diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 26e567f..09df20a 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -140,3 +140,8 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = and [`vim.spellChecking.programmingWordlist.enable`](vim.spellChecking.programmingWordlist.enable) for ignoring certain filetypes in spellchecking and enabling `vim-dirtytalk` respectively. The previously used `vim.spellcheck.vim-dirtytalk` aliases to the latter option. + +- Exposed `withRuby`, `withNodeJs`, `withPython3`, and `python3Packages` from the `makeNeovimConfig` function under their respective options. + +- Added [`vim.extraPackages`](vim.extraPackages) for appending additional packages to the wrapper PATH, making said packages available + while inside the Neovim session. diff --git a/modules/default.nix b/modules/default.nix index f840334..aaedd42 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,7 +10,8 @@ inputs: { inherit (pkgs) wrapNeovimUnstable vimPlugins; inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.neovimUtils) makeNeovimConfig; - inherit (lib.lists) concatLists; + inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep; + inherit (lib.lists) concatLists optional; inherit (lib.attrsets) recursiveUpdate; inherit (lib.asserts) assertMsg; @@ -82,11 +83,19 @@ inputs: { plugins = builtStartPlugins ++ builtOptPlugins; + # additional Lua and Python3 packages, mapped to their respective functions + # to conform to the format makeNeovimConfig expects. end user should + # only ever need to pass a list of packages, which are modified + # here extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; - # wrap user's desired neovim package using the neovim wrapper from nixpkgs - # the wrapper takes the following arguments: + extraWrapperArgs = + concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); + + # wrap user's desired neovim package with the desired neovim configuration + # using wrapNeovimUnstable and makeNeovimConfig from nixpkgs. + # the makeNeovimConfig function takes the following arguments: # - withPython (bool) # - extraPython3Packages (lambda) # - withNodeJs (bool) @@ -95,10 +104,14 @@ inputs: { # - plugins (list) # - customRC (string) # and returns the wrapped package - neovim-wrapped = wrapNeovimUnstable vimOptions.package (makeNeovimConfig { + neovimConfigured = makeNeovimConfig { inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit plugins extraLuaPackages extraPython3Packages; customRC = vimOptions.builtConfigRC; + }; + + neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured { + wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs; }); in { inherit (module) options config; diff --git a/modules/neovim/mappings/default.nix b/modules/neovim/mappings/default.nix index 18ce626..fe9e1b8 100644 --- a/modules/neovim/mappings/default.nix +++ b/modules/neovim/mappings/default.nix @@ -1,6 +1,6 @@ { imports = [ ./config.nix - #./options.nix + ./options.nix ]; } diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index e69de29..3b1f263 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -0,0 +1,101 @@ +{lib, ...}: let + inherit (lib.options) mkOption; + inherit (lib.types) bool str attrsOf nullOr submodule; + inherit (lib.nvim.config) mkBool; + # Most of the keybindings code is highly inspired by pta2002/nixvim. + # Thank you! + mapConfigOptions = { + silent = + mkBool false + "Whether this mapping should be silent. Equivalent to adding to a map."; + + nowait = + mkBool false + "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; + + script = + mkBool false + "Equivalent to adding