Repository navigation
fix: a user-defined language server without a working directory starts in the project's directory, and gets its environment - #2233
Merged
lagergren merged 3 commits intoNov 25, 2026
Conversation
…s in the project's directory, and gets its environment A user-defined language server without a working directory started in the IDE's working directory, which is rarely meaningful (/ on macOS, the home or bin directory elsewhere). The environment of a directory (redhat-developer#1693), which mise or direnv give from a mise.toml or an .envrc, then didn't apply to it, and its command was looked up in the IDE's PATH. Without a configured working directory, none or a blank one, a user-defined language server now runs in its root, which ${instanceRoot} names too: the project's directory, or with serverInstances the root of each instance, as since redhat-developer#1853. So it gets the environment of that directory. A configured working directory still wins. The default applies wherever LSP4IJ starts the language server: over its standard input and output, over a socket that LSP4IJ starts it for (redhat-developer#1870), and in the initialize check of an installer. A language server that LSP4IJ attaches to isn't started, so it has no working directory. An instance whose root is in an archive now runs in the project's directory, which ${instanceRoot} already was for it. A project whose directory isn't on disk, or the default project of an installer check without a project, gives none, as before, so that the language server still starts. The empty Working Directory field of the New Language Server dialog and of the settings shows the default: "Project directory", or "Root of each instance" with serverInstances. Nothing new is stored. Behaviour change: a language server whose command relied on the IDE's working directory, as with a relative path, now resolves it against the project's directory. Set the working directory to run it elsewhere. Fixes redhat-developer#1886
…rectory runs, and what its empty field shows UserDefinedServerWorkingDirectoryTest starts WorkingDirectoryRecorder, a JDK-only program that prints the directory it runs in and a variable which a test CommandLineEnvCustomizer sets to the working directory, as mise or direnv do. Without a working directory, or with a blank one, the language server runs in the project's directory and gets its environment, over the standard input and output and over a socket; a configured working directory wins; the initialize check of an installer runs where the language server does; a project whose directory isn't on disk, and the default project, give none. The environment is checked where the IDE has the extension point, since 2025.1, and the test fails if a 2025.1+ IDE lacks it, so that it isn't skipped there. The light project of the tests has no directory on disk, so the tests which need it create it, and delete it at their end. UserDefinedServerInstancesTest: one instance per project and an instance whose root is in an archive run in the project's directory now; an instance with a local root still runs in its root. LanguageServerViewWorkingDirectoryTest and NewLanguageServerDialogTemplateTest: the empty field shows "Project directory", and "Root of each instance" with serverInstances, also once the Server tab is back after the Workspace Folders tab changed the configuration. The placeholder isn't stored.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2233 +/- ##
==========================================
+ Coverage 55.67% 55.76% +0.08%
==========================================
Files 844 844
Lines 36091 36108 +17
Branches 7464 7468 +4
==========================================
+ Hits 20094 20134 +40
+ Misses 13086 13066 -20
+ Partials 2911 2908 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…placeholder The three screenshots of the New Language Server dialog in UserDefinedLanguageServer.md showed an empty Working Directory field, which now shows "Project directory". They are rendered again from the real dialog, offscreen at 2x in the New UI Dark theme with the Inter font: the empty dialog with its "Server name must be set" and "Command must be set" errors, the dialog after choosing the TypeScript template, with its current command `typescript-language-server --stdio` and its instructions line, and the socket transport that starts the language server, which connects to LSP4IJ on an Auto port. Offscreen, the dialog has no window frame or title bar.
This was referenced Nov 25, 2026
lagergren
added a commit
that referenced
this pull request
Nov 25, 2026
…d Find Usages screenshots (#2257) Retakes the screenshots of the New Language Server dialog with the Choose template popup, the current templates and the Project directory placeholder of #2233; the settings page with its header and tabs; the LSP console tree with the tooltips of a language server and of its process; and Find Usages without the repeated declaration (#2219).
lagergren
added a commit
that referenced
this pull request
Nov 25, 2026
…0.1 (#2255) ## What An audit of the docs against main found wrong information, missing docs for features merged since 0.30.1, broken links and small mistakes. This PR fixes the text. The outdated screenshots are retaken in separate PRs. ## Change ### DAP guides - **DAPSupport.md:** - The `Cancel` request is supported, with `supportsCancelRequest` (#2122). It was marked ❌. - `Terminate Thread` is also in the Frames view. - The Output line links the user guide. - **DAP user guide:** - New section, "Console output": ANSI colours, indented groups, hidden `telemetry` output, and the source link or "Jump to Value Source" after an output. - Jump to Source on a lazy variable whose value has no declaration opens the lazy variable's own declaration. - The Frames view also says "the thread has exited". - CodeLLDB maps Rust files only. - **DAP developer guide:** - The `DAPClient` requests `stepBack`, `reverseContinue`, `locations`, `setExpression` and `terminateThreads`. - The rule that a request naming a frame id or a `variablesReference` goes through `sendInExecutionEpoch`. - The `DAP.Threads.Popup` group with `ThreadsPanel.SELECTED_THREADS`. - Keeping `supportsANSIStyling` when overriding `createInitializeRequestArguments`. - **Debug adapter pages:** - "Log pattern before proceeding", not "processing", in go-delve, julia and vscode-js-debug. - ruby-rdbg: select Attach, since the dialog opens on Launch. - codelldb: the C++ TODO is replaced by how to map C/C++ files. ### Developer guides - **LSPApi.md, fixes:** - The formatting sample compiles: `isExistingFormatterOverrideable` is `public`. The javadoc sample of `LSPFormattingFeature` is fixed too. - The `get*Characters` and `get*Scope` methods return `String` and `FormattingScope`, not `boolean`. - The CodeLens sample compares the command's title, not the `Command`, and has its imports. - There is one Diagnostic section, with `getTooltip`; the duplicate section named `getToolTip`, which is never called. - The DocumentSymbol table: `getIcon` takes the `boolean`. - `isEnabled(VirtualFile)` is `false` until a server with an installer is installed. - `EditorBehaviorFeature` is named correctly, and the Breadcrumbs default is given. - Two stray `=======` merge markers are gone. - **LSPApi.md, additions:** - Sections for the call hierarchy, type hierarchy, on-type formatting and configuration features. - The missing methods of CodeAction, CodeLens, Completion, Progress, DocumentSymbol and References. - When Find Usages merges a language server's reference with a language plugin's. - **DeveloperGuide.md:** - A custom server API is exposed with `getServerInterface()`, not `createLanguageClient`. - The get-server sample had an inverted null check. The Lease sample checks for a null item, casts to the server API and joins the future. - The custom `WorkspaceFolderStrategy` sample implements `getWorkspaceFolders`, so it compiles. - All attributes of the `server` extension point are listed. - `OSProcessStreamConnectionProvider` isn't experimental, starts one process, and logs to the `Logs` tab. - A document matcher that throws counts as no match. - The missing workspace folders image is replaced by an existing screenshot. ### User guides - **UserGuide.md:** - A Getting started section. The empty LSP console's `Getting Started` link opens this page. - The console tree: state badges, the server and instance tooltips, and `[stdio]` or the socket. - Messages that LSP4J can't parse are shown in the traces. - The warning when IntelliJ 2026.3's own LSP client also serves a file. - Find Usages lists a declaration once, and lists once a reference that a language plugin also finds. - **LSPSupport.md:** - Snippet edits of `workspace/applyEdit`. - `workspace/executeCommand` traces name the command. - When Quick Documentation shows a late hover reply. - The completion prefix in a token that spans whitespace. - `callHierarchy/incomingCalls` and `callHierarchy/outgoingCalls`, not `textDocument/...`. - The `LSP Type Definition(s)` and `LSP Declaration(s)` menus. - A reversed link is fixed. - **README:** - "As notification" is the default error reporting. - "In log" writes a warning to `idea.log` and opens no dialog; the screenshot of that dialog is removed. - LSP4IJ instead of LSP4J. - The documentation list names the LSP API, the template page and the DAP pages. ### User-defined language servers and templates - **UserDefinedLanguageServerTemplate.md:** - The npm `exec` example matches the bundled TypeScript installer: it runs in `node_modules`, with a quoted command, and says why (#2084). - A downloaded file is named after the last segment of the URL's path, without its query or fragment. - The `template.json` example gives JavaScript its `*.js` pattern. - The rust-analyzer installer tab is a link, not an inline image. - **UserDefinedLanguageServer.md:** the template list uses the names that `Choose template...` shows (Camel, Dart, EO, Stylelint, Vue), and the Language ID sentence is finished. - **Server pages:** - Ada: the path includes the archive's `integration/` folder. - HTML: the template is development-only. - LemMinX: the installer runs at the first start, not when the server is created. ## Checks - **Samples:** the developer-guide samples, and an override of every method in the new API tables, compile in a throwaway test source. The samples as they are on main fail with 3 errors. - **Links:** all relative links and anchors of the changed pages resolve. - **Open PRs:** the doc changes of #2229, #2230 and #2233 still apply on top of this PR.
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1886, with option 3 from the issue, plus a visible placeholder.
What
A user-defined language server without a working directory started in the IDE's working directory, which is
/on macOS. So the directory environment of #1693 (mise, direnv), shipped in 0.30.0, didn't apply to most user-defined servers, and their commands were looked up in the IDE'sPATH.Change
${instanceRoot}names. That's the project's directory, or withserverInstancesthe root of each instance (feat: several instances of one language server per project #1853). It gets that directory's environment.initializecheck. Attach mode starts no process.${instanceRoot}already meant. Before, it had no working directory.WorkingDirectoryNotFoundException).serverInstances, in the New Language Server dialog and on the settings page. Nothing new is stored.LanguageServerView.setWorkspaceFolderStrategyConfigurationnow goes through the panel, so the placeholder follows a reset of the settings page.docs/UserDefinedLanguageServer.mdanddocs/UserDefinedLanguageServerTemplate.md.Tests
New
UserDefinedServerWorkingDirectoryTest(8 tests). It runs a recorder process that reports its working directory, and an environment variable that a testCommandLineEnvCustomizersets from that directory. The cases:The environment is checked on 2025.1 and later, the platforms that have directory environments.
Changed tests:
UserDefinedServerInstancesTest: 2 assertions now expect the project's directory. The local-root instance tests are unchanged.LanguageServerViewWorkingDirectoryTest: +3 placeholder tests, including the Workspace Folders tab round trip.NewLanguageServerDialogTemplateTest: +1 placeholder test.Red-green: without the fix, 10 of 37 tests fail on 2024.2. The process runs in the IDE's directory, the installer and blank cases get no directory, and the placeholders are empty. With the fix, all pass.
Platforms: the new and changed classes pass headless on IC 2024.2, 2025.3 and IU 2026.3: 45 tests each. The
server.*,settings.*,launching.*andinstallation.*packages pass on all three: 503 tests each, 0 failures, with the 4 Windows-only skips as before.Behaviour change
A command that relied on the IDE's working directory, for example through a relative path, now resolves against the project's directory. To run it elsewhere, set the working directory.