feat(lsp): support not using the global config by default by dsherret · Pull Request #1264 · dprint/dprint · GitHub
Skip to content

feat(lsp): support not using the global config by default - #1264

Merged
dsherret merged 5 commits into
mainfrom
feat/lsp-use-global-config-env
Oct 1, 2026
Merged

dsherret merged 5 commits into
mainfrom
feat/lsp-use-global-config-env

Conversation

@dsherret

@dsherret dsherret commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

dprint lsp always falls back to the global config file for files that don't have a config file in an ancestor directory. This allows an editor to make that opt-in and to still explicitly format with the global config file.

  • DPRINT_EDITOR_USE_GLOBAL_CONFIG environment variable - Setting it to 0 or false disables the fallback. It's read once when the server starts and the behaviour is unchanged when it's not set.
  • useGlobalConfig formatting option - A client may provide useGlobalConfig: true in the options of a textDocument/formatting or textDocument/rangeFormatting request to use the global config file for that request when there's no config file in an ancestor directory.

This is so dprint-vscode can pass its dprint.useGlobalConfig setting, which currently has no effect in its LSP mode, when launching the server and can have a command that formats the current document using the global config file when that setting is off.

An earlier commit here tried to not use the global config file only when formatting on save, but that was reverted because a server can't reliably tell that a format request is for a save in vscode.

Replaces #1263.

…the global config

The language server always fell back to the global config file for files without a config file in an ancestor directory. Setting this environment variable to 0 or false disables that so an editor extension can make using the global config file opt-in.
…hen formatting on save

Setting DPRINT_EDITOR_USE_GLOBAL_CONFIG to explicit uses the global config file except when a document is being formatted because it is being saved. The server knows that by having the client tell it when it will save and did save a document.
@dsherret dsherret changed the title feat(lsp): add DPRINT_EDITOR_USE_GLOBAL_CONFIG env var to opt out of the global config feat(lsp): add DPRINT_EDITOR_USE_GLOBAL_CONFIG env var to control using the global config Oct 1, 2026
@dsherret
dsherret marked this pull request as draft October 1, 2026 17:12
@dsherret

dsherret commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

…config when formatting on save"

This reverts commit 8d5edf6.
… the global config

A client may provide this option in a format request to use the global config file for a document without a config file in an ancestor directory when the server does not use the global config file by default.
@dsherret dsherret changed the title feat(lsp): add DPRINT_EDITOR_USE_GLOBAL_CONFIG env var to control using the global config feat(lsp): support not using the global config by default Oct 1, 2026
@dsherret
dsherret marked this pull request as ready for review October 1, 2026 17:22
…onfig-env

# Conflicts:
#	crates/dprint/src/commands/lsp/mod.rs
@dsherret
dsherret merged commit 11a12e3 into main Oct 1, 2026
16 checks passed
@dsherret
dsherret deleted the feat/lsp-use-global-config-env branch October 1, 2026 17:46
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.

1 participant