Commit Graph

18 Commits

Author SHA1 Message Date
Pham Huy Hoang
1ffa019856 feat(python): add match-case indents 2023-03-25 00:31:57 -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
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
Stephan Seitz
2caac44720 fix: Allow re-parsing in Python, XFAIL \ indentation test 2022-02-06 19:42:57 +01:00
Stephan Seitz
d615497e7e indents(python): remove branches.py from expected failures
The previous indentation actually causes a linter warning when using
pep8
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
Munif Tanjim
bb60706433 feat(indent): support @aligned_indent for python 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
Stephan Seitz
c7634f16de Mark failing indent tests to add them to CI
Expected failures should be monitored so that we don't have regressions
and also remove failure marks when they are resolved.
2021-11-24 17:29:55 +01:00
Santos Gallegos
be8f656087 Use stylua for autoformat code (#1480) 2021-07-04 21:12:17 +00:00
Jędrzej Boczar
af3537fbe5 tests/indent: factor out most of the code into common.lua 2021-04-23 21:21:38 +02:00
Jędrzej Boczar
dbb1550aaf tests/indent: move common code out of main lua/ directory 2021-04-23 21:21:38 +02:00
Jędrzej Boczar
db97170e4e tests/indent: move the run helper functions to top-level 2021-04-23 21:21:38 +02:00
Jędrzej Boczar
63a88c873f move all tests to top-level tests/ directory 2021-04-23 21:21:38 +02:00