diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-09-13 15:08:11 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-09-19 07:30:49 +0200 |
| commit | 7e3c4f808940a981a034709163724eb5a7546e2d (patch) | |
| tree | 9ac40da7363fa5a01a24107b7843f36f9fab4a86 | |
| parent | Link to gallery (diff) | |
| download | nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar.gz nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar.bz2 nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar.lz nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar.xz nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.tar.zst nvim-treesitter-7e3c4f808940a981a034709163724eb5a7546e2d.zip | |
Add @keyword.operator for operators that are English words and add @exception for Java/JS
| -rw-r--r-- | CONTRIBUTING.md | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/highlight.lua | 3 | ||||
| -rw-r--r-- | plugin/nvim-treesitter.vim | 1 | ||||
| -rw-r--r-- | queries/cpp/highlights.scm | 22 | ||||
| -rw-r--r-- | queries/java/highlights.scm | 20 | ||||
| -rw-r--r-- | queries/javascript/highlights.scm | 18 | ||||
| -rw-r--r-- | queries/lua/highlights.scm | 10 | ||||
| -rw-r--r-- | queries/python/highlights.scm | 11 | ||||
| -rw-r--r-- | queries/ruby/highlights.scm | 9 | ||||
| -rw-r--r-- | queries/rust/highlights.scm | 5 |
10 files changed, 75 insertions, 27 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 63613cbf2..b0949fa99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,9 +131,10 @@ are optional and will not have any effect for now. @conditional @repeat @label for C/Lua-like labels -@operator @keyword @keyword.function +@keyword.operator (for operators that are English words, e.g. `and`, `or`) +@operator (for symbolic operators, e.g. `+`, `*`) @exception @include keywords for including modules (e.g. import/from in Python) diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua index 3ccd3fdda..4dde5a8c1 100644 --- a/lua/nvim-treesitter/highlight.lua +++ b/lua/nvim-treesitter/highlight.lua @@ -46,9 +46,10 @@ hlmap["constructor"] = "TSConstructor" hlmap["conditional"] = "TSConditional" hlmap["repeat"] = "TSRepeat" hlmap["label"] = "TSLabel" -hlmap["operator"] = "TSOperator" hlmap["keyword"] = "TSKeyword" hlmap["keyword.function"] = "TSKeywordFunction" +hlmap["keyword.operator"] = "TSKeywordOperator" +hlmap["operator"] = "TSOperator" hlmap["exception"] = "TSException" hlmap["type"] = "TSType" diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index c4136ea82..e103b8766 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -48,6 +48,7 @@ highlight default link TSLabel Label highlight default link TSOperator Operator highlight default link TSKeyword Keyword highlight default link TSKeywordFunction Keyword +highlight default link TSKeywordOperator TSOperator highlight default link TSException Exception highlight default link TSType Type diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index 15bc3ac72..c026d54bf 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -101,13 +101,11 @@ "class" "decltype" "constexpr" - "delete" "explicit" "final" "friend" "mutable" "namespace" - "new" "override" "private" "protected" @@ -119,6 +117,26 @@ (auto) ] @keyword +[ + "new" + "delete" + + ;; these keywords are not supported by the parser + ;"eq" + ;"not_eq" + ; + ;"compl" + ;"and" + ;"or" + ; + ;"bitand" + ;"bitand_eq" + ;"bitor" + ;"bitor_eq" + ;"xor" + ;"xor_eq" +] @keyword.operator + "::" @operator "..." @operator diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 70cbb28a7..f8ce34c8b 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -141,7 +141,6 @@ "abstract" "assert" "break" -"catch" "class" "continue" "default" @@ -149,13 +148,11 @@ "exports" "extends" "final" -"finally" "implements" "instanceof" "interface" "module" "native" -"new" "open" "opens" "package" @@ -168,17 +165,18 @@ "static" "strictfp" "synchronized" -"throw" -"throws" "to" "transient" "transitive" -"try" "uses" "volatile" "with" ] @keyword +[ + "new" +] @keyword.operator + ; Conditionals [ @@ -218,6 +216,16 @@ ")" ] @punctuation.bracket +; Exceptions + +[ +"throw" +"throws" +"finally" +"try" +"catch" +] @exception + ; Labels (labeled_statement (identifier) @label) diff --git a/queries/javascript/highlights.scm b/queries/javascript/highlights.scm index 627c4b2d1..d83228c37 100644 --- a/queries/javascript/highlights.scm +++ b/queries/javascript/highlights.scm @@ -184,30 +184,36 @@ "async" "await" "break" -"catch" "class" "const" "debugger" -"delete" "export" "extends" -"finally" "function" "get" "in" "instanceof" "let" -"new" "return" "set" "static" "switch" "target" -"throw" -"try" "typeof" "var" "void" "with" "yield" ] @keyword + +[ + "new" + "delete" +] @keyword.operator + +[ + "throw" + "try" + "catch" + "finally" +] @exception diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index b66d33c45..305a9790f 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -51,15 +51,19 @@ ] @keyword ;; Operators + +[ + "not" + "and" + "or" +] @keyword.operator + [ "=" "~=" "==" "<=" ">=" -"not" -"and" -"or" "<" ">" "+" diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index 30420af12..b0cae4cfc 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -157,15 +157,19 @@ "|" "|=" "~" + "->" +] @operator + +; Keywords +[ "and" "in" "is" "not" "or" - "->" -] @operator -; Keywords + "del" +] @keyword.operator [ "assert" @@ -173,7 +177,6 @@ "await" "class" "def" - "del" "except" "exec" "finally" diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm index 20b0a0ef2..a1f1913b5 100644 --- a/queries/ruby/highlights.scm +++ b/queries/ruby/highlights.scm @@ -5,7 +5,6 @@ [ "alias" - "and" "begin" "break" "class" @@ -13,10 +12,8 @@ "do" "end" "ensure" - "in" "module" "next" - "or" "rescue" "retry" "return" @@ -25,6 +22,12 @@ ] @keyword [ + "and" + "or" + "in" +] @keyword.operator + +[ "case" "else" "elsif" diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index b31acdcd0..01994555f 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -163,7 +163,10 @@ (escape_sequence) @string.escape [ -"as" + "as" +] @keyword.operator + +[ "*" "'" "->" |
