13 Commits

Author SHA1 Message Date
Grace Petryk
f16a775830 feat(python): Improved python indentation (#6859)
* feat: improve python indentation

* use lua-match

* revert concatenated_string changes, handle function def hanging indents

* lint

* add delimiters to param query

* add test cases
2024-07-16 20:13:41 +09:00
Riley Bruins
d96bf9d522 fix(python): better try-except indentation (#6097) 2024-02-15 00:39:59 +07:00
Pham Huy Hoang
1ca9b938c1 Add Python else elif dedent (#4618)
* feat(python): add interactive else/elif dedent

* fixup

* add test
2023-04-29 10:35:35 +02:00
Pham Huy Hoang
c9ef5e58f7 feat(python): add break/continue dedent 2023-03-25 00:31:57 -04:00
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
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
059fbc487c indents: allow aligned_indent for unfinished calls in C and Python 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
Jędrzej Boczar
63a88c873f move all tests to top-level tests/ directory 2021-04-23 21:21:38 +02:00