feat: add support for specifying path to node in settings#118
feat: add support for specifying path to node in settings#118taylorzane wants to merge 2 commits intosublimelsp:mainfrom
Conversation
|
Hello, I use nvm When I have the following set in lsp_utils.sublime-settings: {
"nodejs_runtime": ["/Users/predrag/.nvm/versions/node/v20.11.1/bin/node"],
}I get this error: |
|
@predragnikolic I went ahead and made the suggested changes to support |
|
Why not just add the path to node? Instead of: Allow setting the path as: Also, filter the path for env variables and user placeholders so that paths like So now you will be able to set paths like: I'm wondering if it's possible to add the path the environment But you don't want to have to do that for every client, you want to be able to set it globally. That I think would be a better solution:
Currently, I have to make nvm available at the system level. It's not ideal. Maybe Sublime Text already has a way of adding to the environment? That wouldn't be ideal either, but it would be better than making nvm available at the system level. |
| self._node = path.join(self._base_dir, 'node') | ||
| self._npm = path.join(self._base_dir, 'npm') |
|
I think this is a way cleaner approach: class NodeRuntimePATH(NodeRuntime):
def __init__(self) -> None:
super().__init__()
- self._node = shutil.which('node')
- self._npm = shutil.which('npm')
+ path = settings.get('nodejs_path') or None
+ self._node = shutil.which('node', path=path)
+ self._npm = shutil.which('npm', path=path)lsp_utils/st3/lsp_utils/node_runtime.py Lines 229 to 233 in e0f4692 |
This pull request adds support for specifying a path to a
nodebinary. I've found thatsystemcan be unreliable when using tools likenodenv(even with proper.zprofilesetup), so this change lets a user specify any node binary to be used with LSP plugins.I've also submitted a PR to update the
lsp_utils.sublime-settings: sublimelsp/LSP#2464Caveat: This change assumes that an
npmbinary exists in the same directory asnode; in my research it seems that all installations of Node.js follow this principle, so it should be a non-issue.