Skip to content

neovim: add 'autoconfigure' setting#356271

Merged
teto merged 1 commit intoNixOS:masterfrom
teto:teto/neovim-autoconfigure
Nov 24, 2024
Merged

neovim: add 'autoconfigure' setting#356271
teto merged 1 commit intoNixOS:masterfrom
teto:teto/neovim-autoconfigure

Conversation

@teto
Copy link
Copy Markdown
Member

@teto teto commented Nov 15, 2024

certain plugins need a custom configuration (available in passthru.initLua) to work with nix. For instance unicode-vim needs to configure where to find the data:

vim.g.Unicode_data_directory="${self.unicode-vim}/autoload/unicode"

if true, the wrapper automatically appends those snippets when necessary

first setup in #352741

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: vim Advanced text editor label Nov 15, 2024
certain plugins need a custom configuration (available in passthru.initLua)
to work with nix. For instance unicode-vim needs to configure where to
find the data:
```
vim.g.Unicode_data_directory="${self.unicode-vim}/autoload/unicode"
```
if true, the wrapper automatically appends those snippets when necessary

first appearance of initLua in NixOS#352741

This will make testing those plugins easier.
@teto teto force-pushed the teto/neovim-autoconfigure branch from f9d59b9 to 0e67d16 Compare November 23, 2024 18:25
@teto teto marked this pull request as ready for review November 23, 2024 18:28
@teto
Copy link
Copy Markdown
Member Author

teto commented Nov 23, 2024

disabled by default to let users test first for instance with neovim.overrideAttrs({ autoconfigure = true;}).
The only concern I have is with the naming. I would like us to address the autoaddition of plugin runtimeDeps in the neovim wrapper see #352738. This will start disabled by default as well. Is this going to be a different flag or the same for simplicity ?
Maybe something like that ?

wrapper = {
autoconfigure ? false
autoconfigureRuntimeDeps ? autoconfigure
...
}:
...

op = acc: normalizedPlugin:
acc ++ lib.optional (finalAttrs.autoconfigure && normalizedPlugin.plugin.passthru ? initLua) normalizedPlugin.plugin.passthru.initLua;
in
lib.foldl' op [] pluginsNormalized;
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.

question: foldl' will reverse the order (correct me if mistaken). Do we care about this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I dont think so, the accumulator comes first.
applying

diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix
index fb89d47aceb0..48b00d42f272 100644
--- a/pkgs/applications/editors/neovim/tests/default.nix
+++ b/pkgs/applications/editors/neovim/tests/default.nix
@@ -170,7 +170,10 @@ in
   '';
 
   nvim_with_autoconfigure = pkgs.neovim.overrideAttrs(oa: {
-    plugins = [ vimPlugins.unicode-vim ];
+    plugins = [
+      vimPlugins.unicode-vim
+      vimPlugins.fzf-hoogle-vim
+    ];
     autoconfigure = true;
     # legacy wrapper sets it to false
     wrapRc = true;

generated

vim.cmd.source "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-init.vim"
vim.g.Unicode_data_directory="/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vimplugin-unicode.vim-2024-07-23/autoload/unicode"
vim.g.hoogle_fzf_cache_file = vim.fn.stdpath('cache')..'/hoogle_cache.json

Copy link
Copy Markdown
Member

@PerchunPak PerchunPak left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@khaneliman khaneliman left a comment

Choose a reason for hiding this comment

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

LGTM

/* neovim-drv must be a wrapped neovim
- exposes lua config in $luarcGeneric
- exposes vim config in $vimrcGeneric

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll do this on next update ty

@wegank wegank added the 12.approvals: 3+ This PR was reviewed and approved by three or more persons. label Nov 24, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 24, 2024
@teto teto merged commit d11140f into NixOS:master Nov 24, 2024
@teto teto deleted the teto/neovim-autoconfigure branch November 24, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: vim Advanced text editor 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants