Commit graph

53 commits

Author SHA1 Message Date
Abhinav Natarajan
2d917106d1 fix(indent): indent empty lines correctly
fix(indent):
2024-07-05 22:35:19 +09:00
dundargoc
9bc21966f2 fix: typos 2024-02-19 17:45:54 +01:00
Pham Huy Hoang
79dcd0e24c
fix: remove 0-length range usage in indent.lua (#5805) 2023-12-19 19:42:30 +09:00
L Lllvvuu
15d327fe63 fix!: backport ac9e755 from main
Co-authored-by: Pham Huy Hoang <hoangtun0810@gmail.com>
Closes: neovim/neovim#25088
2023-09-11 10:00:25 +02:00
Pham Huy Hoang
ad75d3c4bd fix(indent): return early if query doesn't exist 2023-05-24 13:57:08 +02:00
Pham Huy Hoang
102f1b2f55 fixup: use correct require syntax 2023-05-17 15:35:28 +02:00
Christian Clason
fa23ff4bd7 refactor(indent): backport improvements from main
* replace ts_utils.memoize_by_buftick by simpler implementation
* simplify construction of hash map
* prefer Neovim APIs
2023-05-17 15:25:35 +02:00
Pham Huy Hoang
474c59dcf1 add test 2023-04-08 09:56:06 -07:00
Pham Huy Hoang
1c7ba3ffcf fix(indent): Make indent ignore trailing spaces/comment
Signed-off-by: Pham Huy Hoang <hoangtun0810@gmail.com>
2023-04-08 09:56:06 -07:00
George Harker
cb568af539 use indent.X syntax for captures and properties of set directives
update CONTRIBUTING.md

adjust indents for bass

fix doc capture comment
2023-03-24 13:07:53 -04:00
George Harker
b4fcc61175 split delimiter into open_delimiter and close_delimiter 2023-03-24 13:07:53 -04:00
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
George Harker
fa0644667e fix: change folding algorithm to fix Python indents 2023-03-15 22:44:59 +01:00
Amaan Qureshi
853b1ab39a style: fill in missing code docs wherever applicable 2023-02-24 01:08:23 -08:00
Kiyoon Kim
7eb5f1a2e3 properly replace deprecated tsutils functions 2023-02-12 14:26:14 -08:00
Kiyan
d7f06bfb13
fix(indents): indents for error block (css, lua) (#3207) 2022-07-21 13:48:03 +02:00
Kiyan
7e0651cd56
fix(indent): set only one autocmd for binding indentexpr (#3190) 2022-07-17 08:23:51 +02:00
Christian Clason
07eb437bb1 refactor!: update to Neovim 0.7 APIs
* set highlight groups via nvim_set_hl
* define autocommands via nvim_create_autocmd
* port plugin/nvim-treesitter.vim to Lua
* port healthcheck to Lua
2022-04-30 16:08:01 +02:00
Stephan Seitz
2caac44720 fix: Allow re-parsing in Python, XFAIL \ indentation test 2022-02-06 19:42:57 +01:00
Stephan Seitz
07e07cf303 fix(indents): ignore comment_parsers for indentation 2022-02-05 18:54:55 +01:00
Stephan Seitz
66f33ddd8b Update lua/nvim-treesitter/indent.lua
Co-authored-by: Kiyan <yazdani.kiyan@protonmail.com>
2022-02-05 18:54:55 +01:00
Stephan Seitz
aa035cdf2a workaround(indents): avoid reparsing for indent sensitive yaml/python 2022-02-05 18:54:55 +01:00
Stephan Seitz
b06961a519 fix(indents): re-parse before each indent 2022-02-05 18:54:55 +01:00
Stephan Seitz
fd5a551d7c indents(c): add zero_indent for #if 2022-02-05 18:54:55 +01:00
Stephan Seitz
616dc885fc indents(c): fix indentation on block comment 2022-02-05 18:54:55 +01:00
Stephan Seitz
b9c38a48ca indents: refactor hanging indent 2022-02-05 18:54:55 +01:00
Stephan Seitz
059fbc487c indents: allow aligned_indent for unfinished calls in C and Python 2022-02-05 18:54:55 +01:00
Stephan Seitz
62982378b8 indents(cpp): indent at field_initializer_list 2022-02-05 18:54:55 +01:00
Stephan Seitz
7654bbc04b feat(indents): add support for language injection 2022-02-05 18:54:55 +01:00
Munif Tanjim
8f9d4ada35 feat(indent): ecma - support try_catch and if_else 2022-01-21 16:40:36 +01:00
Munif Tanjim
bb60706433 feat(indent): support @aligned_indent for python 2022-01-21 10:51:51 +01:00
Munif Tanjim
46438064ac refactor(indent): extract functions and support metadata 2022-01-21 10:51:51 +01:00
Munif Tanjim
85140a7a47 feat(indent): use native Query:iter_captures 2022-01-21 10:51:51 +01:00
Munif Tanjim
c0110e34aa feat: rewrite indent module 2022-01-21 10:51:51 +01:00
Munif Tanjim
baf94219aa feat: improve indent module
get_node_at_line should return appropriate child if available
2022-01-21 10:51:51 +01:00
oxalica
6407d54092 fix: off-by-one errors in indent calculation 2021-11-28 14:52:06 +01:00
Santos Gallegos
be8f656087
Use stylua for autoformat code (#1480) 2021-07-04 21:12:17 +00:00
kiyan
7deedc4939 fix: prev_node nil check 2021-04-02 18:41:51 +02:00
kiyan
0f9bdb0939 fix: avoid infinite loop which causes some breakage 2021-04-01 20:50:25 +02:00
kiyan
a2cee8852b fix: indent on new line 2021-04-01 20:50:25 +02:00
Steven Sojka
6863f79118
refactor(all): language tree adaption (#1105) 2021-03-30 08:18:24 -05:00
Brady Phillips
bdbae28b24 Fix indent size
Indent size should equal shiftwidth, unless shiftwidth is 0 in which
case tabstop should be used.
2021-03-22 17:36:19 +01:00
BonaBeavis
be9c4ab36d Fix indent size 2021-02-22 18:17:46 +01:00
yzia2000
839f621955 fixed #630 2021-02-04 20:22:57 +01:00
Jędrzej Boczar
252472081e indent: introduce @ignore to avoid indenting some nodes (e.g. comments) 2021-01-14 13:54:43 +01:00
Jędrzej Boczar
5123231424 indent: introduce @return to further tune indentation on o/<cr> 2021-01-14 13:54:43 +01:00
Jędrzej Boczar
32cc79b7c9 indent: improve behavior on o/<cr> in languages like Python 2021-01-14 13:54:43 +01:00
Jędrzej Boczar
42bc217a54 indent: fix wrong line number passed to descendant_for_range 2021-01-14 13:54:43 +01:00
kiyan42
f2c219cddc indent fixes 2021-01-04 17:42:19 +01:00
Senghan Bright
d3180720f1 fix: support shiftwidth for indents. 2020-12-16 11:43:03 +01:00