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

Ensure that local node runtime and python bindir are in the PATH #67

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions st3/lsp_utils/_client_handler/abstract_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def can_start(cls, window: sublime.Window, initiating_view: sublime.View,
configuration.command = cls.get_command()
return None

@classmethod
def on_pre_start(cls, window: sublime.Window, initiating_view: sublime.View,
workspace_folders: List[WorkspaceFolder], configuration: ClientConfig) -> Optional[str]:
extra_paths = path.pathsep.join(cls.get_additional_paths())
if extra_paths:
original_path = configuration.env.get('PATH') or ''
configuration.env['PATH'] = path.pathsep.join([extra_paths, original_path])
predragnikolic marked this conversation as resolved.
Show resolved Hide resolved
return None

# --- ClientHandlerInterface --------------------------------------------------------------------------------------

@classmethod
Expand Down
5 changes: 5 additions & 0 deletions st3/lsp_utils/_client_handler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def package_storage(cls) -> str:
def get_additional_variables(cls) -> Dict[str, str]:
...

@classmethod
@abstractmethod
def get_additional_paths(cls) -> List[str]:
...

@classmethod
@abstractmethod
def manages_server(cls) -> bool:
Expand Down
4 changes: 4 additions & 0 deletions st3/lsp_utils/generic_client_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ def get_additional_variables(cls) -> Dict[str, str]:
'server_path': cls.binary_path(),
}

@classmethod
def get_additional_paths(cls) -> List[str]:
return []

@classmethod
def manages_server(cls) -> bool:
"""
Expand Down
5 changes: 5 additions & 0 deletions st3/lsp_utils/npm_client_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .server_npm_resource import ServerNpmResource
from .server_resource_interface import ServerResourceInterface
from LSP.plugin.core.typing import Dict, List, Optional, Tuple
from os import path

__all__ = ['NpmClientHandler']

Expand Down Expand Up @@ -61,6 +62,10 @@ def get_additional_variables(cls) -> Dict[str, str]:
})
return variables

@classmethod
def get_additional_paths(cls) -> List[str]:
return [path.dirname(cls._node_bin())]
Copy link
Member Author

@rchl rchl Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to return anything here when using node on PATH but it shouldn't hurt to include it either.


# --- GenericClientHandler handlers -------------------------------------------------------------------------------

@classmethod
Expand Down