summaryrefslogtreecommitdiffstats
path: root/src/debputy/lsp/lsp_features.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/debputy/lsp/lsp_features.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/debputy/lsp/lsp_features.py b/src/debputy/lsp/lsp_features.py
index e7b4445..63e4cd2 100644
--- a/src/debputy/lsp/lsp_features.py
+++ b/src/debputy/lsp/lsp_features.py
@@ -19,6 +19,7 @@ from lsprotocol.types import (
Diagnostic,
DidOpenTextDocumentParams,
SemanticTokensLegend,
+ TEXT_DOCUMENT_FORMATTING,
)
from debputy.commands.debputy_cmd.context import CommandContext
@@ -61,9 +62,14 @@ CODE_ACTION_HANDLERS = {}
FOLDING_RANGE_HANDLERS = {}
SEMANTIC_TOKENS_FULL_HANDLERS = {}
WILL_SAVE_WAIT_UNTIL_HANDLERS = {}
+FORMAT_FILE_HANDLERS = {}
_ALIAS_OF = {}
_STANDARD_HANDLERS = {
+ TEXT_DOCUMENT_FORMATTING: (
+ FORMAT_FILE_HANDLERS,
+ on_save_trim_end_of_line_whitespace,
+ ),
TEXT_DOCUMENT_CODE_ACTION: (
CODE_ACTION_HANDLERS,
lambda ls, params: provide_standard_quickfixes_from_diagnostics(params),
@@ -145,6 +151,16 @@ def lsp_folding_ranges(file_formats: Union[str, Sequence[str]]) -> Callable[[C],
return _registering_wrapper(file_formats, FOLDING_RANGE_HANDLERS)
+def lsp_will_save_wait_until(
+ file_formats: Union[str, Sequence[str]]
+) -> Callable[[C], C]:
+ return _registering_wrapper(file_formats, WILL_SAVE_WAIT_UNTIL_HANDLERS)
+
+
+def lsp_format_document(file_formats: Union[str, Sequence[str]]) -> Callable[[C], C]:
+ return _registering_wrapper(file_formats, FORMAT_FILE_HANDLERS)
+
+
def lsp_semantic_tokens_full(
file_formats: Union[str, Sequence[str]]
) -> Callable[[C], C]:
@@ -214,6 +230,7 @@ def describe_lsp_features(context: CommandContext) -> None:
("folding ranges", FOLDING_RANGE_HANDLERS),
("semantic tokens", SEMANTIC_TOKENS_FULL_HANDLERS),
("on-save handler", WILL_SAVE_WAIT_UNTIL_HANDLERS),
+ ("format file handler", FORMAT_FILE_HANDLERS),
]
print("LSP language IDs and their features:")
all_ids = sorted(set(lid for _, t in feature_list for lid in t))