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:
Stephan Seitz
2020-09-22 23:01:19 +02:00
committed by Stephan Seitz
parent f5ac2b4a1a
commit 45397ebbd9
8 changed files with 46 additions and 12 deletions

View File

@@ -140,7 +140,7 @@ are optional and will not have any effect for now.
@type
@type.builtin
@structure
@namespace for identifiers referring to namespaces
@attribute for e.g. Python decorators
```

View File

@@ -570,9 +570,9 @@ For types.
*hl-TSTypeBuiltin*
For builtin types (you guessed it, right ?).
`TSStructure`
*hl-TSStructure*
This is left as an exercise for the reader.
`TSNamespace`
*hl-TSNamespace*
For identifiers referring to modules and namespaces.
`TSInclude`
*hl-TSInclude*

View File

@@ -30,6 +30,7 @@ hlmap["boolean"] = "TSBoolean"
hlmap["float"] = "TSFloat"
hlmap["annotation"] = "TSAnnotation"
hlmap["attribute"] = "TSAttribute"
hlmap["namespace"] = "TSNamespace"
-- Functions
hlmap["function"] = "TSFunction"

View File

@@ -41,6 +41,7 @@ highlight default link TSProperty Identifier
highlight default link TSConstructor Special
highlight default link TSAnnotation PreProc
highlight default link TSAttribute PreProc
highlight default link TSNamespace Include
highlight default link TSConditional Conditional
highlight default link TSRepeat Repeat
@@ -53,7 +54,6 @@ highlight default link TSException Exception
highlight default link TSType Type
highlight default link TSTypeBuiltin Type
highlight default link TSStructure Structure
highlight default link TSInclude Include
highlight default link TSVariable TSNone

View File

@@ -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)

View File

@@ -90,6 +90,11 @@
(rest_parameter
(identifier) @parameter))
; Variables
;----------
(namespace_import
(identifier) @namespace)
; Literals
;---------

View File

@@ -1,7 +1,7 @@
; Modules
;--------
[(module_name) (module_type_name)] @structure
[(module_name) (module_type_name)] @namespace
; Types
;------

View File

@@ -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)