syntax: Add go & rust locals, improve tree-sitter error message
This commit is contained in:
parent
2bef245b7a
commit
4ac29434cb
5 changed files with 57 additions and 6 deletions
|
@ -144,8 +144,12 @@ impl LanguageConfiguration {
|
||||||
&highlights_query,
|
&highlights_query,
|
||||||
&injections_query,
|
&injections_query,
|
||||||
&locals_query,
|
&locals_query,
|
||||||
)
|
);
|
||||||
.unwrap(); // TODO: no unwrap
|
|
||||||
|
let config = match config {
|
||||||
|
Ok(config) => config,
|
||||||
|
Err(err) => panic!("{}", err),
|
||||||
|
}; // TODO: avoid panic
|
||||||
config.configure(scopes);
|
config.configure(scopes);
|
||||||
Some(Arc::new(config))
|
Some(Arc::new(config))
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
(const_spec
|
(const_spec
|
||||||
name: (identifier) @constant)
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
(parameter_declaration (identifier) @variable.parameter)
|
||||||
|
(variadic_parameter_declaration (identifier) @variable.parameter)
|
||||||
|
|
||||||
(type_identifier) @type
|
(type_identifier) @type
|
||||||
(field_identifier) @property
|
(field_identifier) @property
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
(package_identifier) @variable
|
(package_identifier) @variable
|
||||||
|
|
||||||
(parameter_declaration (identifier) @variable.parameter)
|
|
||||||
(variadic_parameter_declaration (identifier) @variable.parameter)
|
|
||||||
|
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
|
|
||||||
|
|
30
runtime/queries/go/locals.scm
Normal file
30
runtime/queries/go/locals.scm
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
; Scopes
|
||||||
|
|
||||||
|
(block) @local.scope
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
|
||||||
|
(parameter_declaration (identifier) @local.definition)
|
||||||
|
(variadic_parameter_declaration (identifier) @local.definition)
|
||||||
|
|
||||||
|
(short_var_declaration
|
||||||
|
left: (expression_list
|
||||||
|
(identifier) @local.definition))
|
||||||
|
|
||||||
|
(var_spec
|
||||||
|
name: (identifier) @local.definition)
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
(range_clause
|
||||||
|
left: (expression_list
|
||||||
|
(identifier) @local.definition)))
|
||||||
|
|
||||||
|
(const_declaration
|
||||||
|
(const_spec
|
||||||
|
name: (identifier) @local.definition))
|
||||||
|
|
||||||
|
; References
|
||||||
|
|
||||||
|
(identifier) @local.reference
|
||||||
|
(field_identifier) @local.reference
|
||||||
|
|
17
runtime/queries/rust/locals.scm
Normal file
17
runtime/queries/rust/locals.scm
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
; Scopes
|
||||||
|
|
||||||
|
(block) @local.scope
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
|
||||||
|
(parameter
|
||||||
|
(identifier) @local.definition)
|
||||||
|
|
||||||
|
(let_declaration
|
||||||
|
pattern: (identifier) @local.definition)
|
||||||
|
|
||||||
|
(closure_parameters (identifier)) @local.definition
|
||||||
|
|
||||||
|
; References
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
|
@ -9,7 +9,7 @@ special = "honey"
|
||||||
property = "white"
|
property = "white"
|
||||||
variable = "lavender"
|
variable = "lavender"
|
||||||
# variable = "almond" # TODO: metavariables only
|
# variable = "almond" # TODO: metavariables only
|
||||||
"variable.parameter" = "lavender"
|
"variable.parameter" = { fg = "lavender", modifiers = ["underlined"] }
|
||||||
"variable.builtin" = "mint"
|
"variable.builtin" = "mint"
|
||||||
type = "white"
|
type = "white"
|
||||||
"type.builtin" = "white" # TODO: distinguish?
|
"type.builtin" = "white" # TODO: distinguish?
|
||||||
|
|
Loading…
Add table
Reference in a new issue