diff options
| author | Fabian David Schmidt <fabian.david.schmidt@gmail.com> | 2021-11-12 16:29:00 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-11-12 20:56:09 +0100 |
| commit | fba03a304e0e8042f8330e1fe7b1ce6764a6fd16 (patch) | |
| tree | f4f40888e6bc664d7e7b6520a6f4e9d52f5e51c8 /lua | |
| parent | Add condition function to module config (diff) | |
| download | nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar.gz nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar.bz2 nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar.lz nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar.xz nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.tar.zst nvim-treesitter-fba03a304e0e8042f8330e1fe7b1ce6764a6fd16.zip | |
feat: get node at cursor of other win
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/ts_utils.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index b17eccc6c..4df84e3ba 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -124,7 +124,13 @@ end function M.get_node_at_cursor(winnr) local cursor = api.nvim_win_get_cursor(winnr or 0) local cursor_range = { cursor[1] - 1, cursor[2] } - local root = M.get_root_for_position(unpack(cursor_range)) + + local buf = vim.api.nvim_win_get_buf(winnr) + local root_lang_tree = parsers.get_parser(buf) + if not root_lang_tree then + return + end + local root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree) if not root then return |
