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
9 changes: 9 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,15 @@ in
A new module is available: 'services.trayer'.
'';
}
{
time = "2021-09-08T19:46:25.315Z";
message = ''
The neovim module has a new option: 'neovim.initExtra'.

This adds extra vimscript configuration to add to the top of the
generated configuration file.
'';
}
];
};
}
37 changes: 25 additions & 12 deletions modules/programs/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ let
(map (x: if x ? plugin && x.optional == true then x.plugin else null)
cfg.plugins);
};
beforePlugins = "";
beforePlugins = ''
" generated by Home Manager
set nocompatible
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want home-manager not to generate a file if nothing is configured, this goes against that. Also neovim has set nocompatible by default so no need to pass that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you so please provide a better and working solution? This is what I and berbiche were able to make. All the other provided solutions until now lead to nix errors or nvim config duplication, and I do not see why I should write my config trying to work around this, since it's a home-manager bug that should be fixed.

Copy link
Copy Markdown
Member

@berbiche berbiche Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this:

Suggested change
set nocompatible
} // optionalAttrs (cfg.initExtra != "") {
beforePlugins = ''
" Generated by Home Manager
${cfg.initExtra}
''
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @arcticlimer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I've forgot about that PR. This PR is currently a mess (it has conflicts, I made it from the wrong branch...), do you mind if I close this and apply these changes in a new PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead!

${cfg.initExtra}
'';
};

extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
Expand All @@ -79,6 +83,14 @@ in {
'';
};

initExtra = mkOption {
type = types.lines;
default = "";
description = ''
Configuration to insert on the top of init.vim
'';
};

vimAlias = mkOption {
type = types.bool;
default = false;
Expand Down Expand Up @@ -121,6 +133,15 @@ in {
'';
};

generatedConfigViml = mkOption {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move this ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got accidentally moved when it got readded after deletion.

type = types.lines;
visible = true;
readOnly = true;
description = ''
Generated vimscript config.
'';
};

extraPython3Packages = mkOption {
type = with types; either extraPython3PackageType (listOf package);
default = (_: [ ]);
Expand All @@ -132,15 +153,6 @@ in {
'';
};

generatedConfigViml = mkOption {
type = types.lines;
visible = true;
readOnly = true;
description = ''
Generated vimscript config.
'';
};

Comment thread
berbiche marked this conversation as resolved.
package = mkOption {
type = types.package;
default = pkgs.neovim-unwrapped;
Expand Down Expand Up @@ -289,13 +301,14 @@ in {
configure.customRC -> programs.neovim.extraConfig
'';

programs.neovim.generatedConfigViml = neovimConfig.neovimRcContent;

home.packages = [ cfg.finalPackage ];

programs.neovim.generatedConfigViml = neovimConfig.neovimRcContent;

xdg.configFile."nvim/init.vim" = mkIf (neovimConfig.neovimRcContent != "") {
text = neovimConfig.neovimRcContent;
};

xdg.configFile."nvim/coc-settings.json" = mkIf cfg.coc.enable {
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
};
Expand Down
4 changes: 4 additions & 0 deletions tests/modules/programs/neovim/plugin-config.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
" generated by Home Manager
set nocompatible


set packpath^=/nix/store/00000000000000000000000000000000-vim-pack-dir
set runtimepath^=/nix/store/00000000000000000000000000000000-vim-pack-dir

Expand Down