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

[WIP] Jedi project sys.path manipulation #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions jedi_language_server/jedi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import random
import string # pylint: disable=deprecated-module
import sys
from inspect import Parameter
from typing import Dict, List, Optional, Tuple

Expand Down Expand Up @@ -55,8 +56,15 @@ def script(workspace: Workspace, uri: str) -> Script:

def project(workspace: Workspace) -> Project:
"""Simplifies getting jedi project."""

extra_paths = getattr(workspace, "extra_paths", [])
for path in extra_paths:
if path not in sys.path:
sys.path.insert(0, path)

return Project(
path=workspace.root_path,
sys_path=sys.path,
smart_sys_path=True,
load_unsafe_extensions=False,
)
Expand Down
7 changes: 6 additions & 1 deletion jedi_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ def bf_initialize(self, params: InitializeParams) -> InitializeResult:
server.feature(TEXT_DOCUMENT_DID_CHANGE)(did_change)
if ip.initializationOptions_diagnostics_didSave:
server.feature(TEXT_DOCUMENT_DID_SAVE)(did_save)
return super().bf_initialize(params)
res = super().bf_initialize(params)

extraPaths = getattr(params.initializationOptions, 'extraPaths', [])
self.workspace.extra_paths = extraPaths

return res


class JediLanguageServer(LanguageServer):
Expand Down