File tree 2 files changed +28
-14
lines changed
2 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,12 @@ return {
86
86
mid_var = " $" ,
87
87
right_var = ' \\ n");' ,
88
88
},
89
+ [" ps1" ] = {
90
+ left = ' Write-Error "' ,
91
+ right = ' "' ,
92
+ mid_var = " $" ,
93
+ right_var = ' "' ,
94
+ },
89
95
[" python" ] = {
90
96
left = ' print(f"' ,
91
97
right = ' ", file=sys.stderr)' ,
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
- if vim .treesitter .get_node then
5
- -- Supported as of NeoVim 0.9?
6
- return vim .treesitter .get_node ()
7
- else
8
- local function requiref (module )
9
- require (module )
10
- end
11
-
12
- local ts_utils_test = pcall (requiref , " nvim-treesitter.ts_utils" )
13
-
14
- if not ts_utils_test then
15
- return nil
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 ()
16
12
else
17
- local ts_utils = require (" nvim-treesitter.ts_utils" )
18
- return ts_utils .get_node_at_cursor ()
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
19
25
end
26
+ else
27
+ return nil
20
28
end
21
29
end
22
30
You can’t perform that action at this time.
0 commit comments