diff options
author | Mango The Fourth <40720523+MangoIV@users.noreply.github.com> | 2024-06-30 19:17:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-30 19:17:04 +0200 |
commit | 51e69413cfc928d02e19c27c9342af2931166d4d (patch) | |
tree | a139e696433eee56c2b5623b6e5af71bd57bc585 /pkgs/applications/editors | |
parent | 19581e2ce8bc43f898ef724f8072ebf62bebb325 (diff) |
neovimUtils.grammarToPlugin: also move the queries (#321550)
This installs queries from source into the neovim expected folder. Some grammar queries are already in a folder like expected by neovim but others (notably the treesitter official ones) are not so the code deals with both. For instance the koka grammar puts its queries directly in "queries" folder https://github.com/mtoohey31/tree-sitter-koka/tree/main/queries but some others puts it in a folder expected by neovim like https://github.com/tjdevries/tree-sitter-lua/tree/master/queries/lua .
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r-- | pkgs/applications/editors/neovim/utils.nix | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 8f9a5b880032c..438c9904829c6 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -7,7 +7,6 @@ , ruby , lua , python3Packages -, writeText , wrapNeovimUnstable , runCommand }: @@ -78,7 +77,7 @@ let ++ (extraPython3Packages ps) ++ (lib.concatMap (f: f ps) pluginPython3Packages)); - luaEnv = neovim-unwrapped.lua.withPackages(extraLuaPackages); + luaEnv = neovim-unwrapped.lua.withPackages extraLuaPackages; # as expected by packdir packpathDirs.myNeovimPackages = myVimPackage; @@ -101,13 +100,13 @@ let "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv) ]; - manifestRc = vimUtils.vimrcContent ({ customRC = ""; }) ; + manifestRc = vimUtils.vimrcContent { customRC = ""; }; # we call vimrcContent without 'packages' to avoid the init.vim generation - neovimRcContent = vimUtils.vimrcContent ({ + neovimRcContent = vimUtils.vimrcContent { beforePlugins = ""; customRC = lib.concatStringsSep "\n" (pluginRC ++ [customRC]); packages = null; - }); + }; in builtins.removeAttrs args ["plugins"] // { @@ -225,8 +224,25 @@ let } // grammar.meta; } '' - mkdir -p $out/parser - ln -s ${grammar}/parser $out/parser/${name}.so + mkdir -p "$out/parser" + ln -s "${grammar}/parser" "$out/parser/${name}.so" + + mkdir -p "$out/queries/${name}" + if [ -d "${grammar}/queries/${name}" ]; then + echo "moving queries from neovim queries dir" + for file in "${grammar}/queries/${name}"*; do + ln -s "$file" "$out/queries/${name}/$(basename "$file")" + done + else + if [ -d "${grammar}/queries" ]; then + echo "moving queries from standard queries dir" + for file in "${grammar}/queries/"*; do + ln -s "$file" "$out/queries/${name}/$(basename "$file")" + done + else + echo "missing queries for ${name}" + fi + fi ''); in |