mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
fix(treesitter): highlight injections properly
`on_line_impl` doesn't highlight single lines, so using pattern indexes to offset priority doesn't work.
This commit is contained in:

committed by
Lewis Russell

parent
274e414c94
commit
12faaf40f4
@@ -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()
|
||||
|
Reference in New Issue
Block a user