diff --git a/Default.sublime-commands b/Default.sublime-commands index 75bb04d95..f71d37a06 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -16,15 +16,6 @@ "default": "[\n\t$0\n]\n", } }, - { - "caption": "Preferences: LSP Language ID Mapping Overrides", - "command": "edit_settings", - "args": { - "base_file": "${packages}/LSP/language-ids.sublime-settings", - "user_file": "${packages}/User/language-ids.sublime-settings", - "default": "// SublimeText base scope -> LSP Language ID overrides\n{\n\t// \"source.mylanguage\": \"mylang\"\n\t$0\n}\n" - } - }, { "caption": "Preferences: LSP Utils Settings", "command": "edit_settings", diff --git a/Main.sublime-menu b/Main.sublime-menu index 6eef29d01..17e54d041 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -307,15 +307,6 @@ "default": "[\n\t$0\n]\n", } }, - { - "caption": "Base Scope to Language ID Mapping", - "command": "edit_settings", - "args": { - "base_file": "${packages}/LSP/language-ids.sublime-settings", - "user_file": "${packages}/User/language-ids.sublime-settings", - "default": "// SublimeText base scope -> LSP Language ID overrides\n{\n\t// \"source.mylanguage\": \"mylang\"\n\t$0\n}\n" - } - } ] } ] diff --git a/language-ids.sublime-settings b/language-ids.sublime-settings deleted file mode 100644 index 4f59059ec..000000000 --- a/language-ids.sublime-settings +++ /dev/null @@ -1,55 +0,0 @@ -// -// SublimeText base scope -> Language ID -// ------------------------------------- -// -// These are the "exceptional" base scopes. If a base scope is not in this -// map, nor the first two components or more match any of the entries here, then -// the rule is that we split the base scope on the ".", and take -// the second component. The resulting string is assumed to be the language ID. -// -// Examples: -// -// source.c++ -> cpp -// source.rust -> rust -// text.tex.latex -> latex -// -// The official list is maintained at -// https://microsoft.github.io/language-server-protocol/specification#textDocumentItem -// -// By virtue of this being a .sublime-settings file, you can make overrides to -// to this file in your Packages/User/ directory. Consider to submit a pull -// request at github.com/sublimelsp/LSP if you believe an entry is missing. -{ - "source.c++": "cpp", - "source.coffee": "coffeescript", - "source.cs": "csharp", - "source.dosbatch": "bat", - "source.fixedform-fortran": "fortran", // https://packagecontrol.io/packages/Fortran - "source.js": "javascript", - "source.js.react": "javascriptreact", // https://github.com/Thom1729/Sublime-JS-Custom - "source.json-tmlanguage": "jsonc", // https://github.com/SublimeText/PackageDev - "source.json.sublime": "jsonc", // https://github.com/SublimeText/PackageDev - "source.jsx": "javascriptreact", - "source.Kotlin": "kotlin", // https://github.com/vkostyukov/kotlin-sublime-package - "source.modern-fortran": "fortran", // https://packagecontrol.io/packages/Fortran - "source.objc": "objective-c", - "source.objc++": "objective-cpp", - "source.shader": "shaderlab", // https://github.com/waqiju/unity_shader_st3 - "source.shell": "shellscript", - "source.ts": "typescript", - "source.ts.react": "typescriptreact", // https://github.com/Thom1729/Sublime-JS-Custom - "source.tsx": "typescriptreact", - "source.unity.unity_shader": "shaderlab", // https://github.com/petereichinger/Unity3D-Shader - "source.yaml-tmlanguage": "yaml", // https://github.com/SublimeText/PackageDev - "text.advanced_csv": "csv", // https://github.com/SublimeText/AFileIcon - "text.django": "html", // https://github.com/willstott101/django-sublime-syntax - "text.html.handlebars": "handlebars", - "text.html.markdown": "markdown", - "text.html.markdown.rmarkdown": "r", // https://github.com/REditorSupport/sublime-ide-r - "text.html.vue": "vue", - "text.jinja": "html", // https://github.com/Sublime-Instincts/BetterJinja - "text.plain": "plaintext", - "text.plist": "xml", // https://bitbucket.org/fschwehn/sublime_plist - "text.tex.latex": "latex", - "text.xml.xsl": "xsl", -} diff --git a/messages/2.4.0.txt b/messages/2.4.0.txt new file mode 100644 index 000000000..c573d996b --- /dev/null +++ b/messages/2.4.0.txt @@ -0,0 +1,8 @@ +=> 2.4.0 + +# Breaking changes + +- The language-ids.sublime-settings configuration file was removed. Instead, the language IDs are + hardcoded now. Language IDs are used by servers which handle more than one language to avoid + re-interpreting file extensions. If you used the configuration file and think that a language ID + is wrong or missing, please create an issue at https://github.com/sublimelsp/LSP/issues. diff --git a/plugin/core/constants.py b/plugin/core/constants.py index bca52cff2..80d252cf3 100644 --- a/plugin/core/constants.py +++ b/plugin/core/constants.py @@ -178,6 +178,45 @@ class RegionKey(StrEnum): DocumentHighlightKind.Write: "region.yellowish markup.highlight.write.lsp" } +# These are the "exceptional" base scopes. If a base scope is not in this map, nor the first two components or more +# match any of the entries here, then the rule is that we split the base scope on the ".", and take the second +# component. The resulting string is assumed to be the language ID. The official list is maintained at +# https://microsoft.github.io/language-server-protocol/specification#textDocumentItem +LANGUAGE_IDENTIFIERS = { + "source.c++": "cpp", + "source.coffee": "coffeescript", + "source.cs": "csharp", + "source.dosbatch": "bat", + "source.fixedform-fortran": "fortran", # https://packagecontrol.io/packages/Fortran + "source.js": "javascript", + "source.js.react": "javascriptreact", # https://github.com/Thom1729/Sublime-JS-Custom + "source.json-tmlanguage": "jsonc", # https://github.com/SublimeText/PackageDev + "source.json.sublime": "jsonc", # https://github.com/SublimeText/PackageDev + "source.jsx": "javascriptreact", + "source.Kotlin": "kotlin", # https://github.com/vkostyukov/kotlin-sublime-package + "source.modern-fortran": "fortran", # https://packagecontrol.io/packages/Fortran + "source.objc": "objective-c", + "source.objc++": "objective-cpp", + "source.shader": "shaderlab", # https://github.com/waqiju/unity_shader_st3 + "source.shell": "shellscript", + "source.ts": "typescript", + "source.ts.react": "typescriptreact", # https://github.com/Thom1729/Sublime-JS-Custom + "source.tsx": "typescriptreact", + "source.unity.unity_shader": "shaderlab", # https://github.com/petereichinger/Unity3D-Shader + "source.yaml-tmlanguage": "yaml", # https://github.com/SublimeText/PackageDev + "text.advanced_csv": "csv", # https://github.com/SublimeText/AFileIcon + "text.django": "html", # https://github.com/willstott101/django-sublime-syntax + "text.html.handlebars": "handlebars", + "text.html.markdown": "markdown", + "text.html.markdown.rmarkdown": "r", # https://github.com/REditorSupport/sublime-ide-r + "text.html.vue": "vue", + "text.jinja": "html", # https://github.com/Sublime-Instincts/BetterJinja + "text.plain": "plaintext", + "text.plist": "xml", # https://bitbucket.org/fschwehn/sublime_plist + "text.tex.latex": "latex", + "text.xml.xsl": "xsl", +} + SEMANTIC_TOKENS_MAP = { "namespace": "variable.other.namespace.lsp", "namespace.declaration": "entity.name.namespace.lsp", diff --git a/plugin/core/types.py b/plugin/core/types.py index b5d5b932f..52fe1dcba 100644 --- a/plugin/core/types.py +++ b/plugin/core/types.py @@ -1,5 +1,6 @@ from __future__ import annotations from .collections import DottedDict +from .constants import LANGUAGE_IDENTIFIERS from .file_watcher import FileWatcherEventType from .logging import debug, set_debug_logging from .protocol import ServerCapabilities, TextDocumentSyncKind, TextDocumentSyncOptions @@ -34,13 +35,12 @@ def basescope2languageid(base_scope: str) -> str: - # This the connection between Language IDs and ST selectors. - base_scope_map = sublime.load_settings("language-ids.sublime-settings") + # This is the connection between Language IDs and ST selectors. result = "" # Try to find exact match or less specific match consisting of at least 2 components. scope_parts = base_scope.split('.') while len(scope_parts) >= 2: - result = base_scope_map.get('.'.join(scope_parts)) + result = LANGUAGE_IDENTIFIERS.get('.'.join(scope_parts)) if result: break scope_parts.pop()