Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
/modules/programs/ne.nix @cwyc
/tests/modules/programs/ne @cwyc

/modules/programs/neovim.nix @cdunster
/tests/modules/programs/neovim @cdunster

/modules/programs/newsboat.nix @sumnerevans
/tests/modules/programs/newsboat @sumnerevans

Expand Down
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,10 @@
github = "pinage404";
githubId = 6325757;
};
cdunster = {
name = "Callum Dunster";
email = "cdunster@users.noreply.github.com";
github = "cdunster";
githubId = 5011912;
};
}
20 changes: 15 additions & 5 deletions modules/programs/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ let
type = mkOption {
type =
types.either (types.enum [ "lua" "viml" "teal" "fennel" ]) types.str;
description =
"Language used in config. Configurations are aggregated per-language.";
description = "Language used in config section of this plugin.";
default = "viml";
};

Expand Down Expand Up @@ -311,14 +310,25 @@ in {
config = "";
optional = false;
}) cfg.plugins;
suppressNotVimlConfig = p:
if p.type != "viml" then p // { config = ""; } else p;
convertConfigToViml = p:
if p.type == "viml" then
p
else if p.type == "lua" then
p // {
config = ''
lua << EOF
'' + p.config + ''

EOF'';
}
else
p // { config = ""; };

neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
inherit (cfg)
extraPython3Packages withPython3 withNodeJs withRuby viAlias vimAlias;
configure = cfg.configure // moduleConfigure;
plugins = (map suppressNotVimlConfig pluginsNormalized)
plugins = (map convertConfigToViml pluginsNormalized)
++ optionals cfg.coc.enable [{ plugin = pkgs.vimPlugins.coc-nvim; }];
customRC = cfg.extraConfig;
};
Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
neovim-plugin-config = ./plugin-config.nix;
neovim-coc-config = ./coc-config.nix;
neovim-plugin-config-lua = ./plugin-config-lua.nix;
# waiting for a nixpkgs patch
# neovim-no-init = ./no-init.nix;
}
34 changes: 34 additions & 0 deletions tests/modules/programs/neovim/plugin-config-lua.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:

with lib;

{
config = {
programs.neovim = {
enable = true;
extraConfig = ''
" This should be present in init.vim
'';
plugins = with pkgs.vimPlugins; [
vim-nix
{
plugin = vim-commentary;
type = "lua";
config = ''
-- This should be present in a lua block.
vim.opt.number = true
'';
}
];
};

nmt.script = ''
vimrc="$TESTED/home-files/.config/nvim/init.vim"
vimrcNormalized="$(normalizeStorePaths "$vimrc")"

assertFileExists "$vimrc"
assertFileContent "$vimrcNormalized" "${./plugin-config-lua.vim}"
'';
};
}

11 changes: 11 additions & 0 deletions tests/modules/programs/neovim/plugin-config-lua.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set packpath^=/nix/store/00000000000000000000000000000000-vim-pack-dir
set runtimepath^=/nix/store/00000000000000000000000000000000-vim-pack-dir

" vim-commentary {{{
lua << EOF
-- This should be present in a lua block.
vim.opt.number = true

EOF
" }}}
" This should be present in init.vim