From f489d98653845f0e7501434f8873bad6feccf19c Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Thu, 10 Jun 2021 21:34:45 +0200 Subject: [PATCH 1/2] fix(treesitter): do not map hl_group when no mapping is set This changes the behavior of the hl_cache to the old one. - when the capture exists as a hlgroup -> use it - when hl_map contains a mapping -> use it - else do nothing (before: map capture to non-existing capture) Before also captures `@foo.bar` would intend to use the hlgroup `foo.bar` which results in a confusing error since hlgroups can't contain dots. --- runtime/lua/vim/treesitter/highlighter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index cf3cdf4505..45eb941db7 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -116,7 +116,7 @@ function TSHighlighterQuery:_get_hl_from_capture(capture) -- From "Normal.left" only keep "Normal" return vim.split(name, '.', true)[1], true else - return TSHighlighter.hl_map[name] or name, false + return TSHighlighter.hl_map[name] or 0, false end end From 912152d6358e8043adf9bb064479c7dfa3ce885e Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Fri, 11 Jun 2021 00:12:39 +0200 Subject: [PATCH 2/2] chore: remove reference to nvim-treesitter in comment --- runtime/lua/vim/treesitter/highlighter.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 45eb941db7..e003cf577a 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -22,8 +22,6 @@ local _link_default_highlight_once = function(from, to) return from end --- These are conventions defined by nvim-treesitter, though it --- needs to be user extensible also. TSHighlighter.hl_map = { ["error"] = "Error",