nvim-treesitter/runtime/queries/rbs/highlights.scm

188 lines
2.3 KiB
Scheme
Raw Normal View History

2023-12-01 01:22:29 +09:00
; Use directive
(use_clause
[
(type_name)
(simple_type_name)
] @type)
2024-02-19 16:49:04 +01:00
; Builtin constants and Keywords
2023-12-01 01:22:29 +09:00
[
"true"
"false"
] @boolean
"nil" @constant.builtin
[
"use"
"as"
"module"
"def"
"attr_reader"
"attr_writer"
"attr_accessor"
"end"
"alias"
] @keyword
2024-04-23 12:23:15 -07:00
[
"interface"
"type"
"class"
] @keyword.type
(class_decl
"end" @keyword.type)
(interface_decl
"end" @keyword.type)
2023-12-01 01:22:29 +09:00
"def" @keyword.function
; Members of declaration
[
2024-01-06 15:05:50 +09:00
"include"
"extend"
"prepend"
2023-12-01 01:22:29 +09:00
] @function.method
(visibility) @keyword.modifier
2023-12-01 01:22:29 +09:00
(comment) @comment @spell
(method_member
(method_name
[
2024-01-06 15:05:50 +09:00
(identifier)
(identifier_suffix)
2024-01-06 15:05:50 +09:00
(constant)
(constant_suffix)
2024-01-06 15:05:50 +09:00
(operator)
(setter)
(constant_setter)
] @function.method))
(attribute_member
(method_name
[
(identifier)
(identifier_suffix)
(constant)
(constant_suffix)
(operator)
(setter)
(constant_setter)
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
] @function.method))
2023-12-01 01:22:29 +09:00
2024-01-06 15:05:50 +09:00
[
(ivar_name)
(cvar_name)
] @variable.member
2024-01-06 15:05:50 +09:00
(alias_member
(method_name) @function)
(class_name
(constant) @type)
(module_name
(constant) @type)
2023-12-01 01:22:29 +09:00
2024-01-06 15:05:50 +09:00
(interface_name
(interface) @type)
(alias_name
(identifier) @type)
2023-12-01 01:22:29 +09:00
(type_variable) @constant
2024-01-06 15:05:50 +09:00
(namespace
(constant) @module)
2023-12-01 01:22:29 +09:00
(builtin_type) @type.builtin
2024-01-06 15:05:50 +09:00
(const_name
(constant) @constant)
(global_name) @variable
2023-12-01 01:22:29 +09:00
; Generics Keywords
[
(generics_unchecked)
(generics_variance)
] @keyword
2023-12-01 01:22:29 +09:00
; Standard Arguments
2024-01-06 15:05:50 +09:00
(parameter
(var_name) @variable.parameter)
2023-12-01 01:22:29 +09:00
(unnamed_parameter) @variable.parameter
2023-12-01 01:22:29 +09:00
; Keyword Arguments
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
(keyword) @variable.parameter
2023-12-01 01:22:29 +09:00
; Self
(self) @variable.builtin
; Literal
2024-01-06 15:05:50 +09:00
(type
(symbol_literal) @string.special.symbol)
2023-12-01 01:22:29 +09:00
2024-01-06 15:05:50 +09:00
(type
(string_literal
(escape_sequence) @string.escape))
2023-12-01 01:22:29 +09:00
2024-01-06 15:05:50 +09:00
(type
(string_literal) @string)
2023-12-01 01:22:29 +09:00
2024-01-06 15:05:50 +09:00
(type
(integer_literal) @number)
2023-12-01 01:22:29 +09:00
(type
(record_type
key: (record_key) @string.special.symbol))
2024-01-06 15:05:50 +09:00
; Operators
2023-12-01 01:22:29 +09:00
[
2024-01-06 15:05:50 +09:00
"="
"->"
"<"
"**"
"*"
"&"
"|"
"^"
"?"
(rest_operator)
(block_operator)
(optional_block_operator)
2024-01-06 15:05:50 +09:00
] @operator
2023-12-01 01:22:29 +09:00
; Punctuation
[
2024-01-06 15:05:50 +09:00
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
2023-12-01 01:22:29 +09:00
[
2024-01-06 15:05:50 +09:00
","
"."
":"
2024-01-06 15:05:50 +09:00
] @punctuation.delimiter
; RBS Inline syntax
(inline_class_annotation) @keyword
(inline_doc
(var_name) @variable.parameter)
(inline_generic) @keyword
(inline_override) @keyword
(inline_skip) @keyword