mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
docs: document all the captures in CONTRIBUTING.md
This commit is contained in:
parent
de2fa5327a
commit
17aef2898b
1 changed files with 142 additions and 117 deletions
259
CONTRIBUTING.md
259
CONTRIBUTING.md
|
|
@ -89,150 +89,175 @@ effect on highlighting. We will work on improving highlighting in the near futur
|
||||||
|
|
||||||
#### Misc
|
#### Misc
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@comment
|
@comment ; line and block comments
|
||||||
@debug
|
@error ; syntax/parser errors
|
||||||
@error for error `ERROR` nodes.
|
@none ; completely disable the highlight
|
||||||
@none to disable completely the highlight
|
@preproc ; various preprocessor directives & shebangs
|
||||||
@preproc
|
@define ; preprocessor definition directives
|
||||||
@punctuation.delimiter for `;` `.` `,`
|
@operator ; symbolic operators (e.g. `+` / `*`)
|
||||||
@punctuation.bracket for `()` or `{}`
|
|
||||||
@punctuation.special for symbols with special meaning like `{}` in string interpolation.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Constants
|
#### Punctuation
|
||||||
|
|
||||||
|
```scheme
|
||||||
|
@punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`)
|
||||||
|
@punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`)
|
||||||
|
@punctuation.special ; special symbols (e.g. `{}` in string interpolation)
|
||||||
```
|
```
|
||||||
@constant
|
|
||||||
@constant.builtin
|
#### Literals
|
||||||
@constant.macro
|
|
||||||
@string
|
```scheme
|
||||||
@string.regex
|
@string ; string literals
|
||||||
@string.escape
|
@string.regex ; regular expressions
|
||||||
@string.special
|
@string.escape ; escape sequences
|
||||||
@character
|
@string.special ; other special strings (e.g. dates)
|
||||||
@character.special
|
|
||||||
@number
|
@character ; character literals
|
||||||
@boolean
|
@character.special ; special characters (e.g. wildcards)
|
||||||
@float
|
|
||||||
|
@boolean ; boolean literals
|
||||||
|
@number ; numeric literals
|
||||||
|
@float ; floating-point number literals
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Functions
|
#### Functions
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@function
|
@function ; function definitions
|
||||||
@function.builtin
|
@function.builtin ; built-in functions
|
||||||
@function.call
|
@function.call ; function calls
|
||||||
@function.macro
|
@function.macro ; preprocessor macros
|
||||||
@parameter
|
|
||||||
|
|
||||||
@method
|
@method ; method definitions
|
||||||
@method.call
|
@method.call ; method calls
|
||||||
@field
|
|
||||||
@property
|
|
||||||
|
|
||||||
@constructor
|
@constructor ; constructor calls and definitions
|
||||||
|
@parameter ; parameters of a function
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Keywords
|
#### Keywords
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@conditional (e.g. `if`, `else`)
|
@keyword ; various keywords
|
||||||
@repeat (e.g. `for`, `while`)
|
@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python)
|
||||||
@label for C/Lua-like labels
|
@keyword.operator ; operators that are English words (e.g. `and` / `or`)
|
||||||
@keyword
|
@keyword.return ; keywords like `return` and `yield`
|
||||||
@keyword.function (keyword to define a function, e.g. `func` in Go, `def` in Python)
|
|
||||||
@keyword.operator (for operators that are English words, e.g. `and`, `or`)
|
|
||||||
@keyword.return
|
|
||||||
@operator (for symbolic operators, e.g. `+`, `*`)
|
|
||||||
@exception (e.g. `throw`, `catch`)
|
|
||||||
@include keywords for including modules (e.g. import/from in Python)
|
|
||||||
@storageclass
|
|
||||||
|
|
||||||
@type
|
@conditional ; keywords related to conditionals (e.g. `if` / `else`)
|
||||||
@type.builtin
|
@repeat ; keywords related to loops (e.g. `for` / `while`)
|
||||||
@type.definition
|
@debug ; keywords related to debugging
|
||||||
@type.qualifier
|
@label ; GOTO and other labels (e.g. `label:` in C)
|
||||||
@namespace for identifiers referring to namespaces
|
@include ; keywords for including modules (e.g. `import` / `from` in Python)
|
||||||
@symbol for identifiers referring to symbols
|
@exception ; keywords related to exceptions (e.g. `throw` / `catch`)
|
||||||
@attribute for e.g. Python decorators
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing.
|
#### Types
|
||||||
|
|
||||||
#### Variables
|
```scheme
|
||||||
|
@type ; type or class definitions and annotations
|
||||||
|
@type.builtin ; built-in types
|
||||||
|
@type.definition ; type definitions (e.g. `typedef` in C)
|
||||||
|
@type.qualifier ; type qualifiers (e.g. `const`)
|
||||||
|
|
||||||
|
@storageclass ; visibility/life-time/etc. modifiers (e.g. `static`)
|
||||||
|
@attribute ; attribute annotations (e.g. Python decorators)
|
||||||
|
@field ; object and struct fields
|
||||||
|
@property ; similar to `@field`
|
||||||
```
|
```
|
||||||
@variable
|
|
||||||
@variable.builtin
|
#### Identifiers
|
||||||
@variable.global
|
|
||||||
|
```scheme
|
||||||
|
@variable ; various variable names
|
||||||
|
@variable.builtin ; built-in variable names (e.g. `this`)
|
||||||
|
|
||||||
|
@constant ; constant identifiers
|
||||||
|
@constant.builtin ; built-in constant values
|
||||||
|
@constant.macro ; constants defined by the preprocessor
|
||||||
|
|
||||||
|
@namespace ; modules or namespaces
|
||||||
|
@symbol ; symbols or atoms
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Text
|
#### Text
|
||||||
|
|
||||||
Mainly for markup languages.
|
Mainly for markup languages.
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@text
|
@text ; non-structured text
|
||||||
@text.strong
|
@text.strong ; bold text
|
||||||
@text.emphasis
|
@text.emphasis ; text with emphasis
|
||||||
@text.underline
|
@text.underline ; underlined text
|
||||||
@text.strike
|
@text.strike ; strikethrough text
|
||||||
@text.title
|
@text.title ; text that is part of a title
|
||||||
@text.literal
|
@text.literal ; literal or verbatim text
|
||||||
@text.uri
|
@text.uri ; URIs (e.g. hyperlinks)
|
||||||
@text.math (e.g. for LaTeX math environments)
|
@text.math ; math environments (e.g. `$ ... $` in LaTeX)
|
||||||
@text.environment (e.g. for text environments of markup languages)
|
@text.environment ; text environments of markup languages
|
||||||
@text.environment.name (e.g. for the name/the string indicating the type of text environment)
|
@text.environment.name ; text indicating the type of an environment
|
||||||
@text.reference (for footnotes, text references, citations)
|
@text.reference ; text references, footnotes, citations, etc.
|
||||||
|
|
||||||
@text.note
|
@text.todo ; todo notes
|
||||||
@text.warning
|
@text.note ; info notes
|
||||||
@text.danger
|
@text.warning ; warning notes
|
||||||
|
@text.danger ; danger/error notes
|
||||||
@todo
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Tags
|
#### Tags
|
||||||
|
|
||||||
Used for xml-like tags
|
Used for XML-like tags.
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@tag
|
@tag ; XML tag names
|
||||||
@tag.attribute
|
@tag.attribute ; XML tag attributes
|
||||||
@tag.delimiter
|
@tag.delimiter ; XML tag delimiters
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Conceal
|
#### Conceal
|
||||||
|
|
||||||
@conceal followed by `(#set! conceal "")` for captures that are not used for highlights but only for concealing.
|
|
||||||
|
```scheme
|
||||||
|
@conceal ; for captures that are only used for concealing
|
||||||
|
```
|
||||||
|
|
||||||
|
`@conceal` must be followed by `(#set! conceal "")`.
|
||||||
|
|
||||||
#### Spell
|
#### Spell
|
||||||
|
|
||||||
@spell for defining regions to be spellchecked.
|
```scheme
|
||||||
|
@spell ; for defining regions to be spellchecked
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Non-standard
|
||||||
|
|
||||||
|
These captures are used by some languages but don't have any default highlights.
|
||||||
|
They fall back to the parent capture if they are not manually defined.
|
||||||
|
|
||||||
|
```scheme
|
||||||
|
@variable.global
|
||||||
|
```
|
||||||
|
|
||||||
### Locals
|
### Locals
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@definition for various definitions
|
@definition ; various definitions
|
||||||
@definition.constant
|
@definition.constant ; constants
|
||||||
@definition.function
|
@definition.function ; functions
|
||||||
@definition.method
|
@definition.method ; methods
|
||||||
@definition.var
|
@definition.var ; variables
|
||||||
@definition.parameter
|
@definition.parameter ; parameters
|
||||||
@definition.macro
|
@definition.macro ; preprocessor macros
|
||||||
@definition.type
|
@definition.type ; types or classes
|
||||||
@definition.field
|
@definition.field ; fields or properties
|
||||||
@definition.enum
|
@definition.enum ; enumerations
|
||||||
@definition.namespace for modules or C++ namespaces
|
@definition.namespace ; modules or namespaces
|
||||||
@definition.import for imported names
|
@definition.import ; imported names
|
||||||
|
@definition.associated ; the associated type of a variable
|
||||||
|
|
||||||
@definition.associated to determine the type of a variable
|
@scope ; scope block
|
||||||
@definition.doc for documentation adjacent to a definition. E.g.
|
@reference ; identifier reference
|
||||||
|
|
||||||
@scope
|
|
||||||
@reference
|
|
||||||
@constructor
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -266,8 +291,8 @@ Possible scope values are:
|
||||||
|
|
||||||
You can define folds for a given language by adding a `folds.scm` query :
|
You can define folds for a given language by adding a `folds.scm` query :
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@fold
|
@fold ; fold this node
|
||||||
```
|
```
|
||||||
|
|
||||||
If the `fold.scm` query is not present, this will fallback to the `@scope` captures in the `locals`
|
If the `fold.scm` query is not present, this will fallback to the `@scope` captures in the `locals`
|
||||||
|
|
@ -281,25 +306,25 @@ You can directly use the name of the language that you want to inject (e.g. `@ht
|
||||||
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@language` to capture
|
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@language` to capture
|
||||||
the node describing the language and `@content` to describe the injection region.
|
the node describing the language and `@content` to describe the injection region.
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@{language} ; e.g. @html to describe a html region
|
@{lang} ; e.g. @html to describe a html region
|
||||||
|
|
||||||
@language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language).
|
@language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language)
|
||||||
@content ; region for the dynamically detected language.
|
@content ; region for the dynamically detected language
|
||||||
@combined ; This will combine all matches of a pattern as one single block of content.
|
@combined ; combine all matches of a pattern as one single block of content
|
||||||
```
|
```
|
||||||
|
|
||||||
### Indents
|
### Indents
|
||||||
|
|
||||||
```
|
```scheme
|
||||||
@indent ; Indent children when matching this node
|
@indent ; indent children when matching this node
|
||||||
@indent_end ; Marks the end of indented block
|
@indent_end ; marks the end of indented block
|
||||||
@aligned_indent ; Behaves like python aligned/hanging indent
|
@aligned_indent ; behaves like python aligned/hanging indent
|
||||||
@dedent ; Dedent children when matching this node
|
@dedent ; dedent children when matching this node
|
||||||
@branch ; Dedent itself when matching this node
|
@branch ; dedent itself when matching this node
|
||||||
@ignore ; Do not indent in this node
|
@ignore ; do not indent in this node
|
||||||
@auto ; Behaves like 'autoindent' buffer option
|
@auto ; behaves like 'autoindent' buffer option
|
||||||
@zero_indent ; Sets this node at position 0 (no indent)
|
@zero_indent ; sets this node at position 0 (no indent)
|
||||||
```
|
```
|
||||||
|
|
||||||
[Zulip]: https://nvim-treesitter.zulipchat.com
|
[Zulip]: https://nvim-treesitter.zulipchat.com
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue