chore(lsprotocol): migrate to 2025.0.0 and cleanup artifacts
The changes align the project with the 2025.0.0 lsprotocol release, removing the old backport and updating type hints in the protocol hooks to use Sequence where appropriate. The dist-info and packaging metadata for older lsprotocol versions are replaced with the new 2025.0.0 artifacts. - Remove exceptiongroup backport used on Python <3.11 - Use Sequence instead of List in LS protocol hooks - Replace old dist-info with 2025.0.0 metadata
This commit is contained in:
+19
-11
@@ -42,7 +42,7 @@ import lsp_jsonrpc as jsonrpc
|
||||
import lsprotocol.types as lsp
|
||||
from common.load_data import standard_items
|
||||
from lsp_tclserver import TclLanguageServer
|
||||
from pygls import uris, workspace
|
||||
from pygls import uris
|
||||
from pygls.workspace.text_document import TextDocument
|
||||
from tools.folding_ranges import build_folding_ranges
|
||||
from tools.inlay_hint import (
|
||||
@@ -575,7 +575,7 @@ def prepare_rename(params: lsp.PrepareRenameParams):
|
||||
indexes, definitions, occurrence, identity = context
|
||||
if not _is_renamable(identity, indexes, definitions):
|
||||
return None
|
||||
return lsp.PrepareRenameResult_Type1(
|
||||
return lsp.PrepareRenamePlaceholder(
|
||||
range=occurrence.range, placeholder=occurrence.placeholder
|
||||
)
|
||||
|
||||
@@ -822,7 +822,7 @@ def _get_settings_by_path(file_path: pathlib.Path):
|
||||
return setting_values[0]
|
||||
|
||||
|
||||
def _get_document_key(document: workspace.Document):
|
||||
def _get_document_key(document: TextDocument):
|
||||
if WORKSPACE_SETTINGS:
|
||||
document_workspace = pathlib.Path(document.path)
|
||||
workspaces = {s["workspaceFS"] for s in WORKSPACE_SETTINGS.values()}
|
||||
@@ -836,7 +836,7 @@ def _get_document_key(document: workspace.Document):
|
||||
return None
|
||||
|
||||
|
||||
def _get_settings_by_document(document: workspace.Document | None):
|
||||
def _get_settings_by_document(document: TextDocument | None):
|
||||
if document is None or document.path is None:
|
||||
return list(WORKSPACE_SETTINGS.values())[0]
|
||||
|
||||
@@ -860,25 +860,33 @@ def _get_settings_by_document(document: workspace.Document | None):
|
||||
def log_to_output(
|
||||
message: str, msg_type: lsp.MessageType = lsp.MessageType.Log
|
||||
) -> None:
|
||||
LSP_SERVER.show_message_log(message, msg_type)
|
||||
LSP_SERVER.window_log_message(
|
||||
lsp.LogMessageParams(message=message, type=msg_type)
|
||||
)
|
||||
|
||||
|
||||
def log_error(message: str) -> None:
|
||||
LSP_SERVER.show_message_log(message, lsp.MessageType.Error)
|
||||
log_to_output(message, lsp.MessageType.Error)
|
||||
if os.getenv("LS_SHOW_NOTIFICATION", "off") in ["onError", "onWarning", "always"]:
|
||||
LSP_SERVER.show_message(message, lsp.MessageType.Error)
|
||||
LSP_SERVER.window_show_message(
|
||||
lsp.ShowMessageParams(message=message, type=lsp.MessageType.Error)
|
||||
)
|
||||
|
||||
|
||||
def log_warning(message: str) -> None:
|
||||
LSP_SERVER.show_message_log(message, lsp.MessageType.Warning)
|
||||
log_to_output(message, lsp.MessageType.Warning)
|
||||
if os.getenv("LS_SHOW_NOTIFICATION", "off") in ["onWarning", "always"]:
|
||||
LSP_SERVER.show_message(message, lsp.MessageType.Warning)
|
||||
LSP_SERVER.window_show_message(
|
||||
lsp.ShowMessageParams(message=message, type=lsp.MessageType.Warning)
|
||||
)
|
||||
|
||||
|
||||
def log_always(message: str) -> None:
|
||||
LSP_SERVER.show_message_log(message, lsp.MessageType.Info)
|
||||
log_to_output(message, lsp.MessageType.Info)
|
||||
if os.getenv("LS_SHOW_NOTIFICATION", "off") in ["always"]:
|
||||
LSP_SERVER.show_message(message, lsp.MessageType.Info)
|
||||
LSP_SERVER.window_show_message(
|
||||
lsp.ShowMessageParams(message=message, type=lsp.MessageType.Info)
|
||||
)
|
||||
|
||||
|
||||
# *****************************************************
|
||||
|
||||
@@ -6,7 +6,8 @@ from typing import List, Optional, Tuple
|
||||
|
||||
import lsprotocol.types as lsp
|
||||
from plugins.poco_plugin import commands
|
||||
from pygls import server, uris
|
||||
from pygls import uris
|
||||
from pygls.lsp.server import LanguageServer
|
||||
from pygls.workspace.text_document import TextDocument
|
||||
from tclint.format import FormatterOpts
|
||||
from tclint.lexer import TclSyntaxError
|
||||
@@ -23,7 +24,7 @@ DIAGNOSTIC_SOURCE = "nx-post-support"
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TclLanguageServer(server.LanguageServer):
|
||||
class TclLanguageServer(LanguageServer):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.parser = parser.CustomParser()
|
||||
|
||||
Reference in New Issue
Block a user