summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2026-02-09 07:45:43 +0100
committerSören Tempel <soeren+git@soeren-tempel.net>2026-04-12 14:41:00 +0200
commit1045f12f00dff46ab320bdd89e76456dc9eae1cf (patch)
tree9984f693bf273bf252f85731f2483e023a2bef06 /gnu
parentc41e1bffa1c4c406de775688a287007fd1351fd8 (diff)
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.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/patches/neovim-tree-sitter-grammar-path.patch33
-rw-r--r--gnu/packages/vim.scm16
3 files changed, 49 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 5bc8413d2a..fae467e500 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -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 \
diff --git a/gnu/packages/patches/neovim-tree-sitter-grammar-path.patch b/gnu/packages/patches/neovim-tree-sitter-grammar-path.patch
new file mode 100644
index 0000000000..30d76ad36f
--- /dev/null
+++ b/gnu/packages/patches/neovim-tree-sitter-grammar-path.patch
@@ -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)
diff --git a/gnu/packages/vim.scm b/gnu/packages/vim.scm
index c37131cb7a..08bc2d9c04 100644
--- a/gnu/packages/vim.scm
+++ b/gnu/packages/vim.scm
@@ -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