mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-13 16:40:40 +02:00
gnu: neovim: honor TREE_SITTER_GRAMMAR_PATH.
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.
This commit is contained in:
@@ -1978,6 +1978,7 @@ dist_patch_DATA = \
|
||||
%D%/packages/patches/nheko-0-12-1-fix-rendering-replies.patch \
|
||||
%D%/packages/patches/nix-dont-build-html-doc.diff \
|
||||
%D%/packages/patches/nfs4-acl-tools-0.3.7-fixpaths.patch \
|
||||
%D%/packages/patches/neovim-tree-sitter-grammar-path.patch \
|
||||
%D%/packages/patches/network-manager-plugin-ownership.patch \
|
||||
%D%/packages/patches/network-manager-plugin-path.patch \
|
||||
%D%/packages/patches/newlib-getentropy.patch \
|
||||
|
||||
33
gnu/packages/patches/neovim-tree-sitter-grammar-path.patch
Normal file
33
gnu/packages/patches/neovim-tree-sitter-grammar-path.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
@@ -801,7 +801,8 @@ is based on Vim's builtin plugin support.")
|
||||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32
|
||||
"1b524vi44gkcsyy8w4jggvprwdsgy0gjprgxpyhh0dmqm47c0c48"))))
|
||||
"1b524vi44gkcsyy8w4jggvprwdsgy0gjprgxpyhh0dmqm47c0c48"))
|
||||
(patches (search-patches "neovim-tree-sitter-grammar-path.patch"))))
|
||||
(build-system cmake-build-system)
|
||||
(arguments
|
||||
(list #:tests? #f
|
||||
@@ -852,6 +853,19 @@ is based on Vim's builtin plugin support.")
|
||||
lua5.1-libmpack
|
||||
tree-sitter))
|
||||
(native-inputs (list pkg-config gettext-minimal gperf))
|
||||
(propagated-inputs
|
||||
;; bundled tree-sitters, neovim assumes that these are available.
|
||||
;; See https://neovim.io/doc/user/treesitter.html#treesitter-parsers
|
||||
(list tree-sitter-c
|
||||
tree-sitter-lua
|
||||
tree-sitter-markdown
|
||||
tree-sitter-vim
|
||||
tree-sitter-vimdoc
|
||||
tree-sitter-query))
|
||||
(native-search-paths
|
||||
(list (search-path-specification
|
||||
(variable "TREE_SITTER_GRAMMAR_PATH")
|
||||
(files '("lib/tree-sitter")))))
|
||||
(home-page "https://neovim.io")
|
||||
(synopsis "Fork of vim focused on extensibility and agility")
|
||||
(description
|
||||
|
||||
Reference in New Issue
Block a user