-
Notifications
You must be signed in to change notification settings - Fork 5
/
plugin.py
36 lines (27 loc) · 1.06 KB
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from LSP.plugin.core.typing import Dict
from lsp_utils.pip_client_handler import PipClientHandler
import os
import sublime
class Pylsp(PipClientHandler):
package_name = __package__
requirements_txt_path = "requirements.txt"
server_filename = "pylsp"
# --- PipClientHandler handlers ------------------------------------------------------------------------------------
@classmethod
def get_python_binary(cls) -> str:
settings = sublime.load_settings('{}.sublime-settings'.format(cls.package_name))
python_binary = settings.get('python_binary')
if python_binary and isinstance(python_binary, str):
return python_binary
return super().get_python_binary()
@classmethod
def get_additional_variables(cls) -> Dict[str, str]:
variables = super().get_additional_variables()
variables.update({
"sublime_py_files_dir": os.path.dirname(sublime.__file__),
})
return variables
def plugin_loaded() -> None:
Pylsp.setup()
def plugin_unloaded() -> None:
Pylsp.cleanup()