diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-08-19 16:45:04 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-08-19 16:45:04 +0200 |
commit | 2460f0a7028550ea2d87492a4e8b95914fdba7b1 (patch) | |
tree | 43982bcffc13f39906ea08b05fe4e32dbb551b70 | |
parent | d088066fa1d9a4d897890e35b5dd0cfb4e8b365b (diff) | |
download | rneovim-2460f0a7028550ea2d87492a4e8b95914fdba7b1.tar.gz rneovim-2460f0a7028550ea2d87492a4e8b95914fdba7b1.tar.bz2 rneovim-2460f0a7028550ea2d87492a4e8b95914fdba7b1.zip |
perf(treesitter): avoid string lookup of highlight name in hot loop
These numbers are guaranteed to be stable even if you do "highlight
clear" (all attributes disappear, but not the id to name mapping itself)
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index e003cf577a..bf5bd791c3 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -85,8 +85,10 @@ function TSHighlighterQuery.new(lang, query_string) hl = _link_default_highlight_once(lang .. hl, hl) end - rawset(table, capture, hl) - return hl + local id = a.nvim_get_hl_id_by_name(hl) + + rawset(table, capture, id) + return id end }) |