Commit graph

120 commits

Author SHA1 Message Date
Amaan Qureshi
0e27391e90 feat(python): update parser & highlights 2023-08-16 20:28:11 -04:00
TheLeoP
922c396b26 fix(python): right content for regex injection 2023-08-16 12:25:51 -04:00
Amaan Qureshi
64d1696d6d fix(python,starlark): update parsers & add escape_interpolation 2023-08-16 03:23:24 -04:00
Pham Huy Hoang
78b54eb7f6 chore(injections)!: update injection syntax to 0.9
Since 0.9, @lang syntax is still available as fallback but will soon be deprecated.
Because of that, new syntax should be adopted once 0.9 becomes the
baseline requirements for nvim-treesitter

- update health check
- update doc
2023-08-12 17:34:15 +02:00
Amaan Qureshi
9bfc966769 fix(python): fields should not match uppercase-beginning names 2023-04-29 19:38:30 -04: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
Amaan Qureshi
87faf372eb fix(python,starlark): builtin types should come after types 2023-04-25 03:04:05 -04:00
Amaan Qureshi
01b42a1a57 feat(python,starlark): highlight type conversions as @function.macro 2023-04-25 03:04:05 -04:00
Amaan Qureshi
5ab25d8a1f fix(python,starlark): update field match pattern 2023-04-25 03:04:05 -04:00
Amaan Qureshi
85330918f0 perf: remove match where possible 2023-04-21 18:24:17 -04: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
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
Anthony Shi
9253ce66f9 fix(python): add object as @type.builtin 2023-03-22 05:27:28 -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
95bcd6a8fa feat: add @string.documentation where applicable 2023-03-05 17:15:32 -05:00
Amaan Qureshi
33ba346e60 feat!: add @keyword.coroutine capture 2023-03-03 07:07:52 -08:00
Anthony Shi
8894d78f63 Update highlights.scm for Python
Added new keywords "is not" and "not in"
2023-03-02 22:54:45 -05:00
Christian Clason
f95ffd09ed python(highlights): adapt query to parser change 2023-02-28 20:27:09 +01:00
ObserverOfTime
14fa6e015e highlights(python): fix captures 2022-11-26 13:17:51 +02:00
Stephan Seitz
c924128771 highlights(python): add "except*"
Added in https://github.com/tree-sitter/tree-sitter-python/pull/176

About the feature https://realpython.com/python311-exception-groups/#exception-groups-and-except-in-python-311
2022-10-25 12:14:53 +02:00
ObserverOfTime
9b43ab819c highlights: use @preproc where appropriate 2022-10-15 08:49:01 -07:00
Lewis Russell
37398c7d68 feat(spell): support more languages 2022-09-26 13:47:12 +01:00
Lewis Russell
2a63ea5665 feat(spell): upstream spell queries from spellsitter 2022-09-06 12:44:19 +01:00
lfenzo
ae87408513 Split func/method definition from calls in python highlighting query 2022-08-03 12:05:30 -07:00
Ryan Barth
e6ff4c8084 fix: keep cls variable highlighting consistent in class methods 2022-06-14 22:35:14 +02:00
Stephan Seitz
c9ebd16c28 python(folds): fold whole functions not only body 2022-05-15 19:14:52 +02:00
Santos Gallegos
f1373051e5
Python: highlight future import (#2936)
* Python: highlight future import

* Use constant.builtin
2022-05-13 21:46:06 +00:00
Santos Gallegos
132405f18f Python: highlight raise from statement 2022-05-01 10:06:13 +02:00
Ferdinand Ratajczak
74a455c01e fixup! highlights(python): highlight exception keywords 2022-04-07 23:24:18 +02:00
Ferdinand Ratajczak
1fb68f76af highlights(python): highlight exception keywords 2022-04-07 23:24:18 +02:00
Stephan Seitz
b8d1c2445a highlights(python): "from" in yield should be @keyword.return
Fixes #2712
2022-04-01 17:00:21 +02:00
Stephan Seitz
fbcfa7ebee locals(python): adapt as_pattern to upstream change 2022-02-07 22:36:46 +01:00
Stephan Seitz
2caac44720 fix: Allow re-parsing in Python, XFAIL \ indentation test 2022-02-06 19:42:57 +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
c4e3564ea3 highlights(python): add support for pattern matching
Fixes #2080
Depends on https://github.com/tree-sitter/tree-sitter-python/pull/140
2022-01-28 19:11:20 +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
Rafik Draoui
9b262596e0 Remove Python docstring injections
These injections lead to inconsistent highlighting since some edge cases
aren't handled (as mentioned in the PR description that introduced the
injections [0]). Besides, not all Python projects use reStructuredText
syntax in docstrings.

If someone still wants to use them, they can extend the base injection
queries through `after/queries/` [1] or enable them with
`vim.treesitter.set_query`.

See also: https://github.com/nvim-treesitter/nvim-treesitter/pull/1204

[0]: https://github.com/nvim-treesitter/nvim-treesitter/pull/917
[1]: ad69e2528a (adding-queries)
2022-01-04 23:15:30 +01:00
Santos Gallegos
56634f49ab Update queries
- Don't use the old form for predicates
- Update some invalid queries
2021-12-22 21:17:28 +01:00
Fabian
e01c7ce972
highlights(python): Improve self and cls highlight (#2134)
1. This function simplifies an unnecessary lua-match usage.
2. Fixes an accidental change, where "cls" was changed to "class" (fe4f320b66)
3. Match functions, which have have a decorator.
4. But exclude @staticmethod
5. Only highlight "cls" as @variable.builtin when the decorator is @classmethod

This might be a bit to complicated and some of this not to useful,
as this existing rule:

```scm
 ((identifier) @variable.builtin
  (#eq? @variable.builtin "self"))
```

overwrites the queries anyway.
2021-12-18 16:49:30 -05:00
Lewis Russell
011ac894ec Prefer lua-match over match
as string.find is much quicker than vim.regex:match*
2021-11-23 10:02:06 +01:00
Santos Gallegos
6888242b98 Python: highlight semicolon 2021-11-12 19:51:04 +01:00
Dundar Göc
6a4fdb317d chore: fix typos 2021-11-02 23:47:48 +01:00
Santos Gallegos
6d08b25f0e Update queries/python/highlights.scm 2021-11-01 16:54:46 +01:00
Santos Gallegos
df06643aa1 Revert "feat: add del keyword for highlights"
This reverts commit 385193d41f.
2021-11-01 16:54:46 +01:00