From 91298e466b0b02f38a75c6bed8c120f4035a335d Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Tue, 15 Oct 2024 20:34:24 +0800 Subject: [PATCH] :poop: Disable formatting temporarily https://github.com/termux/termux-language-server/issues/19#issuecomment-2413779969 --- .pre-commit-config.yaml | 8 ++++---- src/termux_language_server/server.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fce48f3..c645c3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: ^templates/|\.json$ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: fix-byte-order-marker @@ -51,7 +51,7 @@ repos: exclude_types: - zsh - repo: https://github.com/rhysd/actionlint - rev: v1.7.2 + rev: v1.7.3 hooks: - id: actionlint - repo: https://github.com/adrienverge/yamllint @@ -83,12 +83,12 @@ repos: hooks: - id: shfmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.7 + rev: v0.6.9 hooks: - id: ruff - id: ruff-format - repo: https://github.com/kumaraditya303/mirrors-pyright - rev: v1.1.381 + rev: v1.1.383 hooks: - id: pyright diff --git a/src/termux_language_server/server.py b/src/termux_language_server/server.py index 9eb134d..8b72652 100644 --- a/src/termux_language_server/server.py +++ b/src/termux_language_server/server.py @@ -14,7 +14,7 @@ TEXT_DOCUMENT_DID_CHANGE, TEXT_DOCUMENT_DID_OPEN, TEXT_DOCUMENT_DOCUMENT_LINK, - TEXT_DOCUMENT_FORMATTING, + # TEXT_DOCUMENT_FORMATTING, TEXT_DOCUMENT_HOVER, CompletionItem, CompletionItemKind, @@ -86,7 +86,8 @@ def did_change(params: DidChangeTextDocumentParams) -> None: diagnostics += namcap(document.path, document.source) self.publish_diagnostics(params.text_document.uri, diagnostics) - @self.feature(TEXT_DOCUMENT_FORMATTING) + # https://github.com/termux/termux-language-server/issues/19#issuecomment-2413779969 + # @self.feature(TEXT_DOCUMENT_FORMATTING) def format(params: DocumentFormattingParams) -> list[TextEdit]: r"""Format. @@ -177,6 +178,7 @@ def hover(params: TextDocumentPositionParams) -> Hover | None: if ( parent.type == "array" and parent.parent is not None + and parent.parent.children[0].text is not None and parent.parent.children[0].text.decode() in PACKAGE_VARIABLES.get(filetype, set()) ): @@ -230,6 +232,7 @@ def completions(params: CompletionParams) -> CompletionList: if ( parent.type == "array" and parent.parent is not None + and parent.parent.children[0].text is not None and parent.parent.children[0].text.decode() in PACKAGE_VARIABLES.get(filetype, set()) ): @@ -250,7 +253,11 @@ def completions(params: CompletionParams) -> CompletionList: ], ) schema = get_schema(filetype) - if parent.type == "array" and parent.parent is not None: + if ( + parent.type == "array" + and parent.parent is not None + and parent.parent.children[0].text is not None + ): property = schema["properties"].get( parent.parent.children[0].text.decode(), {} )