diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 88683e40..e4555c80 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -240,6 +240,17 @@ in { ''; }; + extraLuaConfig = mkOption { + type = types.lines; + default = ""; + example = '' + vim.opt.nobackup = true + ''; + description = '' + Custom lua lines. + ''; + }; + extraPackages = mkOption { type = with types; listOf package; default = [ ]; @@ -373,6 +384,7 @@ in { luaRcContent = lib.optionalString (neovimConfig.neovimRcContent != "") "vim.cmd [[source ${config.xdg.configHome}/nvim/init-home-manager.vim]]" + + config.programs.neovim.extraLuaConfig + lib.optionalString hasLuaConfig config.programs.neovim.generatedConfigs.lua; in mkIf (luaRcContent != "") { text = luaRcContent; }; diff --git a/tests/modules/programs/neovim/default.nix b/tests/modules/programs/neovim/default.nix index 3950dc8b..d3224666 100644 --- a/tests/modules/programs/neovim/default.nix +++ b/tests/modules/programs/neovim/default.nix @@ -5,4 +5,5 @@ # waiting for a nixpkgs patch neovim-no-init = ./no-init.nix; + neovim-extra-lua-init = ./extra-lua-init.nix; } diff --git a/tests/modules/programs/neovim/extra-lua-init.nix b/tests/modules/programs/neovim/extra-lua-init.nix new file mode 100644 index 00000000..2abaa6e9 --- /dev/null +++ b/tests/modules/programs/neovim/extra-lua-init.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.neovim = { + enable = true; + + extraLuaConfig = '' + -- extraLuaConfig + ''; + }; + nmt.script = '' + nvimFolder="home-files/.config/nvim" + assertFileContent "$nvimFolder/init.lua" ${ + pkgs.writeText "init.lua-expected" '' + -- extraLuaConfig + '' + } + ''; + }; +}