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

volta + neovim compatibility issues #866

Open
stefanpenner opened this issue Nov 11, 2020 · 7 comments
Open

volta + neovim compatibility issues #866

stefanpenner opened this issue Nov 11, 2020 · 7 comments

Comments

@stefanpenner
Copy link
Contributor

stefanpenner commented Nov 11, 2020

problem

neovim cannot discover node modules installed globally by volta

investigation

nvim +checkhealth

yields:

## Node.js provider (optional)
  - INFO: Node.js: v14.15.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

Given that when using volta, npm i -g and volta global add are discouraged, i run:

volta install neovim

Which still has nvim +checkhealth yielding:

## Node.js provider (optional)
  - INFO: Node.js: v14.15.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

Investigating further, neovim's algorithm essentially looks each of the following locations:

  • npm --loglevel silent root -g
  • yarn global dir (for non unix)
  • '$HOME/.config/yarn/global/' (for unix)

Likely ideal solution

Add volta support to neovim? corresponding neovim issue

Workaround:

The following has volta behave as if it were yarn, which appears to address the issue in question.

volta install yarn 
rm -rf $HOME/.config/yarn/global/
mkdir -p $HOME/.config/yarn/global/
ln -s $HOME/.volta/tools/shared/ $HOME/.config/yarn/global/node_modules

yields a functional node.js provider for neovim.

## Node.js provider (optional)
  - INFO: Node.js: v14.15.0
  - INFO: Neovim node.js host: /Users/spenner/.config/yarn/global//node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.9.0
@chriskrycho
Copy link
Contributor

@stefanpenner which version of Volta are you using? Our recent 0.9.x releases should have (a) stopped discouraging use of npm i -g or yarn global add and (b) made this work!

@charlespierce
Copy link
Contributor

@chriskrycho The changes in 0.9.x still didn't quite get this working. neovim itself isn't launched by Volta, so it doesn't pick up the NODE_PATH that makes the neovim package available with require. It looks (given the above-linked issue) like neovim looks in a couple of specific locations for the Node package, and Volta's custom package handling breaks those assumptions.

@chriskrycho
Copy link
Contributor

Ahhhh, that would do it; I misunderstood the dynamics with neovim specifically. Thanks for clarifying, @charlespierce!

@mainendra
Copy link

@stefanpenner - You have to specify node path in neovim config (init.vim). Please add let g:node_host_prog = system('volta which neovim-node-host | tr -d "\n"') to your neovim config and try again.

@stefanpenner
Copy link
Contributor Author

stefanpenner commented Nov 19, 2020

@mainendra that is a better workaround than the one I have listed, thank you.

That being said it would be great to make this more seamless.

In the meantime, I've changed my work-around to add the following to my init.vim based on @mainendra's suggestion:

if executable('volta')
  let g:node_host_prog = trim(system("volta which neovim-node-host"))
endif

@mainendra
Copy link

I think we can convert this to enhancement story.

@DriesVerb
Copy link

Thanks for your solutions. For me they were not 100% clear, so if anyone had the same problem. It worked with me via this:

local g = vim.g 

g["node_host_prog"] = vim.call("system", 'volta which neovim-node-host | tr -d "\n"')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants