diff options
author | Jongwook Choi <wookayin@gmail.com> | 2023-12-04 04:00:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 10:00:49 +0100 |
commit | cf612c64b0fc87c399bc5c72735335c5e73d6de1 (patch) | |
tree | 8bfd68e4dac5145cce42126f572ecc7ac9d85c50 /test/functional/treesitter/node_spec.lua | |
parent | 589f4761ee896cea5c8d1b1dad6655bd0b78fc2d (diff) | |
download | rneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.tar.gz rneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.tar.bz2 rneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.zip |
fix(treesitter): allow passing lang to vim.treesitter.get_node() now correctly takes opts.lang (#26360)
PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in
the option table. This option was used in somewhere else, for instance,
`vim.treesitter.dev` (for `inspect_tree`) but was never implemented.
SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a
treesitter parser.
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r-- | test/functional/treesitter/node_spec.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index eef75d0e91..16ead69649 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -40,6 +40,20 @@ describe('treesitter node API', function() assert_alive() end) + it('get_node() with lang given', function() + -- this buffer doesn't have filetype set! + insert('local foo = function() end') + exec_lua([[ + node = vim.treesitter.get_node({ + bufnr = 0, + pos = { 0, 6 }, -- on "foo" + lang = 'lua', + }) + ]]) + eq('foo', lua_eval('vim.treesitter.query.get_node_text(node, 0)')) + eq('identifier', lua_eval('node:type()')) + end) + it('can move between siblings', function() insert([[ int main(int x, int y, int z) { |