neovim: autogenerate config.lua file sourced to init.vim#2716
neovim: autogenerate config.lua file sourced to init.vim#2716teto merged 1 commit intonix-community:masterfrom
Conversation
|
I tried running the test suite, but attribute shellDryRun was missing. Given that I didn't go anywhere near those files, I'm going to assume something is off or faulty there? |
|
Looks like there's an upstream remarshal package error in nixpkgs. It's supposedly fixed on master. NixOS/nixpkgs#159074 |
|
Yep, need it to hit nixpkgs-unstable: https://nixpk.gs/pr-tracker.html?pr=159074 |
|
sounds sensible. I have something similiar in my config except that I've named the file |
So the use case you refer to, where we would automatically generate a init.lua file has some issues. The first being that neovim.generatedConfigs.lua will automatically be empty if neovimConfig.neovimRcContent is empty. The reason for this being the case is that neovim.generatedConfigs.lua only aggregates lua code found in plugins, while having plugins requires the package and runtime support, which mandates 2 minimum lines in neovimConfig.neovimRcContent. The second being that neovim.generateConfigs.lua does not have the package and runtime support lines automatically added at the top. Ideally, I agree with you. It would be great to have the neovim module support lua-only configs as that is quickly becoming the standard (if it not already is). Ideally, we'd also figure out a way to add lua module support for configuration, as it is pretty common place for lua based configs to have quite a lot of customization done outside of plugins (and sending it to a single file is a bit messy). Correct me if I'm wrong, but I think this would require a rewrite of this part of the code: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/neovim/utils.nix is where Also, it seems that another pull request was just submitted attempting to work on this too: I'm linking that here (#2723). |
This could be added to either lua or vimscript, not a problem IMO. You can look at nixpkgs nixos/modules/programs/neovim.nix: I would like it if we could have this as a parameter of makeNeovimConfig as you suggest. |
|
I would like before merging a more specific name than |
8229801 to
833bd92
Compare
I have amended my commit/PR to change the I hope this change is sufficient to suggest this point? If not, please let me know so I can make further changes so this can be merged. Appreciate it! |
After this gets merged, I think I'll tackle this next. I'd also like to add the option to add arbitrary lua code in the form of modules and source the files appropriately. Thanks! |
|
arf the CI doesn't pass because of an issue in nixpkgs (remarshal build is fixed in master so we have to wait for it to reach unstable). I want to merge but I dont think I can with the failing CI. |
It looks like the tests are passing again; would you mind rerunning the CI? |
|
I can't unless you rebase or amend your last commit. Do it and I will merge it (no need to ping me if tests pass) |
833bd92 to
4c63e99
Compare
Sorry for the ping, but the tests won't run until they are approved by someone. I rebased, so hopefully this will do the trick to pass CI now. Thanks! |
|
seems to be a valid error here https://github.com/nix-community/home-manager/runs/5302698665?check_suite_focus=true#step:9:868 . Btw you can run the tests locally with |
4c63e99 to
6ccacd2
Compare
Thank you All tests are passing locally now. Thanks! |
|
so next step would be if no viml config, generate an "init.lua" instead of an "init-home-manager.lua" ? |
I think so, but I also think it might be worth making the extraConfig option typeable between a viml and lua (with viml being the default so as to not break people's configs). Otherwise generating an init.lua file would give you no way to source additional lua code for your config (outside of the plugin specific ones, which wouldn't be very idiomatic) for things like setting , line numbers, etc. Does that sound like a reasonable approach? I'm going to try to get that up and working this weekend, if nobody else starts working on it first. Thanks for the merge btw! |
|
Yeah extraConfig could be of type pluginWithConfigType (ignoring the "optional" part) |
Though it would be odd to have an What do you think? |
| neovimConfig.neovimRcContent; | ||
| }; | ||
| xdg.configFile."nvim/lua/init-home-manager.lua" = | ||
| mkIf (hasAttr "lua" config.programs.neovim.generatedConfigs) { |
There was a problem hiding this comment.
When exactly does this file get generated? generatedConfigs is readonly, and I cannot think of a scenario when it would have a lua attr?
There was a problem hiding this comment.
if you set your plugin like this:
{
plugin = urlview-nvim;
type = "lua";
config = ''
'';
}
I prefer the pure lua way. Because the modular design of lua( https://github.com/mlyxshi/flake/blob/main/home/nvim/nvim.nix I'm not familiar with nix lang right now, could you please implement the init.lua? |
Description
The neovim module now automatically adds a config.lua file and sources it at the bottom of the init.vim configuration file, when the aggregate plugin configurations for the lua type have non-zero length. This adds the remaining functionality (for lua plugins) that #2637 set out to add to the neovim module. Previous to this change, the lua files were not sourced to the init.vim file, even if you created the lua files yourself in your home-manager configuration file.
Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.all. (via make test TEST=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.