[backport #3639] programs.neovim: add extraLuaConfig (#3727)

Co-authored-by: Guillaume Desforges <guillaume.desforges.pro@gmail.com>
This commit is contained in:
Wael Nasreddine 2023-03-01 14:52:37 -08:00 committed by GitHub
parent 71c6073ee0
commit a7d3f51e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View file

@ -240,6 +240,17 @@ in {
''; '';
}; };
extraLuaConfig = mkOption {
type = types.lines;
default = "";
example = ''
vim.opt.nobackup = true
'';
description = ''
Custom lua lines.
'';
};
extraPackages = mkOption { extraPackages = mkOption {
type = with types; listOf package; type = with types; listOf package;
default = [ ]; default = [ ];
@ -373,6 +384,7 @@ in {
luaRcContent = luaRcContent =
lib.optionalString (neovimConfig.neovimRcContent != "") lib.optionalString (neovimConfig.neovimRcContent != "")
"vim.cmd [[source ${config.xdg.configHome}/nvim/init-home-manager.vim]]" "vim.cmd [[source ${config.xdg.configHome}/nvim/init-home-manager.vim]]"
+ config.programs.neovim.extraLuaConfig
+ lib.optionalString hasLuaConfig + lib.optionalString hasLuaConfig
config.programs.neovim.generatedConfigs.lua; config.programs.neovim.generatedConfigs.lua;
in mkIf (luaRcContent != "") { text = luaRcContent; }; in mkIf (luaRcContent != "") { text = luaRcContent; };

View file

@ -5,4 +5,5 @@
# waiting for a nixpkgs patch # waiting for a nixpkgs patch
neovim-no-init = ./no-init.nix; neovim-no-init = ./no-init.nix;
neovim-extra-lua-init = ./extra-lua-init.nix;
} }

View file

@ -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
''
}
'';
};
}