Commit graph

81 commits

Author SHA1 Message Date
Pham Huy Hoang
57a8acf0c4 chore: query formatting 2024-01-19 16:58:37 +01:00
Pham Huy Hoang
edee83272e refactor: manual pre-cleanup
Moving comments, adding `format-ignore` to lines that will be better
with it
2024-01-19 16:58:37 +01:00
Christian Clason
1ae9b0e455 feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.

Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.

Specifically:

* tree-sitter "standard capture names"
  (3f44b89685/highlight/src/lib.rs (L20-L72)):

  - `@parameter` -> `@variable.parameter`
  - `@field` -> `@variable.member`
  - `@namespace` -> `@module`
  - `@float` -> `@number.float`
  - `@symbol` -> `@string.special.symbol`
  - `@string.regex` -> `@string.regexp`
  - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
  - `@text.title` -> `@markup.heading`
  - `@text.literal` -> `@markup.raw`
  - `@text.reference` -> `@markup.link`
  - `@text.uri` -> `@markup.link.url` (in markup links)
  - `@string.special` -> `@markup.link.label` (non-url links)
  - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)

* Helix captures
  (https://docs.helix-editor.com/master/themes.html#syntax-highlighting):

  - `@method` -> `@function.method`
  - `@method.call` -> `@function.method.call`
  - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
  - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
  - `@text.uri` -> `@string.special.url` (outside markup)
  - `@preproc` -> `@keyword.directive`
  - `@define` -> `@keyword.directive`(`.define`?)
  - `@storageclass` -> `@keyword.storage`
  - `@conditional` -> `@keyword.conditional`
  - `@debug` -> `@keyword.debug`
  - `@exception` -> `@keyword.exception`
  - `@include` -> `@keyword.import`
  - `@repeat` -> `@keyword.repeat`

* cleanup

  - remove some redundant `@conceal` (but still allow it for conceal-only patterns)
  - remove obsolete `@error` (syntax linting is out of scope for this repo)
  - sort, cleanup capture list in `CONTRIBUTING.md`
2024-01-19 16:58:37 +01:00
ObserverOfTime
ab818bf5a2 fix(python): restrict typed parameter highlight
Only the name is a parameter and not the value
2023-12-14 13:05:40 -05:00
ObserverOfTime
2583eb351b fix(python): highlight variadic lambda parameters 2023-12-14 13:05:40 -05:00
Riley Bruins
1610b1aafb
feat(python): @string.regex capture, injection improvements (#5697)
* feat(python): `@string.regex` capture, injection improvements

* fix(python): match regex only for first argument of re module

* chore(python): remove unneeded capture

Co-authored-by: Santos Gallegos <stsewd@proton.me>

* fix(python): only highlight string content itself as regex

---------

Co-authored-by: Santos Gallegos <stsewd@proton.me>
2023-11-21 01:26:18 +09:00
Pham Huy Hoang
107e61afb7 refactor: Remove all (ERROR) @error captures
As discussed in PR#5421, capturing `@error` is inconsistent, requiring
deep nesting (or priority) in order to correctly have red backgrounds to
it.

Some queries has this capture, some don't. For consistency purposes,
removing all of them is more preferable.

For re-enabling error, either add `(ERROR) @error` or `(ERROR _ @error)`
to your custom queries.
2023-10-25 18:18:50 +02:00
Amaan Qureshi
0e27391e90 feat(python): update parser & highlights 2023-08-16 20:28:11 -04:00
Amaan Qureshi
64d1696d6d fix(python,starlark): update parsers & add escape_interpolation 2023-08-16 03:23:24 -04:00
Amaan Qureshi
9bfc966769 fix(python): fields should not match uppercase-beginning names 2023-04-29 19:38:30 -04: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
Anthony Shi
9253ce66f9 fix(python): add object as @type.builtin 2023-03-22 05:27:28 -04: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
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
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
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
Ashish Panigrahi
385193d41f feat: add del keyword for highlights 2021-11-01 13:19:27 +01:00
Santos Gallegos
10419ee747 Python: highlight interpolation escaped chars
Support for these was just added in the grammar.
2021-10-22 09:21:42 +02:00
Santos Gallegos
948fa6a260
Python: fix class highlights (#1548) 2021-07-11 15:06:52 -05:00
Sergio Alejandro Vargas
017760113a Highlights(python): Add @keyword.function
Use `@keyword.function` for `def` and `lambda`
2021-07-06 00:53:40 +02:00
antonk52
90f15d9bf7 feat(keywords) merge return and yield into keyword.return group 2021-07-04 21:49:17 +02:00
antonk52
bd9095e969 feat(keywords) add keyword.return & keyword.yield 2021-07-04 21:49:17 +02:00
Stephan Seitz
6d5b4f19f3 python(highlights): don't use type for APP 2021-07-01 22:50:33 +02:00
Stephan Seitz
fe4f320b66 highlights(python): use any-of? 2021-05-16 21:13:12 +02:00
Stephan Seitz
b441f257a4 Python highlights: update definition of decorator 2021-01-07 08:52:41 +01:00
Stephan Seitz
40588da97c Remove usages of @embedded in highlights 2021-01-06 09:12:32 -05:00
Santos Gallegos
1ad1f3b35a Python: fix self highlighing 2020-12-18 20:33:04 +01:00