aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@protonmail.com>2020-08-03 21:40:23 -0500
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-08-09 18:38:00 +0200
commit429036317aa67b097fa4a04b8dda5551266b942e (patch)
tree8542b0f694b3d6970b392644bc62954d8989fc52
parentAdd troubleshooting for when a parser changes (diff)
downloadnvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar.gz
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar.bz2
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar.lz
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar.xz
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.tar.zst
nvim-treesitter-429036317aa67b097fa4a04b8dda5551266b942e.zip
Lua: highlight function name
-rw-r--r--CONTRIBUTING.md1
-rw-r--r--doc/nvim-treesitter.txt4
-rw-r--r--lua/nvim-treesitter/highlight.lua1
-rw-r--r--plugin/nvim-treesitter.vim1
-rw-r--r--queries/lua/highlights.scm17
5 files changed, 17 insertions, 7 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 13497b475..a973d7150 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -124,6 +124,7 @@ are optional and will not have any effect for now.
@label for C/Lua-like labels
@operator
@keyword
+ function
@exception
@include keywords for including modules (e.g. import/from in Python)
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt
index ebe568a1f..7e4f749cf 100644
--- a/doc/nvim-treesitter.txt
+++ b/doc/nvim-treesitter.txt
@@ -388,6 +388,10 @@ For any operator: `+`, but also `->` and `*` in C.
*hl-TSKeyword*
For keywords that don't fall in previous categories.
+`TSKeywordFunction`
+ *hl-TSKeywordFunction*
+For keywords used to define a fuction.
+
`TSException`
*hl-TSException*
For exception related keywords.
diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua
index 6058d52c6..1737d526c 100644
--- a/lua/nvim-treesitter/highlight.lua
+++ b/lua/nvim-treesitter/highlight.lua
@@ -46,6 +46,7 @@ hlmap["repeat"] = "TSRepeat"
hlmap["label"] = "TSLabel"
hlmap["operator"] = "TSOperator"
hlmap["keyword"] = "TSKeyword"
+hlmap["keyword.function"] = "TSKeywordFunction"
hlmap["exception"] = "TSException"
hlmap["type"] = "TSType"
diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim
index 5614cbaff..742af5814 100644
--- a/plugin/nvim-treesitter.vim
+++ b/plugin/nvim-treesitter.vim
@@ -54,6 +54,7 @@ highlight default link TSRepeat Repeat
highlight default link TSLabel Label
highlight default link TSOperator Operator
highlight default link TSKeyword Keyword
+highlight default link TSKeywordFunction Keyword
highlight default link TSException Exception
highlight default link TSType Type
diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm
index 7a69434dd..01bb48ec4 100644
--- a/queries/lua/highlights.scm
+++ b/queries/lua/highlights.scm
@@ -25,11 +25,11 @@
)
[
-"in"
-"local"
-"return"
-(break_statement)
-"goto"
+ "in"
+ "local"
+ "return"
+ (break_statement)
+ "goto"
] @keyword
;; Operators
@@ -77,9 +77,12 @@
(nil) @constant.builtin
(spread) @constant ;; "..."
-;; Nodes
-("function" @function "end" @function) ;; Any node that has both funtion and end in it
+;; Functions
+("function" @keyword.function
+ [(function_name) (identifier)] @function
+ "end" @keyword.function)
+;; Nodes
(table ["{" "}"] @constructor)
(comment) @comment
(string) @string