Add initExtra option to neovim#2244
Add initExtra option to neovim#2244viniciusmuller wants to merge 1 commit intonix-community:masterfrom
Conversation
|
I wouldn't consider the suggestions in the linked PR as "workarounds", don't they work for you. The goal should be to keep options to a minimum so I don't think this MR is needed ? |
|
I personally don't think that makes sense an user have to use xdg.configFile in order to set options on the top of their vimrc. The module should provide abstractions to do that. If you don't think that this is useful, that's ok. But the provided solution doesn't work for me and I would like to use upstream home-manager instead of my fork. |
|
Hi @arcticlimer, Can you set the ''
" generated by Home Manager
set nocompatible
${cfg.initExtra}
''and set back |
sumnerevans
left a comment
There was a problem hiding this comment.
Please format the commits according to the CONTRIBUTING guidelines
|
Hey, @berbiche, are you sure that this |
I had a look at the neovim/vim code in nixpkgs again and I was mistaken. From neovim/utils.nix: {
configurePatched = configure // {
customRC = pluginRc + customRC + (configure.customRC or "");
};
# <snip>
manifestRc = vimUtils.vimrcContent (configurePatched // { customRC = ""; }) ;
}From vim-plugins/vim-utils.nix: {
vimrcContent = {
packages ? null,
vam ? null,
pathogen ? null,
plug ? null,
beforePlugins ? ''
" configuration generated by NIX
set nocompatible
'',
customRC ? null
}:
{ };
} |
|
Could you elaborate a bit more? When trying to change |
The manifestRc solution does not work because its value never gets used.
In that case, you can set |
|
I cannot force push the patch to your branch @arcticlimer, Here's the content: commit 77d0a500cfead7e1a61d8c97de0cfe29c2dfb5f6
Author: Nicolas Berbiche <nicolas@normie.dev>
Date: Sat Aug 21 23:00:20 2021 -0400
neovim: move initExtra to beforePlugins block
diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix
index 66bcb44..22ddc9a 100644
--- a/modules/programs/neovim.nix
+++ b/modules/programs/neovim.nix
@@ -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
+ ${cfg.initExtra}
+ '';
};
extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
@@ -285,11 +289,6 @@ in {
plugins = cfg.plugins
++ optionals cfg.coc.enable [ pkgs.vimPlugins.coc-nvim ];
customRC = cfg.extraConfig;
- manifestRc = ''
- " generated by Home Manager
- set nocompatible
- ${cfg.initExtra}
- '';
};
in mkIf cfg.enable {I verified this PR worked on my local configuration. |
|
Is this right @berbiche? Also I really regret that I forgot to branch out from master when I created this PR. |
|
@arcticlimer can you update the failing test? |
|
I think this might work? Could not test perfectly on my machine, since it was failing due to being generated with other home-manger warnings, but the error about the "generated by home-manager" thing was not here. |
|
The neovim-plugin-config test is still failing due to a missing blank line. |
|
I'm getting this locally, still, I can't see the missing newline error, and setting the mentioned option in my config does nothing. If you could point this change to be committed here, I would be glad :) |
|
This should work: The documentation should be updated to reflect the need to run the tests against the unstable branch of nixpkgs for HM master. |
berbiche
left a comment
There was a problem hiding this comment.
Could you add a news entry to the news.nix file? The format to follow is specified in the file and in docs/contributing.adoc.
1d90a39 to
49f8520
Compare
| beforePlugins = ""; | ||
| beforePlugins = '' | ||
| " generated by Home Manager | ||
| set nocompatible |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Something like this:
| set nocompatible | |
| } // optionalAttrs (cfg.initExtra != "") { | |
| beforePlugins = '' | |
| " Generated by Home Manager | |
| ${cfg.initExtra} | |
| '' | |
| }; |
There was a problem hiding this comment.
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?
| ''; | ||
| }; | ||
|
|
||
| generatedConfigViml = mkOption { |
There was a problem hiding this comment.
This got accidentally moved when it got readded after deletion.
Description
This PR adds an
initExtraoption to neovim, allowing users to add vimscript configuration to the top of the generatedinit.vim,without using workarounds such as #2213. The generated init.vim will have the following shape:
Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.all.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Added myself as module maintainer. See example.
Added myself and the module files to
.github/CODEOWNERS.