summaryrefslogtreecommitdiffstats
path: root/src/debputy/lsp/lsp_features.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/debputy/lsp/lsp_features.py')
-rw-r--r--src/debputy/lsp/lsp_features.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/debputy/lsp/lsp_features.py b/src/debputy/lsp/lsp_features.py
index b417dd3..8260675 100644
--- a/src/debputy/lsp/lsp_features.py
+++ b/src/debputy/lsp/lsp_features.py
@@ -8,6 +8,7 @@ from lsprotocol.types import (
DidChangeTextDocumentParams,
Diagnostic,
DidOpenTextDocumentParams,
+ SemanticTokensLegend,
)
try:
@@ -21,11 +22,20 @@ from debputy.lsp.text_util import on_save_trim_end_of_line_whitespace
C = TypeVar("C", bound=Callable)
+SEMANTIC_TOKENS_LEGEND = SemanticTokensLegend(
+ token_types=["keyword", "enumMember"],
+ token_modifiers=[],
+)
+SEMANTIC_TOKEN_TYPES_IDS = {
+ t: idx for idx, t in enumerate(SEMANTIC_TOKENS_LEGEND.token_types)
+}
DIAGNOSTIC_HANDLERS = {}
COMPLETER_HANDLERS = {}
HOVER_HANDLERS = {}
CODE_ACTION_HANDLERS = {}
+FOLDING_RANGE_HANDLERS = {}
+SEMANTIC_TOKENS_FULL_HANDLERS = {}
WILL_SAVE_WAIT_UNTIL_HANDLERS = {}
_ALIAS_OF = {}
@@ -111,6 +121,16 @@ def lsp_hover(file_formats: Union[str, Sequence[str]]) -> Callable[[C], C]:
return _registering_wrapper(file_formats, HOVER_HANDLERS)
+def lsp_folding_ranges(file_formats: Union[str, Sequence[str]]) -> Callable[[C], C]:
+ return _registering_wrapper(file_formats, FOLDING_RANGE_HANDLERS)
+
+
+def lsp_semantic_tokens_full(
+ file_formats: Union[str, Sequence[str]]
+) -> Callable[[C], C]:
+ return _registering_wrapper(file_formats, SEMANTIC_TOKENS_FULL_HANDLERS)
+
+
def lsp_standard_handler(file_formats: Union[str, Sequence[str]], topic: str) -> None:
res = _STANDARD_HANDLERS.get(topic)
if res is None:
@@ -171,6 +191,8 @@ def describe_lsp_features() -> None:
("code actions/quickfixes", CODE_ACTION_HANDLERS),
("completion suggestions", COMPLETER_HANDLERS),
("hover docs", HOVER_HANDLERS),
+ ("folding ranges", FOLDING_RANGE_HANDLERS),
+ ("semantic tokens", SEMANTIC_TOKENS_FULL_HANDLERS),
("on-save handler", WILL_SAVE_WAIT_UNTIL_HANDLERS),
]
print("LSP language IDs and their features:")