diff options
| author | Chris Dragan <chris@dragan.dev> | 2026-01-08 05:53:42 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-07 21:53:42 -0800 |
| commit | 6feaebb4561711cf6b99f2e8b96715a9fc9b496b (patch) | |
| tree | 6197e216ea8db94af8267453ae7f414bdc9dda9a | |
| parent | fix(html_tags): disable spell for tags (#8410) (diff) | |
| download | nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar.gz nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar.bz2 nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar.lz nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar.xz nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.tar.zst nvim-treesitter-6feaebb4561711cf6b99f2e8b96715a9fc9b496b.zip | |
feat(kos): highlights improvements (#8404)
* Mark floats as number.float
* Mark function arguments as variable.parameter
* Mark _ placeholder as character.special
* Mark string interpolation delimiters as punctuation.special
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 2 | ||||
| -rw-r--r-- | runtime/queries/kos/highlights.scm | 17 | ||||
| -rw-r--r-- | tests/query/highlights/kos/test.kos | 40 |
3 files changed, 54 insertions, 5 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index b7037d245..e8af232b6 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1189,7 +1189,7 @@ return { }, kos = { install_info = { - revision = '5f11d41b3150b0837e8b3964151ebb7fc4f367e9', + revision = '03b261c1a78b71c38cf4616497f253c4a4ce118b', url = 'https://github.com/kos-lang/tree-sitter-kos', }, maintainers = { '@cdragan' }, diff --git a/runtime/queries/kos/highlights.scm b/runtime/queries/kos/highlights.scm index 0942b2b89..07757d2e3 100644 --- a/runtime/queries/kos/highlights.scm +++ b/runtime/queries/kos/highlights.scm @@ -4,8 +4,13 @@ (number) @number +(float_number) @number.float + (identifier) @variable +(parameter + parameter: (identifier) @variable.parameter) + (property_identifier) @property [ @@ -57,8 +62,9 @@ "=>" ] @keyword.function +"_" @character.special + [ - "_" (line) "assert" ;"async" @@ -96,6 +102,15 @@ "}" ] @punctuation.bracket +(string_literal_begin + "\\(" @punctuation.special) + +(string_literal_continuation + "\\(" @punctuation.special) + +(formatted_string + ")" @punctuation.special) + [ ";" ":" diff --git a/tests/query/highlights/kos/test.kos b/tests/query/highlights/kos/test.kos index 981fdb313..4e1b0ec6d 100644 --- a/tests/query/highlights/kos/test.kos +++ b/tests/query/highlights/kos/test.kos @@ -21,15 +21,15 @@ fun name(arg1, # ^ keyword.function # ^ function # ^ punctuation.bracket -# ^ variable +# ^ variable.parameter # ^ punctuation.delimiter arg2 = "default", -# ^ variable +# ^ variable.parameter # ^ operator # ^ string # ^ punctuation.delimiter arg3...) -# ^ variable +# ^ variable.parameter # ^ operator # ^ punctuation.bracket { @@ -147,3 +147,37 @@ name.name() # ^ function.method.call # ^ punctuation.bracket # ^ punctuation.bracket + +print("hello \(123 + var) world \(true)") +# <- function.call +# ^ punctuation.bracket +# ^ string +# ^ punctuation.special +# ^ number +# ^ operator +# ^ variable +# ^ punctuation.special +# ^ string +# ^ punctuation.special +# ^ boolean +# ^ punctuation.special +# ^ punctuation.bracket + +[] -> each((x,_,y) => x + y) +# <- punctuation.bracket +#^ punctuation.bracket +# ^ operator +# ^ function.call +# ^ punctuation.bracket +# ^ punctuation.bracket +# ^ variable.parameter +# ^ punctuation.delimiter +# ^ character.special +# ^ punctuation.delimiter +# ^ variable.parameter +# ^ punctuation.bracket +# ^ keyword.function +# ^ variable +# ^ operator +# ^ variable +# ^ punctuation.bracket |
