summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkiyan42 <yazdani.kiyan@protonmail.com>2020-06-19 14:13:23 +0200
committerkiyan42 <yazdani.kiyan@protonmail.com>2020-06-19 14:13:23 +0200
commitcf72524b2f7e3868ea74037004913af6f935f126 (patch)
treefb9e1984ed56efeedb05e9adbf5041d2ce390516
parentcabe61ac19a2d0377a46ef48499eb292e12ae5fb (diff)
add winnr to get_node_at_cursor
-rw-r--r--README.md2
-rw-r--r--doc/nvim-treesitter.txt3
-rw-r--r--lua/nvim-treesitter/ts_utils.lua4
3 files changed, 5 insertions, 4 deletions
diff --git a/README.md b/README.md
index b2193103..787a2a20 100644
--- a/README.md
+++ b/README.md
@@ -137,7 +137,7 @@ you can get some utility functions with
```lua
local ts_utils = require 'nvim-treesitter.ts_utils'
```
-More information is available in neovim documentation (`:help nvim-treesitter-utils`).
+More information is available in the help file (`:help nvim-treesitter-utils`).
## Supported Languages
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt
index 27e4f0bb..bb53e182 100644
--- a/doc/nvim-treesitter.txt
+++ b/doc/nvim-treesitter.txt
@@ -99,7 +99,8 @@ Nvim treesitter has some wrapper functions that you can retrieve with:
<
Methods
-get_node_at_cursor() *ts_utils.get_node_at_cursor*
+get_node_at_cursor(winnr) *ts_utils.get_node_at_cursor*
+ winnr will be 0 if nil
returns the node under the cursor
get_node_text(node, bufnr) *ts_utils.get_node_text*
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua
index a85934c0..687a3c53 100644
--- a/lua/nvim-treesitter/ts_utils.lua
+++ b/lua/nvim-treesitter/ts_utils.lua
@@ -206,8 +206,8 @@ function M.previous_scope(node)
end
end
-function M.get_node_at_cursor()
- local cursor = api.nvim_win_get_cursor(0)
+function M.get_node_at_cursor(winnr)
+ local cursor = api.nvim_win_get_cursor(winnr or 0)
local root = parsers.get_parser().tree:root()
return root:named_descendant_for_range(cursor[1]-1,cursor[2],cursor[1]-1,cursor[2])
end