Commit graph

208 commits

Author SHA1 Message Date
George Harker
d1333dd7e5 refactor(indent)!: Rework indent, aligned indent
indents now use @indent.X style captures, and indent.PROP for properties to set on those captures, as documented in the help.

Captures are:

indent.auto
indent.begin
indent.end
indent.dedent
indent.branch
indent.ignore
indent.align
indent.zero

Properties are:

indent.immediate
indent.start_at_same_line
indent.open_delimiter
indent.close_delimiter
indent.increment
indent.avoid_last_matching_next

Multiple opening delims on one line and multiple closing on a line are collapsed so as not to over indent,

The final line of @indent.align blocks which must in some cases be treated specially to avoid clashing with the next line is treated the same regardless of whether the @indent.align capture actually uses aligned indentation or just normal indentation. The indent.avoid_last_matching_next property controls this.

Adjust python to use these.

List, set, dict and tuple all use @indent.align which permits both hanging and aligned styles.

Finally, try: on it’s own will indent when typing live but make no guaranteeds about whole-file formatting.

Includes lucario387:fix-align-indent
2023-03-24 13:07:53 -04:00
Lucario387
c7b9f68d03
feat(vue): add tsx/jsx injection queries (#4550)
* feat(vue): add tsx/jsx injection queries

- add a test

- style: format vue/injections.scm
2023-03-24 14:38:19 +00:00
Benny Powers
972da989bc test: ecma injections 2023-03-22 02:28:21 -04:00
Benny Powers
d228b51cd7 test: html injections 2023-03-22 02:28:21 -04:00
Pham Huy Hoang
01e8a51451 feat(python): add "return" patterns to @indent_end
`return ...` is usually the last line of a
function/statement, so mark some possible patterns of `return` with
`@indent_end` to dedent the line after it
2023-03-16 13:41:19 +01:00
Pham Huy Hoang
f5ddd8f92e fix(python): add missing @indent_end 2023-03-16 03:46:01 -04:00
George Harker
fa0644667e fix: change folding algorithm to fix Python indents 2023-03-15 22:44:59 +01:00
Amaan Qureshi
ffa6efa7f5 feat(julia): add tests for new changes 2023-03-10 03:38:23 -05:00
Amaan Qureshi
4a4c475617 fix(gleam): update tests reflecting recent changes 2023-03-10 02:41:45 -05:00
Daniel Woznicki
7947a2ccf1
fix: Java indent for multiple line arguments (#4449)
* fix Java indent for multiple line arguments, fixes #4448, add an additional test for methods with arguments on multiple lines

* Satisfy StyLua check

---------

Co-authored-by: Daniel Woznicki <danwoz@nettoolkit.com>
2023-03-06 18:10:31 -05:00
Pham Huy Hoang
5ac39d10cc indents(vue): fix indents on new line after <template> 2023-03-06 02:32:45 -05:00
Pham Huy Hoang
d11dd552db injections(html): fix faulty css/js injections
Group queries to reduce duplicate injection tree

use only regex
2023-03-05 22:34:41 +02:00
Amaan Qureshi
d7cef15b01 feat(ecma): add tests for constants 2023-03-04 05:00:39 -05:00
Evan Phoenix
28f84d69e3 fix(go): Indent on type switch case properly 2023-03-03 23:36:51 -05:00
Tomas Sandven
061ee1b98f Fix broken YANG indent tests 2023-02-24 16:39:33 -05:00
Tomas Sandven
06e8a91ce2 Add YANG indentation tests 2023-02-24 16:39:33 -05:00
SzeLamC
68ab44277c
fix(dart): add @indent_end to } (#4167)
* fix dart indentation after }

* add some simple test case
2023-02-24 16:06:31 -05:00
Amaan Qureshi
5c511dd124 feat(solidity): use maintained parser and update highlights accordingly 2023-02-24 13:05:33 -08:00
Amaan Qureshi
a3213e3dd7 fix(go): apply indents in a communication case in a select statement 2023-02-24 01:37:58 -08:00
dundargoc
4612212c72 docs: fix typos 2023-02-23 11:39:43 -08:00
Kiyoon Kim
7eb5f1a2e3 properly replace deprecated tsutils functions 2023-02-12 14:26:14 -08:00
Kiyoon Kim
2c2430d42f deprecate get_node_range and is_in_node_range 2023-02-12 02:38:17 -08:00
Alvaro Muñoz
f6531e27fd simplify tests 2023-01-31 12:23:13 +01:00
Alvaro Muñoz
d335c39bff update tests 2023-01-31 12:23:13 +01:00
Alvaro Muñoz
c433b3c232 fix tests 2023-01-31 12:23:13 +01:00
Alvaro Muñoz
9d6d348418 add ql indent tests 2023-01-31 12:23:13 +01:00
Pham Huy Hoang
f669924df2 indents(c): update if cases 2023-01-14 04:52:21 -08:00
Pham Huy Hoang
2f5deed456 indents(c): Refactor indent queries 2023-01-14 04:52:21 -08:00
Cameron
5fb315df12 Update indent-square-brackets.rb 2023-01-09 22:17:50 +01:00
Cameron
bb24f483ca Create indent-square-brackets.rb 2023-01-09 22:17:50 +01:00
lucario387
85d9534491
allow negative assertion in injection tests (#4107)
* tests(vue, svelte): strengthen tests

* fix(html, vue, svelte): fix wrong test format

* allow negative assertions in injection tests
2023-01-07 11:22:20 +01:00
Michael Lan
0922634d37
fix(utils): swap_nodes calculates correct char_delta (#4110)
* fix(utils): swap_nodes calculates correct char_delta

The char_delta is not calculated correctly right now when there are two
treesitter nodes being swapped, one directly following the other. This
is rare but can happen for example when attempting to swap "print" and
"(1)" in "print(1)". In this case an incorrect char_delta is calculated
because of a bug in range comparison.

* test(swap_nodes): check cursor

* add a regression test (for multiline node swap)
* add a test with adjacent swaps that fails when char_delta is not
  calculated correctly

* test(swap_nodes): check text content after swap

* test: note language for parser

* fix tests

* use same not equal for table comparison
2023-01-07 02:53:12 +01:00
Cameron
2d8e6b6662 Add tests correctly for ruby rescue/ensure indentation 2023-01-06 19:48:42 +01:00
Cameron
14bdbef468 Create indent-ensure.rb 2023-01-06 19:48:42 +01:00
Cameron
7eb76dc290 Create indent-rescue.rb 2023-01-06 19:48:42 +01:00
Pham Huy Hoang
2cd89b4bc3 fix(jsx): add missing indent end mark to elements 2023-01-04 12:14:03 +01:00
Pham Huy Hoang
8c71c6c5ed fix(html): fix wrong indents for script/style tags 2023-01-03 17:50:44 +01:00
Lucario387
28baed7698 refactor(svelte): Remove duplicated queries
These injection queries are defined already in html_tags, remove them

Signed-off-by: Pham Huy Hoang <hoangtun0810@gmail.com>
2023-01-03 12:05:10 +01:00
Lucario387
6f4b9b190b refactor(vue, html): Update injections
Update html_tags injections so that html/vue/svelte parsers can use
it without having a script/style tag being captured twice

Signed-off-by: Pham Huy Hoang <hoangtun0810@gmail.com>
2023-01-03 12:05:10 +01:00
Stephan Seitz
6a31d9086e highlights(rust): use @namespace for [(crate) (self) (super)]
Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/3992
2023-01-01 15:32:07 +01:00
Stephan Seitz
ab414f8b1c ci: allow negative assertions in tests 2023-01-01 15:32:07 +01:00
Pedro Castro
6d2b0bd381 move 'in' to repeat 2022-12-31 13:50:47 +01:00
Pedro Castro
ec3d4af104 fix test 2022-12-31 13:50:47 +01:00
Pedro Castro
58c0d78de8 r: update highlights 2022-12-31 13:50:47 +01:00
Michael Hoffmann
ee3e9f4dc0 feat(hcl,terraform): split terraform from hcl, add specialized queries for tf
This enables us to have different queries for
terraform and general hcl. It solve the situation
where other dialects of hcl (nomad, packer, etc)
might use a terraform keyword and get highlighted
out of place.
2022-12-29 22:18:41 +01:00
Lucario387
f5d517f4a7 Fix(vue): Invalid match queries 2022-12-25 17:43:25 +01:00
Lucario387
bbd7ecb25d add test file 2022-12-25 14:58:33 +01:00
xasc
2d48cbc831 feat(t32): initial support 2022-12-21 23:57:06 +01:00
Raymond Ha
6c4772f7b6 indents(ecma): Fix switch default indent 2022-12-07 18:05:33 +01:00
Stephan Seitz
d6a2ecb8b7 highlights: create subscoping for ternary operator
After https://github.com/nvim-treesitter/nvim-treesitter/issues/470,
we decided to use `@conditional` for ternary operator instead of
operator despite `@conditional` is documented for keywords only.
A sub-scoping can make it easier for people to highlight this operator
group differently.

Also unify the usage of `@conditional...` across languages.
2022-12-02 21:42:11 +01:00