aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_inspector.lua
diff options
context:
space:
mode:
authorRaphael <glephunter@gmail.com>2023-04-16 17:50:32 +0800
committerGitHub <noreply@github.com>2023-04-16 17:50:32 +0800
commit2f779b94e7fe0fb2fba00dd8e644c60605e83179 (patch)
treefb5c0da8877b15f1d055ffb275e1e44c6464fb37 /runtime/lua/vim/_inspector.lua
parent6ca4fba97f0d8a498fafd949c9db48bf7a870f48 (diff)
downloadrneovim-2f779b94e7fe0fb2fba00dd8e644c60605e83179.tar.gz
rneovim-2f779b94e7fe0fb2fba00dd8e644c60605e83179.tar.bz2
rneovim-2f779b94e7fe0fb2fba00dd8e644c60605e83179.zip
fix(lua): inspect_pos respect bufnr when get syntax info (#23098)
Diffstat (limited to 'runtime/lua/vim/_inspector.lua')
-rw-r--r--runtime/lua/vim/_inspector.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/runtime/lua/vim/_inspector.lua b/runtime/lua/vim/_inspector.lua
index 05983d3f0d..2ebb7a7efd 100644
--- a/runtime/lua/vim/_inspector.lua
+++ b/runtime/lua/vim/_inspector.lua
@@ -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