mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-07 22:10:01 -04:00
fix(highlights): Add TSNamespace highlight
Start adding highlights for
- C++
- Rust (including other scoped_identifier/scoped_type_identifier fixes)
- JS (only namespace_import)
Addresses #516
This commit is contained in:
parent
f5ac2b4a1a
commit
45397ebbd9
8 changed files with 46 additions and 12 deletions
|
|
@ -28,14 +28,16 @@
|
|||
name: (scoped_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(namespace_identifier) @constant
|
||||
|
||||
((identifier) @type (#match? @type "^[A-Z]"))
|
||||
|
||||
(namespace_identifier) @namespace
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
((namespace_identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
(namespace_definition
|
||||
name: (identifier) @namespace)
|
||||
|
||||
(destructor_name
|
||||
name: (_) @function)
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@
|
|||
(rest_parameter
|
||||
(identifier) @parameter))
|
||||
|
||||
; Variables
|
||||
;----------
|
||||
(namespace_import
|
||||
(identifier) @namespace)
|
||||
|
||||
; Literals
|
||||
;---------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
; Modules
|
||||
;--------
|
||||
|
||||
[(module_name) (module_type_name)] @structure
|
||||
[(module_name) (module_type_name)] @namespace
|
||||
|
||||
; Types
|
||||
;------
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@
|
|||
(type_identifier) @type
|
||||
(primitive_type) @type.builtin
|
||||
(field_identifier) @field
|
||||
|
||||
(mod_item
|
||||
name: (identifier) @namespace)
|
||||
|
||||
; Function calls
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
(identifier) @function .))
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function))
|
||||
|
|
@ -36,6 +40,16 @@
|
|||
(#match? @constant "^[A-Z]"))
|
||||
|
||||
; Assume that uppercase names in paths are types
|
||||
(scoped_identifier
|
||||
path: (identifier) @namespace)
|
||||
(scoped_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @namespace))
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @namespace)
|
||||
(scoped_type_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @namespace))
|
||||
((scoped_identifier
|
||||
path: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
|
@ -43,6 +57,13 @@
|
|||
name: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(crate) @namespace
|
||||
(scoped_use_list
|
||||
path: (identifier) @namespace)
|
||||
(scoped_use_list
|
||||
path: (scoped_identifier
|
||||
(identifier) @namespace))
|
||||
(use_list (scoped_identifier (identifier) @namespace . (_)))
|
||||
(use_list (identifier) @type (#match? @type "^[A-Z]"))
|
||||
(use_as_clause alias: (identifier) @type (#match? @type "^[A-Z]"))
|
||||
|
||||
|
|
@ -60,8 +81,10 @@
|
|||
(#eq? @type "derive"))
|
||||
|
||||
(macro_invocation
|
||||
macro: (identifier) @function.macro
|
||||
"!" @function.macro)
|
||||
macro: (identifier) @function.macro)
|
||||
(macro_invocation
|
||||
macro: (scoped_identifier
|
||||
(identifier) @function.macro .))
|
||||
|
||||
; Function definitions
|
||||
|
||||
|
|
@ -99,6 +122,11 @@
|
|||
|
||||
(self) @variable.builtin
|
||||
|
||||
[
|
||||
"use"
|
||||
"mod"
|
||||
] @include
|
||||
|
||||
[
|
||||
"break"
|
||||
"const"
|
||||
|
|
@ -111,7 +139,6 @@
|
|||
"let"
|
||||
"macro_rules!"
|
||||
"match"
|
||||
"mod"
|
||||
"move"
|
||||
"pub"
|
||||
"ref"
|
||||
|
|
@ -124,7 +151,6 @@
|
|||
"unsafe"
|
||||
"async"
|
||||
"await"
|
||||
"use"
|
||||
"where"
|
||||
(mutable_specifier)
|
||||
(super)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue