Skip to content
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

expose withNodeJs option to pass to neovim wrapper #1198

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

fidgetingbits
Copy link
Contributor

This allows the neovim wrapper to be built with node plugin support by specifying it in the nixvim config. I confirmed that it is present with :checkhealth and that I could load something via a runtimepath rplugin/node folder.

:checkhealth output:

Node.js provider (optional) ~
- Node.js: v18.18.2
- Nvim node.js host: /nix/store/5g13wzq09yx4kp3r6z3w3p913r7y1ik4-neovim-4.11.0/bin/neovim-node-host
- WARNING Package "neovim" is out-of-date. Installed: 4.11.0, latest: 5.0.1
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim

Setting this new option changes the command-line lua argument passed by the neovim wrapper such that vim.g.loaded_node_provider=0 is not passed meaning provider will loaded, and also now the vim.g.node_host_prog gets set. The difference looks like this if you look at ps outout:

withNodeJs option set to true:

 /nix/store/8dz8z8ypimcy52lf81kj5lc3b17h39wn-nixvim/bin/nvim --cmd lua vim.g.node_host_prog='/nix/store/l3nlpj3mr5bizrai1f0ijdxxg78qpd94-neovim-0.9.5/bin/nvim-node';vim
.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog='/nix/store/l3nlpj3mr5bizrai1f0ijdxxg78qpd94-neovim-0.9.5/bin/nvim-python3';vim.g.ruby_host_prog='/nix/store/l3nl
pj3mr5bizrai1f0ijdxxg78qpd94-neovim-0.9.5/bin/nvim-ruby' --cmd set packpath^=/nix/store/fv3169bd1qdv5qbs3bq3j26k7f9f0y5p-vim-pack-dir --cmd set rtp^=/nix/store/fv3169bd1qdv5qbs3bq3j26k7f9f0y5p-v
im-pack-dir -u /nix/store/53ds455c4j8k5flw7hna8x3lrazcifk8-init.lua 

Without the option set:

/nix/store/0pmpp842897a107s5yab46cyr7sxdqm4-nixvim/bin/nvim --cmd lua vim.g.loaded_node_provider=0;vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_
host_prog='/nix/store/6fldmqmgv3xj72sw8azqgd27aalirjv3-neovim-0.9.5/bin/nvim-python3';vim.g.ruby_host_prog='/nix/store/6fldmqmgv3xj72sw8azqgd27aalirjv3-neovim-0.9.5/bin/nvim-ruby' --cmd set pack
path^=/nix/store/r1ik79k79kv2v5gi0fh0hpcdfmxpp8r0-vim-pack-dir --cmd set rtp^=/nix/store/r1ik79k79kv2v5gi0fh0hpcdfmxpp8r0-vim-pack-dir -u /nix/store/gjd9hdnvwy3h9l8sg0jdfzgyw8kkj6r0-init.lua

Note that the nix flake check tests fail for me with the following error:

ERROR: [null-ls] You required a deprecated builtin (code_actions/eslint.lua), which will be removed in March.

But I think this has nothing to do with my change. I'm happy to run tests again, if there is something I'm missing here.

If this PR is accepted then probably the other neovim provider option should be exposed (perl, python, ruby, etc) but I don't have the means to test those atm so didn't include them.

@GaetanLepage GaetanLepage requested a review from traxys March 3, 2024 21:46
@traxys traxys merged commit 40286bf into nix-community:main Mar 3, 2024
51 checks passed
@traxys
Copy link
Member

traxys commented Mar 3, 2024

We could do the same for the others, but aren't a lot of them enabled by default?

@fidgetingbits
Copy link
Contributor Author

We could do the same for the others, but aren't a lot of them enabled by default?

Ya, from <nixpkgs>/pkgs/applications/editors/neovim/wrapper.nix:

 167     /* Generate vim.g.<LANG>_host_prog lua rc to setup host providers
 168   
 169     Mapping a boolean argument to a key that tells us whether to add
 170         vim.g.<LANG>_host_prog=$out/bin/nvim-<LANG>
 171     Or this:
 172         let g:loaded_${prog}_provider=0
 173     While the latter tells nvim that this provider is not available */
 174     generateProviderRc = {
 175         withPython3 ? true
 176       , withNodeJs ? false
 177       , withRuby ? true
 178       # perl is problematic https://github.com/NixOS/nixpkgs/issues/132368
 179       , withPerl ? false

So really would only need to add withPerl. I guess the other benefit of exposing them is if someone actually wanted to turn default ruby/python off, but maybe can wait until someone needs it.

@fidgetingbits fidgetingbits deleted the fix-nodejs branch March 4, 2024 00:38
@michaelfranzl michaelfranzl mentioned this pull request May 7, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants