Commit graph

36 commits

Author SHA1 Message Date
Phạm Huy Hoàng
722617e672 refactor(format): drop extra indentation for field 2024-03-21 15:51:26 +01:00
Christian Clason
99ddf57353
feat(highlights)!: enforce documented captures (#6232)
Problem: Allowing undocumented "secret" (sub)captures makes it harder
to write comprehensive colorschemes and catch inconsistent captures.

Solution: Only allow captures listed in CONTRIBUTING.md. Add useful
(cross-language) subcaptures and drop language-specific or too niche
ones.

Follow-up: Adding further `*.builtin` captures and changing queries to
use them.

Language-specific subcaptures should instead be added in user config or
a custom language plugin.
2024-03-03 11:00:11 +01:00
再生花
31641d72a4
feat(format-scripts): linewrap predicates
"format-ignore".kick()
2024-02-23 10:42:01 +02:00
Phạm Huy Hoàng
d198a75e2c
Fixup format (#5934)
* fix(format): newline between top-level field defs

* fixup: newline between node and comment

* fixup: optimize pattern
2024-01-20 18:47:56 +09:00
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
Christian Clason
5b90ea2aba feat(locals)!: switch to upstream captures 2024-01-19 16:58:37 +01: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
17d3398b5b feat: add CSV, PSV, & TSV 2023-08-17 11:15:54 -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
ObserverOfTime
7bef1d5330 highlights(rst): don't spell check links 2023-01-22 14:11:45 +01:00
ObserverOfTime
90c44df8cb highlights(rst): disable spell for code blocks
injections(rst): add sourcecode directive
2022-10-15 08:12:55 -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
Santos Gallegos
9a98ed1f96
RST: use any-of? instead of match? (#1678) 2021-08-08 12:37:08 -05:00
Santos Gallegos
1e8016d92d
RST: add code-block to injections (#1677)
This isn't part of the rst spec,
but it's common enough on third party libs (sphinx specially).
2021-08-08 11:16:11 -05:00
Santos Gallegos
c1f61d4ca1
Improve check-queries (#1253)
- Add checks for injections.
- Allow queries that start with [A-Z] for highlights only.
- Don't stop on the first error, finish checking all queries.
2021-05-31 17:03:27 +00:00
Santos Gallegos
67f0857015 Revert "Comment: use @combined to create just one tree per buffer (#1252)"
This reverts commit 4a7a713c52.
2021-05-07 16:51:57 +02:00
Santos Gallegos
4a7a713c52
Comment: use @combined to create just one tree per buffer (#1252)
* Comment: use `@combined` to create just one tree per buffer

There is no need to create a tree per line/block for comments.
Should fix https://github.com/nvim-treesitter/nvim-treesitter/issues/1251

* Add injections for scss

* Fix jsonc

* Combine jsdoc
2021-04-28 07:19:07 -05:00
Stephan Seitz
712cc78a1e Add text.reference and text.environment 2021-03-30 19:26:37 +02:00
Santos Gallegos
e4083fc8e1
Add comment parser to highlight comment tags (#893)
Closes #236
2021-03-12 11:21:46 -05:00
Stephan Seitz
2655fc94b0 highlights(rst): Reset highlights in doctest_block 2021-02-15 15:36:33 -05:00
Santos Gallegos
6aaf240d0c RST: update injection queries
Finally, highlight for code blocks
2021-01-02 17:19:08 -05:00
Santos Gallegos
5ffcd75ea6 RST: update parser and queries
- The directive type does not longer includes `::`.
- The content of the directives is not longer interpreted as rst,
  but it uses language injection for it.
- Fix a query to allow to capture targets without link.
- Reset the content of the math role so it can be highlighted by the
  injection instead.

Problems I found:

- Capturing the same node with @language and @content will raise an
  error.

  ```
  Error detected while processing FileType Autocommands for "*":
  E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:331: table index is nil
  ```

  Harcoding the language works, Using the offset predicate doesn't work
  either `(#offset! 0 0 1 0)` nor `(#offset! 0 0 0 5)`

- Generating the grammar using `tree-sitter-cli@0.17.x` breaks
  nvim-treesitter, `@0.16.9` works.
2021-01-01 09:49:14 -05:00
Stephan Seitz
3362f45196 Remove textobjects module 2020-10-04 14:20:20 +02:00
Santos Gallegos
5c85e6beee RST: update queries
Some nodes were renamed and added more textobjects.
2020-09-18 21:29:19 +02:00
Santos Gallegos
09c703193f RST: update locals
A title is an implicit target.
2020-09-15 20:59:02 +02:00
Santos Gallegos
c719e60266 rst: remove unused captures
This is causing an error.
2020-09-06 21:57:32 +02:00
Steven Sojka
ce43dbf54c fix(queries): use vim-match for non lua regexes 2020-08-16 18:31:56 +02:00
Santos Gallegos
8f3b601bcc RST: update textobjects 2020-08-11 20:21:03 +02:00
Santos Gallegos
81d444c498 RST: update queries 2020-08-07 10:51:00 +02:00
Santos Gallegos
5c5f4c5d54 RST: update locals 2020-08-01 19:18:54 +02:00
Santos Gallegos
8cacd5aaac RST: update highlights 2020-08-01 14:33:36 +02:00
Santos Gallegos
b1da6ad8b3 rst: update highlight queries 2020-07-29 10:04:46 +02:00
Santos Gallegos
6f01384cb2 Parsers: add reStructuredText 2020-07-27 09:16:26 +02:00