Skip to content

neovim: give the choice to wrap startup commands (to set packpath, rtp, providers etc) or add them to initrc#205932

Closed
teto wants to merge 1 commit intoNixOS:masterfrom
teto:nvim-wrapping-startup-commands
Closed

neovim: give the choice to wrap startup commands (to set packpath, rtp, providers etc) or add them to initrc#205932
teto wants to merge 1 commit intoNixOS:masterfrom
teto:nvim-wrapping-startup-commands

Conversation

@teto
Copy link
Copy Markdown
Member

@teto teto commented Dec 13, 2022

1/ We used to set rtp and packpath in the generated init.vim.
That was removed in case users wanted to keep their own init.vim rather
than one generated by nvim.

To be able to install plugins while keeping
your own init.vim, we wrap the HM binary with "startup commands" such as

--cmd' 'set rtp^=/nix/store/c1cqzhhxgxd36jj9fqv0x0xfbh5fp9gr-vim-pack-dir,/nix/store/jim60lbwdl7gln40q28zf7gqya95bdf1-grammars'

This triggers another issue when using project-specific neovim, it
isn't wrapped with these flags and thus can't properly load the
generated init.vim (plugins are missing since packdir is not set).

This PR makes it possible to revert to the old behavior with the
wrapStartupCommands boolean in neovim's wrapper.

This allows home-manager to generate an init.lua that can be picked up
by any neovim, not necessarily the one generated by home-manager.

2nd commit warns about wrapperArgs expecting an array instead of a string. Adds a depreciation notice.

Related home-manager PR ready as well.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.05 Release Notes (or backporting 22.11 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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: vim Advanced text editor label Dec 13, 2022
Copy link
Copy Markdown
Member

@figsoda figsoda left a comment

Choose a reason for hiding this comment

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

We used to set rtp and packpath in the generated init.vim.
That was removed in case users wanted to keep their own init.vim rather
than one generated by nvim.

To be able to install plugins while keeping
your own init.vim, we wrap the HM binary with "startup commands" such as

    --cmd' 'set rtp^=/nix/store/c1cqzhhxgxd36jj9fqv0x0xfbh5fp9gr-vim-pack-dir,/nix/store/jim60lbwdl7gln40q28zf7gqya95bdf1-grammars'

This triggers another issue when using project-specific neovim, it
isn't wrapped with these flags and thus can't properly load the
generated init.vim (plugins are missing since packdir is not set).

This PR makes it possible to revert to the old behavior with the
`wrapStartupCommands` boolean in neovim's wrapper.

This allows home-manager to generate an init.lua that can be picked up
by any neovim, not necessarily the one generated by home-manager.
@teto teto force-pushed the nvim-wrapping-startup-commands branch from 7fb63b2 to 5fc7e68 Compare December 14, 2022 11:15
@teto teto changed the title neovim: depreate wrapperArgs as string neovim: give the choice to wrap startup commands (to set packpath, rtp, providers etc) or add them to initrc Dec 14, 2022
@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 Dec 14, 2022
@teto
Copy link
Copy Markdown
Member Author

teto commented Dec 14, 2022

Indeed. the legacyWrapper does need to use a string and it would be a pain for everyone to deprecate that until we get a proper new wrapper. So the PR doesnt deprecate the usage anymore.

, wrapRc ? true
# if yes, pass startupCommands as `--cmd` arguments to neovim
# if false, inline the commands in the generated initrc
, wrapStartupCommands ? true
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.

does that mean startupCommands would be in lua if true and in vim if false?

@teto teto marked this pull request as draft December 19, 2022 18:25
@teto
Copy link
Copy Markdown
Member Author

teto commented Apr 9, 2023

I've merged a better PR

@teto teto closed this Apr 9, 2023
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants