Commit Graph

55 Commits

Author SHA1 Message Date
Simon Fowler
83277d5545 Improve shell indentation implementation.
Use the custom object match command for copying indentation of blocks,
rather than simply increasing/decreasing indentation when start and end
statements are encountered.

This fixes an issue where a newline added after an already correctly
placed `else` or `fi` would trigger an unnecessary deindent. Tests have
been added to ensure no regression in this behaviour.
2020-09-26 22:10:31 +10:00
Michał Kruszewski
f78cd6daf8 Improve '}' auto inserting for go language.
Adding "} else if ... {" was not correctly handled.
2020-09-20 12:25:26 +02:00
Michał Kruszewski
0f63dd339a Provide better support for Go language.
1. Highlight short variable declaration operator :=.
2. 'while' is not go keyword.
3. Auto insert ')', '}', when line ends with '(' or '{'.
2020-09-07 21:48:06 +02:00
Maxime Coste
8d51a99a3b Merge remote-tracking branch 'pickfire/rust-highlight' 2020-07-31 07:50:14 +10:00
John Isom
428232d2fa Add tests for javascript deindenting 2020-07-29 15:05:49 -06:00
John Isom
504d309894 Add go test cases for bad indentation edge case 2020-07-27 12:18:40 -06:00
John Isom
26f4681c3b Add rust test cases for bad indentation edge case 2020-07-27 12:13:23 -06:00
John Isom
2e6e507d42 Add c-family test cases for bad indentation edge case 2020-07-27 12:02:32 -06:00
John Isom
0439128007 Add test cases for go closing brace indentation 2020-07-26 20:28:33 -06:00
John Isom
d2437b468d Add test cases for rust closing brace indentation 2020-07-26 20:03:54 -06:00
John Isom
46ea52a0a8 Add test cases for c-family closing brace indentation 2020-07-26 19:04:08 -06:00
Ivan Tham
974684aa68 Improve rust comment closing handling
/// foo
    ///%( )

    /// foo
    /// %( )

With `c<ret>bar<esc>`,

    /// foo
    bar

    /// foo
    ///
    /// bar

Based on c-family block comment handling, this patch also add rust
block comment indentation.

This affects `o` behavior on empty comment but it allows a way more
efficient way to clear comments.
2020-07-09 23:02:50 +08:00
Ivan Tham
12cafe3ed4 Rust dedent { after where clause 2020-06-02 00:26:47 +08:00
Ivan Tham
b1beea8638 Rust indent after standalone where 2020-05-31 18:13:04 +08:00
Ivan Tham
de4b7f3864 Rust indent block comment 2020-05-31 18:07:17 +08:00
Ivan Tham
dd3257e3f2 Rust take indentation before comment to next line 2020-05-30 10:54:55 +08:00
Ivan Tham
7c791f130c Handle dedent in rust syntax
Naively handle dedent after , and ; which works most of the cases but
does not work with multi level dedent.
2020-05-30 10:54:55 +08:00
Maxime Coste
0a66eb9c47 Expand env vars as list of strings
This makes it possible to do :select `%val{selections_decs}` and to
correctly combine $kak_quoted with those.
2020-03-02 20:53:28 +11:00
Jason Felice
0ed3bd662c {clojure,lisp}.kak: handle doubled brackets 2020-01-03 15:14:56 -05:00
Jan-Jaap Korpershoek
fcc8ed5df3 [html] Fix indentation when entering a newline while in the middle of a tag
Example:

```
        <tag>|</tag>
```
Then press enter

Old behaviour:
```
        <tag>
            </tag>
```
New behaviour:
```
        <tag>
        </tag>
```

I also added a test for it
2019-11-03 12:25:02 +01:00
Jason Felice
e888f4341c test: Allow expect-style UI tests, testing any var 2019-10-13 14:57:24 -04:00
Maxime Coste
e840140b38 Add indent tests for brace after else indent 2019-07-25 17:27:08 +10:00
Maxime Coste
9363f98f5b Fix indent/sh/deindent-after-esac test case 2019-07-01 22:04:04 +10:00
Simon Fowler
c5dd013235 Add tests.
Probably overkill, but at least this is comprehensive . . .
2019-06-30 12:57:59 +10:00
Dmitry Matveyev
01159a9e72 Add support for autoformatting after do keyword in Ruby 2019-06-12 09:03:24 +03:00
Grant Moyer
d8e4c6801f Fix autoindent issues with paren in literal 2019-03-31 00:07:12 -04:00
Maxime Coste
2c283d46a5 Merge remote-tracking branch 'GrantMoyer/rust-block-indent' 2019-03-29 20:12:34 +11:00
Grant Moyer
71c5077bec Block indent on newline when previous line is '(stuff' and move 'stuff' to own line
Also, align closing paren on own line with opening paren
2019-03-28 13:17:57 -04:00
Grant Moyer
61840c8b11 Preserve tabs during autoindent and alignment with '(' for c-family languages
Also add test for tab preservation during c-family autoindentation, and correct alignment of '}' with opening of block in cases of wrap between '(' and ')' in c-family languages
2019-03-28 13:08:02 -04:00
Alex Leferry 2
c0dccdd90d Add categories in rc/
Closes #2783
2019-03-21 01:06:16 +01:00
Justin Frank
58c15b0240 Indent and deindent c-family single line else properly 2019-02-08 15:16:29 -08:00
Maxime Coste
0600724a8b Improve some corner cases in c-family auto-indenting 2019-01-14 23:42:57 +11:00
Justin Frank
de839d14c4 added test for deindentation 2018-09-12 12:25:36 -07:00
Maxim Baz
ba547ea4dd
Make tests a bit more interesting 2018-07-03 22:32:04 +02:00
Maxim Baz
8a1b557b5f
Add test to ensure whitespaces are preserved after uncomment 2018-06-29 00:10:21 +02:00
Maxim Baz
5d689858df
Improve comment-line command 2018-06-28 23:47:48 +02:00
Maxime Coste
8c6af54db3 c-family.kak: Fix comment line continuation behaviour
Fixes #2043
2018-05-19 14:15:16 +10:00
Maxime Coste
567c82840a ruby.kak: Refactor end autoinsertion logic to be more robust
Fixes the bug described by PR #1994
2018-04-14 12:47:42 +10:00
Nate Clark
27604359d4 Add test for buggy ruby method newline
Currently, inserting a newline after a ruby method will incorrectly
cause the following line to repeat the method header. This commit
adds a test case to illustrate the bug.
2018-04-10 18:30:12 -05:00
Maxime Coste
65258934d3 lua.kak: Rework 'end' auto insertion logic
Fixes #1525
2018-03-04 10:36:32 +11:00
Alyssa Ross
79af68843e
Add Ruby indentation test
See https://github.com/mawww/kakoune/issues/1525#issuecomment-324571751.
2018-03-02 13:13:19 +00:00
Maxime Coste
67424aae1e Remove avoidance of end of lines
Various places in Kakoune code used to modify selections so that
cursors would not lie on an end of line. Remove those to increase
Kakoune's consistency and simplicity.

Now that end of lines are highlighted separately, they should not
be handled specially in most commands.
2018-02-25 00:05:05 +11:00
Maxime Coste
1a38849086 c-family.kak: indent after parenthesis at end of line 2017-12-03 17:47:44 +08:00
Maxime Coste
2b993b7c4b Add an indent test for html closing tag 2017-11-04 12:45:27 +08:00
Maxime Coste
78530b82be Add an indentation test for braces after if 2017-10-25 10:27:39 +08:00
Tim Allen
e640e6d859 Consecutive markdown list bullets are not a valid list prefix.
Previously, if you opened a new line after an underlined heading (what
the CommonMark spec calls a "Setext heading") or inserted a newline into
a line that started with `**strong emphasis**` the Markdown autoindent
hook would assume the leading symbols were list bullets and paste them
at the beginning of the new line.

However, the CommonMark specification says that list bullets must be
followed by at least one horizontal whitespace character, so Setext
heading underlines and strong emphasis are not valid list bullets and
should not be matched by the autoindent pattern.

This commit changes the regex that selects the pastable prefix of the
previous line so that it must match either:

  - One or more `>` characters with optional whitespace between them
    (a blockquote prefix), optionally followed by a list bullet; or
  - An optional blockquote prefix and a list bullet

Since we don't strictly need either the blockquote prefix nor the list
bullet, we could concievably just make both optional... but for lines
without either, the regex would find a zero-length match, and for the
purposes of copy/paste Kakoune treats that as a one-character match.
Therefore, the regex is written to fail if neither pattern is found.
2017-08-01 20:36:40 +10:00
Tim Allen
8a6df93dc6 More tests for markdown autoindent.
All these tests pass with the current implementation.
2017-08-01 19:53:01 +10:00
Maxime Coste
bb9dd14a09 Check final cursor position in indent/c-family/indent-if-body test 2017-07-29 10:46:41 +07:00
Maxime Coste
e73cd78288 Fix corner case in C family indenting 2017-06-13 10:19:38 +01:00
Maxime Coste
1c16a91fd6 Add some missing tests for c-family indent 2017-05-21 22:33:00 +01:00