Commit graph

37 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
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
ObserverOfTime
fa38f4e6f9 fix(highlights): improve member/property distinction 2024-01-19 16:58:37 +01:00
Pham Huy Hoang
57a8acf0c4 chore: query formatting 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
Christian Segundo
831dbb619e fix(yaml): promql injections block 2023-09-15 12:53:44 +02: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
Constantine Bulany
4115fad9fd
fix(yaml): typo in promql injection (#5130) 2023-07-20 01:41:50 +09:00
Michael Hoffmann
b64ea2ec44 feat(promql,yaml): add parser and yaml injections
Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
2023-07-18 03:03:11 -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
figsoda
d2d8980c5c injections(yaml): fix injections 2022-12-21 23:38:07 +01:00
Jongwook Choi
1a04759d91 folds(yaml): Fold at the entire node, not at the body. 2022-10-16 16:06:09 -07: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
Phelipe Teles
8bd07c88b6 fix(indents/yaml): only indent mapping pair if value is a block
This improves the following situation, in which '|' is the cursor position:

```yaml
- key1: value1
  key2: value2|
```

Before this commit, by pressing Enter would result in this indentation:

```yaml
- key1: value1
  key2: value2
    |
```

Which is less convenient than this:

```yaml
- key1: value1
  key2: value2
  |
```
2022-06-14 22:37:52 +02:00
Phelipe Teles
1a49d068a7 fix(indents/yaml): improve error handling
This helps to solve the first issue reported at #1377.

The problem is that the line loses its indentation when we start
inserting a new mapping pair (specifically, when we enter the character
":").

The issue seems to be solved by auto indenting ERROR nodes.
2022-06-14 22:37:52 +02:00
Phelipe Teles
5e8ec943f8 fix(indents/yaml): indent sequence/list items
This solves the second issue reported at #1377, in which the cursor
would not be aligned with the line "key2: value2" when entering a new
line below it.

```yaml
- key1: value1
  key2: value2
```
2022-06-14 22:37:52 +02:00
Stephan Seitz
4d552d9fda injections(yaml): inject at command list for Gitlab script 2022-02-05 18:25:35 +01:00
Stephan Seitz
71cfcff510 injections(yaml): injection on Gitlab's before_script/after_script 2022-02-05 18:25:35 +01:00
Stephan Seitz
b5d05aaac8 yaml(injections): Also add heuristics for Gitlab CI bash 2021-11-28 15:01:34 +01:00
Stephan Seitz
ad615ffc4c injections(yaml): inject bash on key "run" 2021-11-28 15:01:34 +01:00
Santos Gallegos
fe4e4aa286
yaml: improve highlights and locals (#946)
- More scopes
- Highlight strings as strings
- Recognize more keys/fields

Improvements can be seen with this weird yaml:

```yaml
{ foo: bar }
---
{a: [b, c], [d, e]: f}

---
- { single line, a: b}
- { multi
  line, a: b}
---

"fooo": bar
'foo': bar
one: two
```
2021-10-26 22:47:59 -05: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
Santos Gallegos
574bd5ae37
YAML: update queries (#1203)
Closes https://github.com/nvim-treesitter/nvim-treesitter-refactor/issues/18
2021-04-18 21:51:03 +00:00
Santos Gallegos
c3603ddad1
Yaml: update locals (#1172)
The parser doesn't break the symbols in `*` `&` from the name of
anchors/aliases. So go to definition doesn't work, but highlight of
usage does :D

Test with

```yaml
Defaults: &defaults
  Company: foo
  Item: 123

Computer:
  <<: *defaults
  <<: *defaults
  Price: 3000
```

Ref https://github.com/nvim-treesitter/nvim-treesitter-refactor/issues/18
2021-04-09 19:36:19 -05:00
Santos Gallegos
e4083fc8e1
Add comment parser to highlight comment tags (#893)
Closes #236
2021-03-12 11:21:46 -05:00
Santos Gallegos
6301bf7952 YAML: add locals
This is so incremental selection works
2021-02-10 22:25:12 +01:00
Santos Gallegos
bfcf03853f Yaml: fix folds
Fix https://github.com/nvim-treesitter/nvim-treesitter/issues/887

(block_node) includes more nodes to fold, test with:

```yaml
days:
  Monday:
    - test: example
  Tuesday:
    - test: example
  Wednesday:
    - test: example
    - test: example
  Thursday:
    - test: example
  Friday:
    - test: example
    - foo: |
        One
        Two
        Three
```
2021-02-07 15:37:21 +01:00
elianiva
9184cf3953 feat: added more indent queries 2021-01-14 14:43:04 +01:00
elianiva
842077acf7 feat: added more fold queries 2021-01-04 11:51:23 +01:00
David Hotham
cafe733e23 wildcards to capture keys 2020-12-25 15:56:49 +01:00
David Hotham
dc0432aa54 simplify treatement of escape sequences 2020-12-25 15:56:49 +01:00
David Hotham
18fd5709b7 remove plus from list of punctuation 2020-12-25 15:56:49 +01:00
David Hotham
4addec1361 first draft of YAML highlighting 2020-12-25 15:56:49 +01:00