File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ function M.check()
1010end
1111
1212function 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 ()
1415 if not version_info .installed then
1516 return h .error (' Treesitter grammar is not installed. Run `:Org install_treesitter_grammar` to install it.' )
1617 end
@@ -26,6 +27,18 @@ function M.check_has_treesitter()
2627 )
2728 )
2829 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
2942 return h .ok ((' Treesitter grammar installed (version %s)' ):format (version_info .installed_version ))
3043end
3144
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ function M.get_lock_file()
8080 return vim .fs .joinpath (M .get_package_path (), ' .org-ts-lock.json' )
8181end
8282
83+ function M .get_parser_path ()
84+ return vim .fs .joinpath (M .get_package_path (), ' parser' , ' org.so' )
85+ end
86+
8387function M .select_compiler_args (compiler )
8488 if string.match (compiler , ' cl$' ) or string.match (compiler , ' cl.exe$' ) then
8589 return {
@@ -177,7 +181,6 @@ function M.run(type)
177181 end
178182
179183 local compiler_args = M .select_compiler_args (compiler )
180- local package_path = M .get_package_path ()
181184 local path = nil
182185
183186 return M .get_path (url , type )
@@ -193,7 +196,7 @@ function M.run(type)
193196 error (' [orgmode] Failed to compile parser' , 0 )
194197 end
195198 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 ( )
197200 local renamed = vim .fn .rename (source , destination )
198201 if renamed ~= 0 then
199202 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