-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
neovim: add standalone module to configure it #55635
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
Conversation
@@ -99,7 +74,7 @@ let | |||
# Only display the log on error since it will contain a few normally | |||
# irrelevant messages. | |||
if ! $out/bin/nvim \ | |||
-u ${vimUtils.vimrcFile (configure // { customRC = ""; })} \ | |||
-u ${neovimrcFile} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I should erase the customRC
@@ -113,7 +88,7 @@ let | |||
# https://github.com/neovim/neovim/issues/9413 | |||
wrapProgram $out/bin/nvim \ | |||
--set NVIM_SYSTEM_RPLUGIN_MANIFEST $out/rplugin.vim \ | |||
--add-flags "-u ${vimUtils.vimrcFile configure}" | |||
--add-flags "--cmd \"source ${neovimrcFile}\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively I can wrap with --set VIMINIT "source vimrc"
to recover the old behavior.
@teto can you please describe how to use this module, perhaps some documentation in the manual and/or wiki? |
@kalbasit right now I would say it just gives better error messages (typecheck) than plain nix errors when generating the vimrc. It seems like these kind of isolated modules don't appear in |
another motivation is to be able to merge neovim configurations. I have a global neovim with minimal python haskell/environments and when I enter a project, I have a nix-shell that generates a neovim configuration adapted for that project (with the proper python3 environment). |
@timokau any opinon ? I think this fits nix way better, like you can have a custom nvim(rc) for each nix-shell. |
I haven't looked at the implementation, but I don't really agree with the premise. Sorry if this sounds overly negative. That said I'm not trying to criticise you (you're doing good work) or block this from being merged, just giving my opinion. NixOS modules have some advantages, but also significant disadvantages:
How does this enable you to have a custom Also I think a lot of the complexity with the current way to configure neovim comes from environment.systemPackages = with pkgs; [
(neovim.override {
configure = {
packages.pkg = with vimPlugins; {
start = [
gruvbox
base16-vim
];
opt = [
vim-nix
];
};
customRC = ''
" something
'';
};
})
] I don't think that is particularly hard. Just unfortunately unstandardized and badly documented. Regarding the other aspects of this PR:
That would be nice to fix, but
I think that is a net negative. At least as a default. It goes against the point of configuring it through nix.
There shouldn't be any reason to do this. If there is, that is a bug that should be fixed. I'd be careful adding a config option to work around a bug. If it is broken right now, I'd rather have it disabled entirely until it is fixed. |
Can anyone confirm that setting "MYVIMRC" to anything breaks module plugins? |
This PR adds a module to typecheck parameters passed to build the wrapper. It allows to generate It adds the possibility to configure the haskell provider. It adds a knob to disable generation of the neovim remote plugin manisfest. Using `-u` to load the generated config breaks vim expectations about setting $MYVIMRC, detecting and autoloading .nvimrc / .vimrc. This PR changes the behavior (not backwards compatible) to fix this. The configuration is not fully declarative anymore as it will also attempt to load the user configuration. see here for more details NixOS#55376.
I don't think that works as is but I merged some update from my main branch to reflect current changes. @timokay thanks for the great feedback, I will adjust the PR once I finalize it to match the current determistic behavior. In this PR I use the nix system module rather than the nixos one, e.g., I pass a config (merged via the module system) when building neovim For instance in my overlay I have:
and in my shell.nix for the python (in the future all languages) project I develop on, I have a |
Why do you need a nixos module for that? Couldn't you do the same thing with a base |
Thank you for your contributions.
|
current vim infra is still a pain for me, like some plugins do need custom configuration, we should make it possible to build vim configuration frameworks. For instance current unicode plugin should have at least: Also let me post https://envy.shados.net/ that may be too complex for nixpkgs but a source of possible inspiration |
For what it's worth, you can get there without a nixos module: https://github.com/timokau/dotfiles/blob/c3340392081c126b5d1cf8cd3e7c519d1cdeb202/home/neovim.nix#L49 Which seems better to me since its more composable. |
Thanks for the pointer, I am not saying you can't work around nixos, but nix is in good at handling dependencies and in this case it doesn't, for instance in my unicode example, either I wish installing unicode-vim would add |
Couldn't that still be implemented as part of the |
I marked this as stale due to inactivity. → More info |
I still would like to leverage the nixpkgs module system to merge configurations but I am unlikely to do it soon. It's now easier to generate your own config via utilities in pkgs/applications/editors/neovim/utils.nix too. Thus closing for now. |
This PR adds a module to typecheck parameters passed to build the wrapper.
It allows to generate
It adds the possibility to configure the haskell provider.
It adds a knob to disable generation of the neovim remote plugin manisfest.
Using
-u
to load the generated config breaks vim expectations about setting $MYVIMRC,detecting and autoloading .nvimrc / .vimrc.
This PR changes the behavior (not backwards compatible) to fix this.
The configuration is not fully declarative anymore as it will also attempt to load the user configuration.
see here for more details #55376.
Motivation for this change
I've seen in meetups people having a hard time installing vim because the
configure
setting is so confusing. Using the module system makes errors more explicit, it adds some documentation. It will also make it easier to generate custom vimrc in nix-shell or in home-manager. Right now, I use tricks in my shell.nix to change the g:python3_host_prog via .nvimrc to tell neovim linters to use this project configuration. With this PR, it gets easier to just configure a new neovim wrapper for each project.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)