-
Notifications
You must be signed in to change notification settings - Fork 18
Highlight fixes #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlight fixes #241
Changes from all commits
419bd37
1ad1493
32944ca
3e82ffc
4fb7aeb
a72871e
ef8fa56
b5a655d
53eba40
37dcedd
07dcf9b
88d6a90
b3ba626
5479086
20f0b4a
bfa3fae
6680403
08e1ecd
9a7d2cc
0c5f544
d5bd57f
83f7209
777ddf5
dc8abb8
8196309
ac21b00
bf62a2d
85a4f41
3a20909
d5a3946
1fe1bbd
996bde6
74f3f3a
7473a29
736c0bb
bc3b707
f81c39d
e4bed23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,54 @@ | |
((value_identifier) @constant.macro | ||
(#match? @constant.macro "^\\.*$")) | ||
|
||
|
||
((value_identifier) @variable) | ||
|
||
[ | ||
(type_identifier) | ||
(unit_type) | ||
(list) | ||
(list_pattern) | ||
] @type | ||
|
||
((type_identifier) @type.builtin | ||
(#any-of? @type.builtin | ||
"int" "char" "string" "float" "bool" "unit")) | ||
|
||
[ | ||
(variant_identifier) | ||
(polyvar_identifier) | ||
] @constant | ||
] @constructor | ||
|
||
(record_type_field (property_identifier) @property) | ||
(record_field (property_identifier) @property) | ||
(object (field (property_identifier) @property)) | ||
(object_type (field (property_identifier) @property)) | ||
(member_expression (property_identifier) @property) | ||
(module_identifier) @namespace | ||
(module_identifier) @module | ||
|
||
(member_expression (property_identifier) @variable.member) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was |
||
|
||
(value_identifier_path | ||
(module_identifier) | ||
(value_identifier) @variable) | ||
|
||
|
||
(record_pattern | ||
(value_identifier_path | ||
(value_identifier) @variable.member)) | ||
|
||
(record_pattern | ||
(value_identifier) @variable) | ||
|
||
(labeled_argument | ||
label: (value_identifier) @variable.parameter) | ||
|
||
|
||
; Parameters | ||
;---------------- | ||
|
||
(list_pattern (value_identifier) @parameter) | ||
(spread_pattern (value_identifier) @parameter) | ||
(list_pattern (value_identifier) @variable.parameter) | ||
(spread_pattern (value_identifier) @variable.parameter) | ||
|
||
; String literals | ||
;---------------- | ||
|
@@ -40,11 +64,8 @@ | |
(template_string) | ||
] @string | ||
|
||
(template_substitution | ||
"${" @punctuation.bracket | ||
"}" @punctuation.bracket) @embedded | ||
|
||
(character) @string.special | ||
(character) @character | ||
(escape_sequence) @string.escape | ||
|
||
; Other literals | ||
|
@@ -53,68 +74,102 @@ | |
[ | ||
(true) | ||
(false) | ||
] @constant.builtin | ||
] @boolean | ||
|
||
(number) @number | ||
(polyvar) @constant | ||
(polyvar_string) @constant | ||
(polyvar) @constructor | ||
(polyvar_string) @constructor | ||
|
||
; Functions | ||
;---------- | ||
|
||
; parameter(s) in parens | ||
[ | ||
(parameter (value_identifier)) | ||
(labeled_parameter (value_identifier)) | ||
] @parameter | ||
|
||
(parameter (value_identifier) @variable.parameter) | ||
(labeled_parameter (value_identifier) @variable.parameter) | ||
|
||
; single parameter with no parens | ||
(function parameter: (value_identifier) @parameter) | ||
(function parameter: (value_identifier) @variable.parameter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and other similar changes conform to to Neovim's new tags with fallbacks. Meaning, if a certain theme specifies a color for |
||
|
||
; first-level descructuring (required for nvim-tree-sitter as it only matches direct | ||
; children and the above patterns do not match destructuring patterns in NeoVim) | ||
(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @parameter))) | ||
(parameter (array_pattern (value_identifier) @parameter)) | ||
(parameter (record_pattern (value_identifier) @parameter)) | ||
(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @variable.parameter))) | ||
(parameter (array_pattern (value_identifier) @variable.parameter)) | ||
(parameter (record_pattern (value_identifier) @variable.parameter)) | ||
|
||
; function identifier in let binding | ||
(let_binding | ||
pattern: (value_identifier) @function | ||
body: (function)) | ||
|
||
; function calls | ||
|
||
(call_expression | ||
function: (value_identifier_path | ||
_ | ||
(value_identifier) @function.call)) | ||
|
||
(call_expression | ||
function: (value_identifier) @function.call) | ||
|
||
; highlight the right-hand side of a pipe operator as a function call | ||
(pipe_expression | ||
_ | ||
[(value_identifier_path | ||
_ | ||
(value_identifier) @function.call) | ||
(value_identifier) @function.call]) | ||
|
||
|
||
; Meta | ||
;----- | ||
|
||
(decorator_identifier) @annotation | ||
(decorator_identifier) @attribute | ||
|
||
(extension_identifier) @keyword | ||
("%") @keyword | ||
|
||
; Misc | ||
;----- | ||
|
||
(subscript_expression index: (string) @property) | ||
(polyvar_type_pattern "#" @constant) | ||
(polyvar_type_pattern "#" @constructor) | ||
|
||
[ | ||
("include") | ||
("open") | ||
] @include | ||
"include" | ||
"open" | ||
] @keyword.import | ||
|
||
|
||
[ | ||
"private" | ||
"mutable" | ||
"rec" | ||
] @keyword.modifier | ||
|
||
[ | ||
"type" | ||
] @keyword.type | ||
|
||
[ | ||
"and" | ||
"with" | ||
"as" | ||
] @keyword.operator | ||
|
||
[ | ||
"export" | ||
"external" | ||
"let" | ||
"module" | ||
"mutable" | ||
"private" | ||
"rec" | ||
"type" | ||
"and" | ||
"assert" | ||
"await" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind moving this one to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I moved both |
||
"with" | ||
"lazy" | ||
"constraint" | ||
] @keyword | ||
|
||
((function "async" @keyword)) | ||
(("await") @keyword.coroutine) | ||
|
||
((function "async" @keyword.coroutine)) | ||
|
||
(module_unpack "unpack" @keyword) | ||
|
||
|
@@ -123,30 +178,31 @@ | |
"else" | ||
"switch" | ||
"when" | ||
] @conditional | ||
] @keyword.conditional | ||
|
||
[ | ||
"exception" | ||
"try" | ||
"catch" | ||
] @exception | ||
] @keyword.exception | ||
|
||
(call_expression | ||
function: (value_identifier) @exception | ||
(#eq? @exception "raise")) | ||
function: (value_identifier) @keyword.exception | ||
(#eq? @keyword.exception "raise")) | ||
|
||
[ | ||
"for" | ||
"in" | ||
"to" | ||
"downto" | ||
"while" | ||
] @repeat | ||
] @keyword.repeat | ||
|
||
[ | ||
"." | ||
"," | ||
"|" | ||
":" | ||
] @punctuation.delimiter | ||
|
||
[ | ||
|
@@ -174,6 +230,7 @@ | |
"|>" | ||
":>" | ||
"+=" | ||
"=>" | ||
(uncurry) | ||
] @operator | ||
|
||
|
@@ -188,8 +245,16 @@ | |
"}" | ||
"[" | ||
"]" | ||
"<" | ||
">" | ||
] @punctuation.bracket | ||
|
||
(unit ["(" ")"] @constant.builtin) | ||
|
||
(template_substitution | ||
"${" @punctuation.special | ||
"}" @punctuation.special) @none | ||
|
||
(polyvar_type | ||
[ | ||
"[" | ||
|
@@ -201,12 +266,11 @@ | |
[ | ||
"~" | ||
"?" | ||
"=>" | ||
".." | ||
"..." | ||
] @punctuation.special | ||
|
||
(ternary_expression ["?" ":"] @operator) | ||
(ternary_expression ["?" ":"] @keyword.conditional.ternary) | ||
|
||
; JSX | ||
;---------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@name | ||
//<- annotation | ||
//<- attribute | ||
|
||
@@name | ||
//<- annotation | ||
//<- attribute |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
let inc = n => n + 1 | ||
// ^ parameter | ||
// ^ variable.parameter | ||
// ^ punctuation.special | ||
// ^ function | ||
|
||
let fn = (a, (b, c), {d, e}, [f, g]) => a + b + c + d + e + f + g | ||
// ^ parameter | ||
// ^ parameter | ||
// ^ parameter | ||
// ^ parameter | ||
|
||
let uncurry = (. u, .x) => (u, x) | ||
// ^ operator | ||
// ^ operator | ||
// ^ variable.parameter | ||
// ^ variable.parameter | ||
// ^ variable.parameter | ||
// ^ variable.parameter | ||
|
||
let get = async (id) => id | ||
// ^ keyword | ||
// ^ keyword.coroutine |
Uh oh!
There was an error while loading. Please reload this page.