From c102a8311ef61e9ba4b8215cab5209e8b6b2d6b8 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 22 Feb 2024 23:27:40 +0100 Subject: [PATCH] feat: add support for `share` directories --- README.md | 3 ++- flake.nix | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 90f4d63..bab7b3b 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ which takes an attrset with the following arguments: - `nvim`: The neovim package. Defaults to `neovim-unwrapped`. - `neodev-types`: neodev.nvim types to add to the `workspace.library`. Defaults to `"stable"`. -- Plugins: List of Neovim plugins and/or luarocks packages. +- `plugins`: List of Neovim plugins and/or luarocks packages. Defaults to an empty list. +- `lua-version`: Defaults to `"5.1"`. Example: diff --git a/flake.nix b/flake.nix index e91880a..bb92625 100644 --- a/flake.nix +++ b/flake.nix @@ -19,16 +19,19 @@ nvim ? final.neovim-unwrapped, neodev-types ? "stable", plugins ? [], + lua-version ? "5.1", }: let lib = final.lib; - plugin-lib-dirs = lib.lists.map (plugin: - if + partitions = builtins.partition (plugin: builtins.hasAttr "vimPlugin" plugin && plugin.vimPlugin - || plugin.pname == "nvim-treesitter" - then "${plugin}/lua" - else "${plugin}/lib/lua/5.1") - plugins; + || plugin.pname == "nvim-treesitter") + plugins; + plugins = partitions.right; + rocks = partitions.wrong; + plugin-luadirs = builtins.map (plugin: "${plugin}/lua") plugins; + pkg-libdirs = builtins.map (pkg: "${pkg}/lib/lua/${lua-version}") rocks; + pkg-sharedirs = builtins.map (pkg: "${pkg}/share/lua/${lua-version}") rocks; in { runtime.version = "LuaJIT"; Lua = { @@ -43,7 +46,9 @@ "\${3rd}/busted/library" "\${3rd}/luassert/library" ] - ++ plugin-lib-dirs; + ++ plugin-luadirs + ++ pkg-libdirs + ++ pkg-sharedirs; ignoreDir = [ ".git" ".github"