aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/highlight_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-03-13 14:40:41 +0000
committerLewis Russell <me@lewisr.dev>2024-03-14 06:55:19 +0000
commit12faaf40f487132b9397d9f3e59e44840985612c (patch)
tree1664c8253ce7fe8d9b3f66f569392d6c2f30cfdb /test/functional/treesitter/highlight_spec.lua
parent274e414c94a74c7f90952327f69a8a1d65e9f00a (diff)
downloadrneovim-12faaf40f487132b9397d9f3e59e44840985612c.tar.gz
rneovim-12faaf40f487132b9397d9f3e59e44840985612c.tar.bz2
rneovim-12faaf40f487132b9397d9f3e59e44840985612c.zip
fix(treesitter): highlight injections properly
`on_line_impl` doesn't highlight single lines, so using pattern indexes to offset priority doesn't work.
Diffstat (limited to 'test/functional/treesitter/highlight_spec.lua')
-rw-r--r--test/functional/treesitter/highlight_spec.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 7f2b5751ae..8b405615e0 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -867,6 +867,40 @@ describe('treesitter highlighting (help)', function()
]],
}
end)
+
+ it('correctly redraws injections subpriorities', function()
+ -- The top level string node will be highlighted first
+ -- with an extmark spanning multiple lines.
+ -- When the next line is drawn, which includes an injection,
+ -- make sure the highlight appears above the base tree highlight
+
+ insert([=[
+ local s = [[
+ local also = lua
+ ]]
+ ]=])
+
+ exec_lua [[
+ parser = vim.treesitter.get_parser(0, "lua", {
+ injections = {
+ lua = '(string content: (_) @injection.content (#set! injection.language lua))'
+ }
+ })
+
+ vim.treesitter.highlighter.new(parser)
+ ]]
+
+ screen:expect {
+ grid = [=[
+ {3:local} {4:s} {3:=} {5:[[} |
+ {5: }{3:local}{5: }{4:also}{5: }{3:=}{5: }{4:lua} |
+ {5:]]} |
+ ^ |
+ {2:~ }|
+ |
+ ]=],
+ }
+ end)
end)
describe('treesitter highlighting (nested injections)', function()