diff --git a/LSP-pyright.sublime-settings b/LSP-pyright.sublime-settings index d063b10..9f8829b 100644 --- a/LSP-pyright.sublime-settings +++ b/LSP-pyright.sublime-settings @@ -10,12 +10,8 @@ "settings": { // Use a predefined setup from this plugin, valid values are: // - "": An empty string does nothing. - // - "sublime_text": Suitable for people who are developing ST Python plugins. - // The Python version which the developed plugin runs on will be used. - // `sys.path` from plugin_host will be added into "python.analysis.extraPaths" - // so ST package dependecies can be resolved by the LSP server. - // - "sublime_text_33": Similar to "sublime_text" but Python 3.3 forced. - // - "sublime_text_38": Similar to "sublime_text" but Python 3.8 forced. + // - "sublime_text": Suitable for people who are developing ST python 3.3 plugins. `sys.path` from the plugin_host will be added into "python.analysis.extraPaths" so that ST package dependencies can be resolved by the LSP server. + // - "sublime_text_33": The same with using "sublime_text". "pyright.dev_environment": "", // Offer auto-import completions. "python.analysis.autoImportCompletions": true, diff --git a/plugin.py b/plugin.py index 67c69ee..360de2a 100644 --- a/plugin.py +++ b/plugin.py @@ -54,8 +54,8 @@ def on_settings_changed(self, settings: DottedDict) -> None: dev_environment = settings.get("pyright.dev_environment") extraPaths = settings.get("python.analysis.extraPaths") or [] # type: List[str] - if dev_environment in {"sublime_text", "sublime_text_33", "sublime_text_38"}: - py_ver = self.detect_st_py_ver(dev_environment) + if dev_environment in {"sublime_text", "sublime_text_33"}: + py_ver = (3, 3) # there is only py33 on ST 3 # add package dependencies into "python.analysis.extraPaths" extraPaths.extend(self.find_package_dependency_dirs(py_ver)) @@ -129,34 +129,6 @@ def patch_markdown_content(self, content: str) -> str: content = re.sub(r"\n:deprecated:", r"\n⚠️ __Deprecated:__", content) return content - def detect_st_py_ver(self, dev_environment: str) -> Tuple[int, int]: - st_packages_path = sublime.packages_path() - default = (3, 3) - - if dev_environment == "sublime_text_33": - return (3, 3) - if dev_environment == "sublime_text_38": - return (3, 8) - - if dev_environment == "sublime_text": - session = self.weaksession() - if not session: - return default - workspace_folders = session.get_workspace_folders() - if not workspace_folders: - return default - if workspace_folders[0].path == os.path.join(st_packages_path, "User"): - return (3, 8) - python_version_file = os.path.join(workspace_folders[0].path, ".python-version") - try: - with open(python_version_file, "r") as file: - if file.read().strip() == "3.8": - return (3, 8) - except Exception: - pass - - return default - @classmethod def get_plugin_setting(cls, key: str, default: Any = None) -> Any: return sublime.load_settings(cls.package_name + ".sublime-settings").get(key, default) diff --git a/sublime-package.json b/sublime-package.json index bd29dc0..f80b789 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -28,14 +28,12 @@ "enum": [ "", "sublime_text", - "sublime_text_33", - "sublime_text_38" + "sublime_text_33" ], "markdownEnumDescriptions": [ "No modifications applied.", - "Suitable for people who are developing ST python plugins. The Python version which the developed plugin runs on will be used. - `sys.path` from the plugin_host will be added into \"python.analysis.extraPaths\" so that ST package dependencies can be resolved by the LSP server.", - "Similar to \"sublime_text\" but Python 3.3 forced.", - "Similar to \"sublime_text\" but Python 3.8 forced." + "Suitable for people who are developing ST python plugins. `sys.path` from the plugin_host will be added into \"python.analysis.extraPaths\" so that ST package dependencies can be resolved by the LSP server.", + "The same with using \"sublime_text\".", ] }, // pyright