File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ function M.check()
10
10
end
11
11
12
12
function M .check_has_treesitter ()
13
- local version_info = require (' orgmode.utils.treesitter.install' ).get_version_info ()
13
+ local ts = require (' orgmode.utils.treesitter.install' )
14
+ local version_info = ts .get_version_info ()
14
15
if not version_info .installed then
15
16
return h .error (' Treesitter grammar is not installed. Run `:Org install_treesitter_grammar` to install it.' )
16
17
end
@@ -26,6 +27,18 @@ function M.check_has_treesitter()
26
27
)
27
28
)
28
29
end
30
+ local installed_org_parsers = vim .api .nvim_get_runtime_file (' parser/org.so' , true )
31
+ local parser_path = ts .get_parser_path ()
32
+ local extra_unexpected_parsers = vim .tbl_filter (function (parser )
33
+ return parser ~= parser_path
34
+ end , installed_org_parsers )
35
+ if # extra_unexpected_parsers > 0 then
36
+ return h .error (
37
+ (' There are conflicting org parser(s) installed in these locations: \n %s\n Remove them to avoid conflicts.' ):format (
38
+ table.concat (extra_unexpected_parsers , ' \n ' )
39
+ )
40
+ )
41
+ end
29
42
return h .ok ((' Treesitter grammar installed (version %s)' ):format (version_info .installed_version ))
30
43
end
31
44
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ function M.get_lock_file()
80
80
return vim .fs .joinpath (M .get_package_path (), ' .org-ts-lock.json' )
81
81
end
82
82
83
+ function M .get_parser_path ()
84
+ return vim .fs .joinpath (M .get_package_path (), ' parser' , ' org.so' )
85
+ end
86
+
83
87
function M .select_compiler_args (compiler )
84
88
if string.match (compiler , ' cl$' ) or string.match (compiler , ' cl.exe$' ) then
85
89
return {
@@ -177,7 +181,6 @@ function M.run(type)
177
181
end
178
182
179
183
local compiler_args = M .select_compiler_args (compiler )
180
- local package_path = M .get_package_path ()
181
184
local path = nil
182
185
183
186
return M .get_path (url , type )
@@ -193,7 +196,7 @@ function M.run(type)
193
196
error (' [orgmode] Failed to compile parser' , 0 )
194
197
end
195
198
local source = vim .fs .joinpath (path , ' parser.so' )
196
- local destination = vim . fs . joinpath ( package_path , ' parser ' , ' org.so ' )
199
+ local destination = M . get_parser_path ( )
197
200
local renamed = vim .fn .rename (source , destination )
198
201
if renamed ~= 0 then
199
202
error (' [orgmode] Failed to move generated tree-sitter parser to runtime folder' , 0 )
You can’t perform that action at this time.
0 commit comments