Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove language IDs configuration file #2586

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
}
]
Expand Down
55 changes: 0 additions & 55 deletions language-ids.sublime-settings

This file was deleted.

8 changes: 8 additions & 0 deletions messages/2.4.0.txt
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 39 additions & 0 deletions plugin/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions plugin/core/types.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down
Loading