Skip to content

Send workspace folder and initialization options - #72

Open
regulad wants to merge 1 commit into
ltex-plus:developfrom
regulad:implement-67
Open

regulad wants to merge 1 commit into
ltex-plus:developfrom
regulad:implement-67

Conversation

@regulad

@regulad regulad commented Dec 2, 2026

Copy link
Copy Markdown

Fixes #67.

Problem

lsp-cli-plus sent an empty InitializeParams, so a language server got no rootUri, no workspaceFolders and no initializationOptions. A server that relies on them can't work from the command line as it does in an editor. ltex-ls-plus, for example, reads external setting files itself only when the client sends ltex.externalFiles.managedByEditor as false in initializationOptions (ltex-plus/ltex-ls-plus#192), and ltex-plus/ltex-ls-plus#234 resolves relative ones against the workspace folder.

Fix

  1. Workspace folder. The client sends the current working directory as rootUri and as the only entry of workspaceFolders, declares the workspace.workspaceFolders client capability, and answers the server's workspace/workspaceFolders request. The new option --workspace-folder=<directory> sends another directory instead.
  2. Initialization options. The new option --initialization-options=<file> sends the JSON value stored in <file> as initializationOptions, unchanged. Without it, none are sent, as before. If the file doesn't exist, the client exits with 1 before it starts the server.
  3. .lsp-cli-plus.json. A relative path given there as the default of either option is resolved against the directory of that file, the directory that --server-working-directory defaults to, so a program can ship an initialization-options file next to its .lsp-cli-plus.json. On the command line, a relative path is resolved against the current working directory.
  4. Documentation. The README lists both options, and changelog.xml has an entry.

Not changed

  • The client answers workspace/configuration as before, and still doesn't declare it as a capability.
  • A default for --client-configuration in .lsp-cli-plus.json is still resolved against the current working directory.

Testing

  • New tests. LspCliLanguageClientTest checks the InitializeParams sent: the workspace folder, a relative one, and the initialization options. LspCliSettingsTest checks how paths in .lsp-cli-plus.json are resolved, with and without the file. LspCliLauncherTest adds a check with both options, one with a missing initialization-options file, and the defaults of both options from .lsp-cli-plus.json.
  • Full suite. mvn verify passes on JDK 21: 23 tests, ktlint, detekt and JaCoCo.
  • End to end, through the ltex-cli-plus launcher of ltex-ls-plus 19.0.0, one file per run, with a word that only an external dictionary file lists:
Server Client Dictionary entry Result
19.0.0 3.0.1 absolute flagged
19.0.0 this branch, without --initialization-options absolute flagged
19.0.0 this branch, with managedByEditor set to false absolute accepted
ltex-plus/ltex-ls-plus#234 this branch, run from the project :.ltex/dict.txt accepted
ltex-plus/ltex-ls-plus#234 this branch, --workspace-folder=.. :.ltex/dict.txt flagged, as the entry then names a file that doesn't exist

Once this is released, ltex-ls-plus can list both options in the visibleArguments that its tools/addLtexCli.py writes, so that ltex-cli-plus --help shows them.


Drafted by Claude Opus 5.5 (claude-opus-5-5); reviewed by @regulad.

https://claude.ai/code/session_01Mv4cZ3LFVAJ9aG5SntwnAr

lsp-cli-plus sent an empty InitializeParams, so a language server got
no rootUri, no workspaceFolders and no initializationOptions.

Send the current working directory as the workspace folder, as rootUri
and as the only entry of workspaceFolders, and declare the
workspace.workspaceFolders client capability. The new option
--workspace-folder overrides the directory, and the new option
--initialization-options names a JSON file whose value is sent as
initializationOptions. In .lsp-cli-plus.json, relative defaults of both
are resolved against the directory of that file.

Fixes ltex-plus#67.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mv4cZ3LFVAJ9aG5SntwnAr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send a workspace folder and initialization options with initialize

1 participant