diff options
| author | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-06-19 15:45:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-19 15:45:28 +0200 |
| commit | 516671fe9f9de98d27024e22c014adc535b56dc7 (patch) | |
| tree | fb9e1984ed56efeedb05e9adbf5041d2ce390516 /lua/nvim-treesitter/ts_utils.lua | |
| parent | 772aa4c169969e56fd3f1208d1d6b42cd799b74a (diff) | |
| parent | cf72524b2f7e3868ea74037004913af6f935f126 (diff) | |
Merge pull request #89 from kyazdani42/refacto/remove-buf-state-and-api
refacto: remove buf state and api
Diffstat (limited to 'lua/nvim-treesitter/ts_utils.lua')
| -rw-r--r-- | lua/nvim-treesitter/ts_utils.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index 1445418e..687a3c53 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -1,6 +1,7 @@ local api = vim.api local locals = require'nvim-treesitter.locals' +local parsers = require'nvim-treesitter.parsers' local M = {} @@ -205,4 +206,10 @@ function M.previous_scope(node) end end +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 + return M |
