Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

programs.neovim: add extraLuaConfig #3639

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion modules/programs/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,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 = [ ];
Expand Down Expand Up @@ -394,7 +405,8 @@ in {
"vim.cmd [[source ${
pkgs.writeText "nvim-init-home-manager.vim"
neovimConfig.neovimRcContent
}]]" + lib.optionalString hasLuaConfig
}]]" + config.programs.neovim.extraLuaConfig
+ lib.optionalString hasLuaConfig
config.programs.neovim.generatedConfigs.lua;
in mkIf (luaRcContent != "") { text = luaRcContent; };

Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

# waiting for a nixpkgs patch
neovim-no-init = ./no-init.nix;
neovim-extra-lua-init = ./extra-lua-init.nix;
}
23 changes: 23 additions & 0 deletions tests/modules/programs/neovim/extra-lua-init.nix
Original file line number Diff line number Diff line change
@@ -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
''
}
'';
};
}