diff options
| author | Sören Tempel <soeren+git@soeren-tempel.net> | 2026-02-09 07:45:43 +0100 |
|---|---|---|
| committer | Sören Tempel <soeren+git@soeren-tempel.net> | 2026-04-12 14:41:00 +0200 |
| commit | 1045f12f00dff46ab320bdd89e76456dc9eae1cf (patch) | |
| tree | 9984f693bf273bf252f85731f2483e023a2bef06 /gnu/packages | |
| parent | c41e1bffa1c4c406de775688a287007fd1351fd8 (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/packages')
| -rw-r--r-- | gnu/packages/patches/neovim-tree-sitter-grammar-path.patch | 33 | ||||
| -rw-r--r-- | gnu/packages/vim.scm | 16 |
2 files changed, 48 insertions, 1 deletions
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 00000000000..30d76ad36f4 --- /dev/null +++ b/gnu/packages/patches/neovim-tree-sitter-grammar-path.patch | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | This patch makes neovim look for tree-sitter parsers in the directories | ||
| 2 | specified by TREE_SITTER_GRAMMAR_PATH. Thereby, making it compatible | ||
| 3 | with the tree-sitter setup used by other Guix packages. e.g. emacs. | ||
| 4 | |||
| 5 | diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua | ||
| 6 | index f70f99421c..480e7bb77a 100644 | ||
| 7 | --- a/runtime/lua/vim/treesitter/language.lua | ||
| 8 | +++ b/runtime/lua/vim/treesitter/language.lua | ||
| 9 | @@ -126,12 +126,19 @@ function M.add(lang, opts) | ||
| 10 | return nil, string.format('Invalid language name "%s"', lang) | ||
| 11 | end | ||
| 12 | |||
| 13 | - local fname = 'parser/' .. lang .. '.*' | ||
| 14 | - local paths = api.nvim_get_runtime_file(fname, false) | ||
| 15 | - if #paths == 0 then | ||
| 16 | - return nil, string.format('No parser for language "%s"', lang) | ||
| 17 | + local paths = vim.split(os.getenv('TREE_SITTER_GRAMMAR_PATH') or '', ':') | ||
| 18 | + for _, elem in ipairs(paths) do | ||
| 19 | + local fname = elem .. '/' .. 'libtree-sitter-' .. lang .. '*' | ||
| 20 | + local paths = vim.fn.glob(fname, false, true) | ||
| 21 | + if #paths > 0 then | ||
| 22 | + path = paths[1] | ||
| 23 | + break | ||
| 24 | + end | ||
| 25 | end | ||
| 26 | - path = paths[1] | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | + if path == nil then | ||
| 30 | + return nil, string.format('No parser for language "%s"', lang) | ||
| 31 | end | ||
| 32 | |||
| 33 | local res = loadparser(path, lang, symbol_name) | ||
diff --git a/gnu/packages/vim.scm b/gnu/packages/vim.scm index c37131cb7a3..08bc2d9c043 100644 --- a/gnu/packages/vim.scm +++ b/gnu/packages/vim.scm | |||
| @@ -801,7 +801,8 @@ is based on Vim's builtin plugin support.") | |||
| 801 | (file-name (git-file-name name version)) | 801 | (file-name (git-file-name name version)) |
| 802 | (sha256 | 802 | (sha256 |
| 803 | (base32 | 803 | (base32 |
| 804 | "1b524vi44gkcsyy8w4jggvprwdsgy0gjprgxpyhh0dmqm47c0c48")))) | 804 | "1b524vi44gkcsyy8w4jggvprwdsgy0gjprgxpyhh0dmqm47c0c48")) |
| 805 | (patches (search-patches "neovim-tree-sitter-grammar-path.patch")))) | ||
| 805 | (build-system cmake-build-system) | 806 | (build-system cmake-build-system) |
| 806 | (arguments | 807 | (arguments |
| 807 | (list #:tests? #f | 808 | (list #:tests? #f |
| @@ -852,6 +853,19 @@ is based on Vim's builtin plugin support.") | |||
| 852 | lua5.1-libmpack | 853 | lua5.1-libmpack |
| 853 | tree-sitter)) | 854 | tree-sitter)) |
| 854 | (native-inputs (list pkg-config gettext-minimal gperf)) | 855 | (native-inputs (list pkg-config gettext-minimal gperf)) |
| 856 | (propagated-inputs | ||
| 857 | ;; bundled tree-sitters, neovim assumes that these are available. | ||
| 858 | ;; See https://neovim.io/doc/user/treesitter.html#treesitter-parsers | ||
| 859 | (list tree-sitter-c | ||
| 860 | tree-sitter-lua | ||
| 861 | tree-sitter-markdown | ||
| 862 | tree-sitter-vim | ||
| 863 | tree-sitter-vimdoc | ||
| 864 | tree-sitter-query)) | ||
| 865 | (native-search-paths | ||
| 866 | (list (search-path-specification | ||
| 867 | (variable "TREE_SITTER_GRAMMAR_PATH") | ||
| 868 | (files '("lib/tree-sitter"))))) | ||
| 855 | (home-page "https://neovim.io") | 869 | (home-page "https://neovim.io") |
| 856 | (synopsis "Fork of vim focused on extensibility and agility") | 870 | (synopsis "Fork of vim focused on extensibility and agility") |
| 857 | (description | 871 | (description |
