Skip to content

Commit ecf23ee

Browse files
Deprecate language IDs configuration file (#2586)
* Remove language IDs configuration file * make this a non breaking change * fix typos * tweak wording * remove comment --------- Co-authored-by: Предраг Николић <[email protected]>
1 parent c6a03e5 commit ecf23ee

File tree

7 files changed

+58
-74
lines changed

7 files changed

+58
-74
lines changed

Default.sublime-commands

-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
"default": "[\n\t$0\n]\n",
1717
}
1818
},
19-
{
20-
"caption": "Preferences: LSP Language ID Mapping Overrides",
21-
"command": "edit_settings",
22-
"args": {
23-
"base_file": "${packages}/LSP/language-ids.sublime-settings",
24-
"user_file": "${packages}/User/language-ids.sublime-settings",
25-
"default": "// SublimeText base scope -> LSP Language ID overrides\n{\n\t// \"source.mylanguage\": \"mylang\"\n\t$0\n}\n"
26-
}
27-
},
2819
{
2920
"caption": "Preferences: LSP Utils Settings",
3021
"command": "edit_settings",

Main.sublime-menu

-9
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,6 @@
307307
"default": "[\n\t$0\n]\n",
308308
}
309309
},
310-
{
311-
"caption": "Base Scope to Language ID Mapping",
312-
"command": "edit_settings",
313-
"args": {
314-
"base_file": "${packages}/LSP/language-ids.sublime-settings",
315-
"user_file": "${packages}/User/language-ids.sublime-settings",
316-
"default": "// SublimeText base scope -> LSP Language ID overrides\n{\n\t// \"source.mylanguage\": \"mylang\"\n\t$0\n}\n"
317-
}
318-
}
319310
]
320311
}
321312
]

boot.py

+7
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,14 @@ def plugin_loaded() -> None:
199199
windows.enable()
200200
_register_all_plugins()
201201
client_configs.update_configs()
202+
# TODO: remove this in the next minor release
203+
base_scope_map = sublime.load_settings("language-ids.sublime-settings")
204+
if base_scope_map.to_dict():
205+
def show_warning():
206+
print("LSP - The language-ids.sublime-settings file is deprecated, but it looks like you have it.\nSee the migration guide -> https://github.com/sublimelsp/LSP/issues/2592")
207+
sublime.status_message("LSP - The language-ids.sublime-settings file is deprecated. Open the Console for details.")
202208

209+
sublime.set_timeout(show_warning, 5_000)
203210

204211
def plugin_unloaded() -> None:
205212
_unregister_all_plugins()

language-ids.sublime-settings

-55
This file was deleted.

messages/2.4.0.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=> 2.4.0
2+
3+
# Breaking changes
4+
5+
- The language-ids.sublime-settings configuration file has been deprecated and will be removed in the next minor release of LSP. The language IDs are
6+
hardcoded now. Language IDs are used by servers which handle more than one language to avoid
7+
re-interpreting file extensions. If you used the configuration file and think that a language ID
8+
is wrong or missing, please follow this migration guide https://github.com/sublimelsp/LSP/issues/2592.

plugin/core/constants.py

+39
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,45 @@ class RegionKey(StrEnum):
178178
DocumentHighlightKind.Write: "region.yellowish markup.highlight.write.lsp"
179179
}
180180

181+
# These are the "exceptional" base scopes. If a base scope is not in this map, nor the first two components or more
182+
# match any of the entries here, then the rule is that we split the base scope on the ".", and take the second
183+
# component. The resulting string is assumed to be the language ID. The official list is maintained at
184+
# https://microsoft.github.io/language-server-protocol/specification#textDocumentItem
185+
LANGUAGE_IDENTIFIERS = {
186+
"source.c++": "cpp",
187+
"source.coffee": "coffeescript",
188+
"source.cs": "csharp",
189+
"source.dosbatch": "bat",
190+
"source.fixedform-fortran": "fortran", # https://packagecontrol.io/packages/Fortran
191+
"source.js": "javascript",
192+
"source.js.react": "javascriptreact", # https://github.com/Thom1729/Sublime-JS-Custom
193+
"source.json-tmlanguage": "jsonc", # https://github.com/SublimeText/PackageDev
194+
"source.json.sublime": "jsonc", # https://github.com/SublimeText/PackageDev
195+
"source.jsx": "javascriptreact",
196+
"source.Kotlin": "kotlin", # https://github.com/vkostyukov/kotlin-sublime-package
197+
"source.modern-fortran": "fortran", # https://packagecontrol.io/packages/Fortran
198+
"source.objc": "objective-c",
199+
"source.objc++": "objective-cpp",
200+
"source.shader": "shaderlab", # https://github.com/waqiju/unity_shader_st3
201+
"source.shell": "shellscript",
202+
"source.ts": "typescript",
203+
"source.ts.react": "typescriptreact", # https://github.com/Thom1729/Sublime-JS-Custom
204+
"source.tsx": "typescriptreact",
205+
"source.unity.unity_shader": "shaderlab", # https://github.com/petereichinger/Unity3D-Shader
206+
"source.yaml-tmlanguage": "yaml", # https://github.com/SublimeText/PackageDev
207+
"text.advanced_csv": "csv", # https://github.com/SublimeText/AFileIcon
208+
"text.django": "html", # https://github.com/willstott101/django-sublime-syntax
209+
"text.html.handlebars": "handlebars",
210+
"text.html.markdown": "markdown",
211+
"text.html.markdown.rmarkdown": "r", # https://github.com/REditorSupport/sublime-ide-r
212+
"text.html.vue": "vue",
213+
"text.jinja": "html", # https://github.com/Sublime-Instincts/BetterJinja
214+
"text.plain": "plaintext",
215+
"text.plist": "xml", # https://bitbucket.org/fschwehn/sublime_plist
216+
"text.tex.latex": "latex",
217+
"text.xml.xsl": "xsl",
218+
}
219+
181220
SEMANTIC_TOKENS_MAP = {
182221
"namespace": "variable.other.namespace.lsp",
183222
"namespace.declaration": "entity.name.namespace.lsp",

plugin/core/types.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22
from .collections import DottedDict
3+
from .constants import LANGUAGE_IDENTIFIERS
34
from .file_watcher import FileWatcherEventType
45
from .logging import debug, set_debug_logging
56
from .protocol import ServerCapabilities, TextDocumentSyncKind, TextDocumentSyncOptions
@@ -39,8 +40,10 @@ def basescope2languageid(base_scope: str) -> str:
3940
result = ""
4041
# Try to find exact match or less specific match consisting of at least 2 components.
4142
scope_parts = base_scope.split('.')
43+
# TODO: remove base_scope_map in the next minor release
44+
language_map = {**LANGUAGE_IDENTIFIERS, **base_scope_map.to_dict()}
4245
while len(scope_parts) >= 2:
43-
result = base_scope_map.get('.'.join(scope_parts))
46+
result = language_map.get('.'.join(scope_parts))
4447
if result:
4548
break
4649
scope_parts.pop()

0 commit comments

Comments
 (0)