fix(lua): inspect_pos respect bufnr when get syntax info

This commit is contained in:
Raphael
2023-04-15 13:47:24 +08:00
parent c2e47e7bec
commit ee4d1f9c52
2 changed files with 21 additions and 7 deletions

View File

@@ -70,15 +70,18 @@ function vim.inspect_pos(bufnr, row, col, filter)
if filter.treesitter then
for _, capture in pairs(vim.treesitter.get_captures_at_pos(bufnr, row, col)) do
capture.hl_group = '@' .. capture.capture .. '.' .. capture.lang
table.insert(results.treesitter, resolve_hl(capture))
results.treesitter[#results.treesitter + 1] = resolve_hl(capture)
end
end
-- syntax
if filter.syntax then
for _, i1 in ipairs(vim.fn.synstack(row + 1, col + 1)) do
table.insert(results.syntax, resolve_hl({ hl_group = vim.fn.synIDattr(i1, 'name') }))
end
if filter.syntax and vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_call(bufnr, function()
for _, i1 in ipairs(vim.fn.synstack(row + 1, col + 1)) do
results.syntax[#results.syntax + 1] =
resolve_hl({ hl_group = vim.fn.synIDattr(i1, 'name') })
end
end)
end
-- namespace id -> name map