syntax: Add go & rust locals, improve tree-sitter error message

This commit is contained in:
Blaž Hrastnik 2021-09-06 18:13:52 +09:00
parent 2bef245b7a
commit 4ac29434cb
5 changed files with 57 additions and 6 deletions

View File

@ -144,8 +144,12 @@ impl LanguageConfiguration {
&highlights_query,
&injections_query,
&locals_query,
)
.unwrap(); // TODO: no unwrap
);
let config = match config {
Ok(config) => config,
Err(err) => panic!("{}", err),
}; // TODO: avoid panic
config.configure(scopes);
Some(Arc::new(config))
}

View File

@ -21,14 +21,14 @@
(const_spec
name: (identifier) @constant)
(parameter_declaration (identifier) @variable.parameter)
(variadic_parameter_declaration (identifier) @variable.parameter)
(type_identifier) @type
(field_identifier) @property
(identifier) @variable
(package_identifier) @variable
(parameter_declaration (identifier) @variable.parameter)
(variadic_parameter_declaration (identifier) @variable.parameter)
; Operators

View 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

View 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

View File

@ -9,7 +9,7 @@ special = "honey"
property = "white"
variable = "lavender"
# variable = "almond" # TODO: metavariables only
"variable.parameter" = "lavender"
"variable.parameter" = { fg = "lavender", modifiers = ["underlined"] }
"variable.builtin" = "mint"
type = "white"
"type.builtin" = "white" # TODO: distinguish?