Skip to content

Commit 7dd08e8

Browse files
authored
Remove deprecated properties of ClientConfig (#2767)
1 parent deb7fbf commit 7dd08e8

5 files changed

Lines changed: 29 additions & 155 deletions

File tree

docs/src/client_configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Below is an example of the `LSP.sublime-settings` file with configurations for t
4141
| settings | per-project settings (equivalent to VS Code's Workspace Settings) |
4242
| initializationOptions | options to send to the server at startup (rarely used) |
4343
| selector | This is _the_ connection between your files and language servers. It's a selector that is matched against the current view's base scope. If the selector matches with the base scope of the the file, the associated language server is started. For more information, see https://www.sublimetext.com/docs/3/selectors.html |
44-
| priority_selector | Used to prioritize a certain language server when choosing which one to query on views with multiple servers active. Certain LSP actions have to pick which server to query and this setting can be used to decide which one to pick based on the current scopes at the cursor location. For example when having both HTML and PHP servers running on a PHP file, this can be used to give priority to the HTML one in HTML blocks and to PHP one otherwise. That would be done by setting "priority_selector" to `text.html` for HTML server and `source.php` to PHP server. Note: when the "priority_selector" is missing, it will be the same as the "document_selector".
44+
| priority_selector | Used to prioritize a certain language server when choosing which one to query on views with multiple servers active. Certain LSP actions have to pick which server to query and this setting can be used to decide which one to pick based on the current scopes at the cursor location. For example when having both HTML and PHP servers running on a PHP file, this can be used to give priority to the HTML one in HTML blocks and to PHP one otherwise. That would be done by setting "priority_selector" to `text.html` for HTML server and `source.php` to PHP server.
4545
| diagnostics_mode | Set to `"workspace"` (default is `"open_files"`) to ignore diagnostics for files that are not within the project (window) folders. If project has no folders then this option has no effect and diagnostics are shown for all files. If the server supports _pull diagnostics_ (`diagnosticProvider`), this setting also controls whether diagnostics are requested only for open files (`"open_files"`), or for all files in the project folders (`"workspace"`). |
4646
| tcp_port | see instructions below |
4747
| experimental_capabilities | Turn on experimental capabilities of a language server. This is a dictionary and differs per language server |

plugin/core/sessions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ def name(cls) -> str:
908908
@classmethod
909909
def configuration(cls) -> tuple[sublime.Settings, str]:
910910
"""
911-
Return the Settings object that defines the "command", "languages", and optionally the "initializationOptions",
912-
"default_settings", "env" and "tcp_port" as the first element in the tuple, and the path to the base settings
911+
Return the Settings object that defines the "command", "selector", and optionally the "initializationOptions",
912+
"env" and "tcp_port" as the first element in the tuple, and the path to the base settings
913913
filename as the second element in the tuple.
914914
915915
The second element in the tuple is used to handle "settings" overrides from users properly. For example, if your

plugin/core/types.py

Lines changed: 26 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -725,46 +725,43 @@ def __init__(
725725

726726

727727
class ClientConfig:
728-
def __init__(self,
729-
name: str,
730-
selector: str,
731-
priority_selector: str | None = None,
732-
schemes: list[str] | None = None,
733-
command: list[str] | None = None,
734-
binary_args: list[str] | None = None, # DEPRECATED
735-
tcp_port: int | None = None,
736-
auto_complete_selector: str | None = None,
737-
enabled: bool = True,
738-
init_options: DottedDict = DottedDict(),
739-
settings: DottedDict = DottedDict(),
740-
env: dict[str, str | list[str]] = {},
741-
experimental_capabilities: dict[str, Any] | None = None,
742-
disabled_capabilities: DottedDict = DottedDict(),
743-
file_watcher: FileWatcherConfig = {},
744-
semantic_tokens: dict[str, str] | None = None,
745-
diagnostics_mode: str = "open_files",
746-
path_maps: list[PathMap] | None = None) -> None:
728+
def __init__(
729+
self,
730+
name: str,
731+
selector: str,
732+
priority_selector: str | None = None,
733+
schemes: list[str] | None = None,
734+
command: list[str] | None = None,
735+
tcp_port: int | None = None,
736+
auto_complete_selector: str | None = None,
737+
enabled: bool = True,
738+
init_options: DottedDict | None = None,
739+
settings: DottedDict | None = None,
740+
env: dict[str, str | list[str]] | None = None,
741+
experimental_capabilities: dict[str, Any] | None = None,
742+
disabled_capabilities: DottedDict | None = None,
743+
file_watcher: FileWatcherConfig | None = None,
744+
semantic_tokens: dict[str, str] | None = None,
745+
diagnostics_mode: str = "open_files",
746+
path_maps: list[PathMap] | None = None
747+
) -> None:
747748
self.name = name
748749
self.selector = selector
749750
self.priority_selector = priority_selector if priority_selector else self.selector
750751
if isinstance(schemes, list):
751752
self.schemes: list[str] = schemes
752753
else:
753754
self.schemes = ["file"]
754-
if isinstance(command, list):
755-
self.command = command
756-
else:
757-
assert isinstance(binary_args, list)
758-
self.command = binary_args
755+
self.command = command
759756
self.tcp_port = tcp_port
760757
self.auto_complete_selector = auto_complete_selector
761758
self.enabled = enabled
762-
self.init_options = init_options
763-
self.settings = settings
764-
self.env = env
759+
self.init_options = init_options or DottedDict()
760+
self.settings = settings or DottedDict()
761+
self.env = env or {}
765762
self.experimental_capabilities = experimental_capabilities
766-
self.disabled_capabilities = disabled_capabilities
767-
self.file_watcher = file_watcher
763+
self.disabled_capabilities = disabled_capabilities or DottedDict()
764+
self.file_watcher = file_watcher or {}
768765
self.path_maps = path_maps
769766
self.status_key = f"lsp_{self.name}"
770767
self.semantic_tokens = semantic_tokens
@@ -970,88 +967,16 @@ def __eq__(self, other: Any) -> bool:
970967

971968

972969
def _read_selector(config: sublime.Settings | dict[str, Any]) -> str:
973-
# Best base scenario,
974970
selector = config.get("selector")
975971
if isinstance(selector, str):
976972
return selector
977-
# Otherwise, look for "languages": [...]
978-
languages = config.get("languages")
979-
if isinstance(languages, list):
980-
selectors = []
981-
for language in languages:
982-
# First priority is document_selector,
983-
document_selector = language.get("document_selector")
984-
if isinstance(document_selector, str):
985-
selectors.append(document_selector)
986-
continue
987-
# After that syntaxes has priority,
988-
syntaxes = language.get("syntaxes")
989-
if isinstance(syntaxes, list):
990-
for path in syntaxes:
991-
syntax = sublime.syntax_from_path(path)
992-
if syntax:
993-
selectors.append(syntax.scope)
994-
continue
995-
# No syntaxes and no document_selector... then there must exist a languageId.
996-
language_id = language.get("languageId")
997-
if isinstance(language_id, str):
998-
selectors.append(f"source.{language_id}")
999-
return "|".join(map("({})".format, selectors))
1000-
# Otherwise, look for "document_selector"
1001-
document_selector = config.get("document_selector")
1002-
if isinstance(document_selector, str):
1003-
return document_selector
1004-
# Otherwise, look for "syntaxes": [...]
1005-
syntaxes = config.get("syntaxes")
1006-
if isinstance(syntaxes, list):
1007-
selectors = []
1008-
for path in syntaxes:
1009-
syntax = sublime.syntax_from_path(path)
1010-
if syntax:
1011-
selectors.append(syntax.scope)
1012-
return "|".join(selectors)
1013-
# No syntaxes and no document_selector... then there must exist a languageId.
1014-
if language_id := config.get("languageId"):
1015-
return f"source.{language_id}"
1016973
return ""
1017974

1018975

1019976
def _read_priority_selector(config: sublime.Settings | dict[str, Any]) -> str:
1020-
# Best case scenario
1021977
selector = config.get("priority_selector")
1022978
if isinstance(selector, str):
1023979
return selector
1024-
# Otherwise, look for "languages": [...]
1025-
languages = config.get("languages")
1026-
if isinstance(languages, list):
1027-
selectors = []
1028-
for language in languages:
1029-
# First priority is feature_selector.
1030-
feature_selector = language.get("feature_selector")
1031-
if isinstance(feature_selector, str):
1032-
selectors.append(feature_selector)
1033-
continue
1034-
# After that scopes has priority.
1035-
scopes = language.get("scopes")
1036-
if isinstance(scopes, list):
1037-
selectors.extend(scopes)
1038-
continue
1039-
# No scopes and no feature_selector. So there must be a languageId
1040-
language_id = language.get("languageId")
1041-
if isinstance(language_id, str):
1042-
selectors.append(f"source.{language_id}")
1043-
return "|".join(map("({})".format, selectors))
1044-
# Otherwise, look for "feature_selector"
1045-
feature_selector = config.get("feature_selector")
1046-
if isinstance(feature_selector, str):
1047-
return feature_selector
1048-
# Otherwise, look for "scopes": [...]
1049-
scopes = config.get("scopes")
1050-
if isinstance(scopes, list):
1051-
return "|".join(map("({})".format, scopes))
1052-
# No scopes and no feature_selector... then there must exist a languageId
1053-
if language_id := config.get("languageId"):
1054-
return f"source.{language_id}"
1055980
return ""
1056981

1057982

sublime-package.json

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
},
3737
"markdownDescription": "A dictionary of code action identifiers that should be triggered on save.\n\nCode action identifiers are not officially standardized so refer to specific server's documentation on what is supported but `source.fixAll` is commonly used to apply fix-on-save code actions.\n\nThis option is also supported in syntax-specific settings and/or in the `\"settings\"` section of project files. Settings from all those places will be merged and more specific (syntax and project) settings will override less specific (from LSP or Sublime settings).\n\nOnly \"source.*\" actions are supported."
3838
},
39-
// Deprecated syntaxes and scopes
40-
"useSelectorInstead": {
41-
"type": "string",
42-
"deprecationMessage": "Use the \"selector\" key instead."
43-
},
4439
"FileWatcher": {
4540
"type": "object",
4641
"examples": [
@@ -380,30 +375,9 @@
380375
"env": {
381376
"$ref": "#/definitions/ClientEnv"
382377
},
383-
"languageId": {
384-
"$ref": "#/definitions/useSelectorInstead"
385-
},
386-
"document_selector": {
387-
"$ref": "#/definitions/useSelectorInstead"
388-
},
389-
"feature_selector": {
390-
"$ref": "#/definitions/useSelectorInstead"
391-
},
392378
"diagnostics_mode": {
393379
"$ref": "#/definitions/ClientDiagnosticsMode"
394380
},
395-
"syntaxes": {
396-
"type": "array",
397-
"$ref": "#/definitions/useSelectorInstead"
398-
},
399-
"scopes": {
400-
"type": "array",
401-
"$ref": "#/definitions/useSelectorInstead"
402-
},
403-
"languages": {
404-
"type": "array",
405-
"$ref": "#/definitions/useSelectorInstead"
406-
}
407381
}
408382
},
409383
"SemanticTokens": {

tests/test_configs.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,6 @@
1717

1818
class ConfigParsingTests(DeferrableTestCase):
1919

20-
def test_can_parse_old_client_settings(self):
21-
settings = {
22-
"command": ["pyls"],
23-
"scopes": ["text.html.vue"],
24-
"syntaxes": ["Packages/Python/Python.sublime-syntax"], # it should use this one
25-
"languageId": "java"
26-
}
27-
config = read_client_config("pyls", settings)
28-
self.assertEqual(config.selector, "source.python")
29-
self.assertEqual(config.priority_selector, "(text.html.vue)")
30-
31-
def test_can_parse_client_settings_with_languages(self):
32-
settings = {
33-
"command": ["pyls"],
34-
# Check that "selector" will be "source.python"
35-
"languages": [{"languageId": "python"}]
36-
}
37-
config = read_client_config("pyls", settings)
38-
self.assertEqual(config.selector, "(source.python)")
39-
self.assertEqual(config.priority_selector, "(source.python)")
40-
4120
def test_can_parse_settings_with_selector(self):
4221
settings = {
4322
"command": ["pyls"],
@@ -50,8 +29,6 @@ def test_can_parse_settings_with_selector(self):
5029
def test_can_update_config(self):
5130
settings = {
5231
"command": ["pyls"],
53-
"document_selector": "source.python",
54-
"languageId": "python"
5532
}
5633
config = read_client_config("pyls", settings)
5734
config = update_client_config(config, {"enabled": True})
@@ -65,8 +42,6 @@ def test_can_read_experimental_capabilities(self):
6542
}
6643
settings = {
6744
"command": ["pyls"],
68-
"document_selector": "source.python",
69-
"languageId": "python",
7045
"experimental_capabilities": experimental_capabilities
7146
}
7247
config = read_client_config("pyls", settings)

0 commit comments

Comments
 (0)