File tree 1 file changed +20
-21
lines changed
1 file changed +20
-21
lines changed Original file line number Diff line number Diff line change 1
1
local M = {}
2
2
3
3
local get_node_at_cursor = function ()
4
- local success , is_node = pcall (vim .treesitter .get_node )
5
-
6
- -- This will fail if this language is not supported by Treesitter, e.g.
7
- -- Powershell/ps1
8
- if success then
9
- if is_node then
10
- -- Supported as of NeoVim 0.9?
11
- return vim .treesitter .get_node ()
4
+ if vim .fn .has (" nvim-0.9.0" ) == 1 then
5
+ local success , is_node = pcall (vim .treesitter .get_node )
6
+
7
+ -- This will fail if this language is not supported by Treesitter, e.g.
8
+ -- Powershell/ps1
9
+ if success and is_node then
10
+ return is_node
12
11
else
13
- local function requiref (module )
14
- require (module )
15
- end
16
-
17
- local ts_utils_test = pcall (requiref , " nvim-treesitter.ts_utils" )
18
-
19
- if not ts_utils_test then
20
- return nil
21
- else
22
- local ts_utils = require (" nvim-treesitter.ts_utils" )
23
- return ts_utils .get_node_at_cursor ()
24
- end
12
+ return nil
25
13
end
26
14
else
27
- return nil
15
+ local function requiref (module )
16
+ require (module )
17
+ end
18
+
19
+ local ts_utils_test = pcall (requiref , " nvim-treesitter.ts_utils" )
20
+
21
+ if not ts_utils_test then
22
+ return nil
23
+ else
24
+ local ts_utils = require (" nvim-treesitter.ts_utils" )
25
+ return ts_utils .get_node_at_cursor ()
26
+ end
28
27
end
29
28
end
30
29
You can’t perform that action at this time.
0 commit comments