Bug 506664 - kate send some requests to the Language Server that Language Server did not announce support in its capabilities
Summary: kate send some requests to the Language Server that Language Server did not a...
Status: REPORTED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 25.04.2
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-06 07:36 UTC by niels
Modified: 2025-07-06 11:34 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description niels 2025-07-06 07:36:59 UTC
SUMMARY
The `kate` editor sends LSP requests to the language server without any regards for the server capabilities.


STEPS TO REPRODUCE
1. Open a file format with a language server that does not support `textDocument/definition` or/and `workspace/symbol` or/and `textDocument/rangeFormatting`
2a. To trigger `textDocument/definition`,  I am not entirely sure what does it. It sometimes just appear while I am working. I am suspecting copy-paste (`CTRL + C`) or scrolling. However, I cannot figure out a reliable trigger - just that it happens "often" while I work on the document.
2b. To trigger `workspace/symbol`, use the `Search and Go to symbol` feature (Right click in the doc, Expand `LSP Client`, then pick the  `Search and Go to symbol` ).
2c. To trigger `textDocument/rangeFormatting`, I had the `kate` setup to use the language server for formatting, with `Format on Save` on in the LSP settings, then marked a range and hit `CTRL+S`. Probably there is a simpler way to trigger this.

Note: The reproducers lists 

OBSERVED RESULT
The `kate` editor will send the request to the server. The Language server will complain about receiving a request that it does not support in the `Output` tab (or crash or silently ignore it depending on the language server and how they decided to implement it)


EXPECTED RESULT
The `kate` editor should not send these requests, since the server has not announced support for them in the server capabilities. Additionally, it would make sense for `kate` to disable UI elements that depend on this feature without a fallback. As an example, `Search and Go to symbol` might need to be disabled in the menu.

For `textDocument/rangeFormatting`, having `kate` fallback to format the entire document would work for the "on save"-triggered formatting (since the language server in question supports full document formatting). Though other instances / ways to trigger that request might need a different strategy.

SOFTWARE/OS VERSIONS
Debian/testing version of kate (25.04.2). Though, I believe this is would not be an OS specific issue and the LSP plugin code is in `kate` (plasma and KDE would be irrelevant as well), so I am skipping the details.

ADDITIONAL INFORMATION
A simple example version of the `pygls` language server like https://github.com/openlawlibrary/pygls/tree/main/examples/hello-world should be sufficient to trigger this problem, if you need a language server without these features.

In case it matters, the language server I used responded with the following as its server capabilities:
pygls.protocol.json_rpc: info: Sending data: {"id": 1, "jsonrpc": "2.0", "result": {"capabilities": {"positionEncoding": "utf-16", "textDocumentSync": {"openClose": true, "change": 2, "save": false}, "completionProvider": {}, "hoverProvider": true, "codeActionProvider": true, "documentFormattingProvider": true, "foldingRangeProvider": true, "executeCommandProvider": {"commands": []}, "semanticTokensProvider": {"legend": {"tokenTypes": ["keyword", "enumMember", "comment", "string", "macro", "operator", "typeParameter", "variable"], "tokenModifiers": []}, "documentSelector": null, "full": true}, "inlayHintProvider": {"resolveProvider": false}, "workspace": {"workspaceFolders": {"supported": true, "changeNotifications": true}, "fileOperations": {}}}, "serverInfo": {"name": "debputy", "version": "vN/A"}}}

(The version being `vN/A` is because I am using a git checkout and it does not announce the correct version there)
Comment 1 niels 2025-07-06 07:41:03 UTC
I think this is a general problem in LSP client plugin and its integration into `kate`. I doubt the there cases I found is an exhaustive list. I recommend doing a sweep over all the features to ensure they are all correctly gated by a capability.
Comment 2 Christoph Cullmann 2025-07-06 11:34:31 UTC
Valid concern that this is suboptimal and can lead to issues. Help to fix that is welcome :)