1

Currently for CoC I am setting the nodejs path like this:

let g:coc_node_path = '/usr/local/.nvm/versions/node/v12.4.0/bin/node'

But I want this variable to be set to the output of which node. How can I do this? The CoC config guide does not mention this, and it's my understanding that this is a vim script specific feature.

2

Perhaps I should have searched the internet more before I asked this question. I was able to accomplish what I needed using the system function.

So here I needed to do:

let g:coc_node_path = substitute(system('which node'), '\n', '', '')

The substitute is necessary because we need to get rid of the new line at the end of the output, otherwise the path is invalid.

2
  • 2
    If your vim is new enough it should have trim() – D. Ben Knoble Jan 24 '20 at 14:02
  • 1
    And if it's old, you could always which node | tr -d "\n" – Biggybi Jan 28 '20 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.