Bug 501082

Summary: Support workspace/configuration in the LSP client
Product: [Applications] kate Reporter: Alex Lowe <lengau>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 24.12.2   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Alex Lowe 2025-03-05 03:18:55 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
Please support the workspace configuration request from LSP servers: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration

STEPS TO REPRODUCE
1. Install YAML language server >= 1.14 (https://github.com/redhat-developer/yaml-language-server)
2. Try to use it with Kate

OBSERVED RESULT
We run into this bug: https://github.com/redhat-developer/yaml-language-server/issues/927
and Kate's logs say:

[21:56:04  LSP Client Log] Started server yaml@/home/lengau: /snap/bin/node /home/lengau/Projects/yaml-language-server/out/server/src/server.js --stdio
[21:56:05  LSP Server Log] yaml@/home/lengau
[Error] Error: workspace/configuration
    at handleResponse (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)
    at handleMessage (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)
    at processMessageQueue (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)
    at Immediate. (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)
    at process.processImmediate (node:internal/timers:483:21)
[21:56:05  LSP Server Log] yaml@/home/lengau
[Error] Error: workspace/configuration
    at handleResponse (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)
    at handleMessage (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)
    at processMessageQueue (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)
    at Immediate. (/home/lengau/Projects/yaml-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)
    at process.processImmediate (node:internal/timers:483:21)

EXPECTED RESULT
It works :-)

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 25.04
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.12.0-15-generic (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon  780M Graphics
Memory: 54.7 GiB of RAM
Graphics Processor: AMD Radeon 780M

ADDITIONAL INFORMATION
Comment 1 Alex Lowe 2025-05-22 16:34:27 UTC
Another example of this in a different LSP: Astral's `ty` LSP warns that no workspace was provided during init. If kate has a project open, that should be provided as the workspace.

[12:26:49  LSP Client Log] Started server python@: /snap/bin/ty server
[12:26:49  LSP Server Log] python@
   0.000022041s  WARN main ty_server::server: No workspace(s) were provided during initialization. Using the current working directory as a default workspace...
   0.000357893s  INFO main ty_project::metadata::options: Defaulting to python-platform `linux`
   0.000412876s  INFO main ty_python_semantic::program: Python version: Python 3.13, platform: linux
   0.001880116s  WARN ty:main ty_server::server: The client does not support file system watching.
   0.001900294s  WARN ty:main ty_server::server::api: Received notification workspace/didChangeConfiguration which does not have a handler.
[12:27:20  LSP Client Log] Started server python@/home/lengau/Work/Code/craft-platforms: /snap/bin/ty server
[12:27:21  LSP Server Log] python@/home/lengau/Work/Code/craft-platforms
   0.000024546s  WARN main ty_server::server: No workspace(s) were provided during initialization. Using the current working directory as a default workspace...
   0.000763987s  INFO main ty_project::metadata::options: Defaulting to python-platform `linux`
   0.000782341s  INFO main ty_python_semantic::program: Python version: Python 3.8, platform: linux
[12:27:21  LSP Server Log] python@/home/lengau/Work/Code/craft-platforms
   0.002087536s  WARN ty:main ty_server::server: The client does not support file system watching.
   0.002099789s  WARN ty:main ty_server::server::api: Received notification workspace/didChangeConfiguration which does not have a handler.
[12:27:21  LSP Server Log] python@/home/lengau/Work/Code/craft-platforms
   0.047562334s  INFO ty:worker:0 ty_project: Indexed 37 file(s)
Comment 2 Christoph Cullmann 2025-07-22 17:03:56 UTC
Git commit 4446f148d340176aeda2ac3980f7b04a0b9ec7a8 by Christoph Cullmann, on behalf of Johnny Hsieh.
Committed on 22/07/2025 at 17:03.
Pushed by cullmann into branch 'master'.

Add support for workspace/configuration request in LSP client

Changes:
- Introduced LSPConfigurationItem and LSPConfigurationParams structs to handle configuration items and parameters.
- Implemented parsing functions for configuration items and parameters in `lspclientserver.cpp`.
- Updated LSPClientServer to emit configuration signals and handle configuration requests.

References:
- vim-lsp: [1](https://github.com/prabirshrestha/vim-lsp/blob/04428c920002ac7cfacbecacb070a8af57b455d0/autoload/lsp/utils/workspace_config.vim#L18-L30), [2](https://github.com/prabirshrestha/vim-lsp/blob/04428c920002ac7cfacbecacb070a8af57b455d0/autoload/lsp.vim#L953-L956)
- neovim: [3](https://github.com/neovim/neovim/blob/b0e8b0a35f3d38763c564f6d4924f7be2e2271fb/runtime/lua/vim/lsp/handlers.lua#L199-L230)
- LSP specification: [4](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration)

M  +10   -0    addons/lspclient/lspclientprotocol.h
M  +47   -4    addons/lspclient/lspclientserver.cpp
M  +2    -0    addons/lspclient/lspclientserver.h
M  +29   -0    addons/lspclient/lspclientservermanager.cpp

https://invent.kde.org/utilities/kate/-/commit/4446f148d340176aeda2ac3980f7b04a0b9ec7a8