-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add support for specifying path to node in settings #118
base: main
Are you sure you want to change the base?
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work on Windows.
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
node
binary. I've found thatsystem
can be unreliable when using tools likenodenv
(even with proper.zprofile
setup), 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
npm
binary 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.