python server
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""Implementation of tool support over LSP."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import sysconfig
|
||||
import traceback
|
||||
from typing import Any, Optional, Sequence
|
||||
|
||||
|
||||
# **********************************************************
|
||||
# Update sys.path before importing any bundled libraries.
|
||||
# **********************************************************
|
||||
def update_sys_path(path_to_add: str, strategy: str) -> None:
|
||||
"""Add given path to `sys.path`."""
|
||||
if path_to_add not in sys.path and os.path.isdir(path_to_add):
|
||||
if strategy == "useBundled":
|
||||
sys.path.insert(0, path_to_add)
|
||||
elif strategy == "fromEnvironment":
|
||||
sys.path.append(path_to_add)
|
||||
|
||||
|
||||
# Ensure that we can import LSP libraries, and other bundled libraries.
|
||||
update_sys_path(
|
||||
os.fspath(pathlib.Path(__file__).parent.parent / "libs"),
|
||||
os.getenv("LS_IMPORT_STRATEGY", "useBundled"),
|
||||
)
|
||||
Reference in New Issue
Block a user