diff options
author | Raphael <glephunter@gmail.com> | 2023-04-16 17:50:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-16 17:50:32 +0800 |
commit | 2f779b94e7fe0fb2fba00dd8e644c60605e83179 (patch) | |
tree | fb5c0da8877b15f1d055ffb275e1e44c6464fb37 /runtime/lua/vim | |
parent | 6ca4fba97f0d8a498fafd949c9db48bf7a870f48 (diff) | |
download | rneovim-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')
-rw-r--r-- | runtime/lua/vim/_inspector.lua | 13 |
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 |