forked from tribes/guix
1045f12f00
While at it, also depend on tree-sitters that are builtin into neovim. Fixes #2269 * packages/patches/neovim-tree-sitter-grammar-path.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/vim.scm (neovim): Support TREE_SITTER_GRAMMAR_PATH. [source] <patches>: Add patch. [native-search-paths]: Add TREE_SITTER_GRAMMAR_PATH. [propagated-inputs]: Add strictly required tree-sitter parsers.
34 lines
1.2 KiB
Diff
34 lines
1.2 KiB
Diff
This patch makes neovim look for tree-sitter parsers in the directories
|
|
specified by TREE_SITTER_GRAMMAR_PATH. Thereby, making it compatible
|
|
with the tree-sitter setup used by other Guix packages. e.g. emacs.
|
|
|
|
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
|
|
index f70f99421c..480e7bb77a 100644
|
|
--- a/runtime/lua/vim/treesitter/language.lua
|
|
+++ b/runtime/lua/vim/treesitter/language.lua
|
|
@@ -126,12 +126,19 @@ function M.add(lang, opts)
|
|
return nil, string.format('Invalid language name "%s"', lang)
|
|
end
|
|
|
|
- local fname = 'parser/' .. lang .. '.*'
|
|
- local paths = api.nvim_get_runtime_file(fname, false)
|
|
- if #paths == 0 then
|
|
- return nil, string.format('No parser for language "%s"', lang)
|
|
+ local paths = vim.split(os.getenv('TREE_SITTER_GRAMMAR_PATH') or '', ':')
|
|
+ for _, elem in ipairs(paths) do
|
|
+ local fname = elem .. '/' .. 'libtree-sitter-' .. lang .. '*'
|
|
+ local paths = vim.fn.glob(fname, false, true)
|
|
+ if #paths > 0 then
|
|
+ path = paths[1]
|
|
+ break
|
|
+ end
|
|
end
|
|
- path = paths[1]
|
|
+ end
|
|
+
|
|
+ if path == nil then
|
|
+ return nil, string.format('No parser for language "%s"', lang)
|
|
end
|
|
|
|
local res = loadparser(path, lang, symbol_name)
|