Skip to content

feat(oxfmt/lsp): Support per-directory config#21081

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-06-feat_oxfmt_lsp_support_per-directory_config
Apr 15, 2026
Merged

feat(oxfmt/lsp): Support per-directory config#21081
graphite-app[bot] merged 1 commit intomainfrom
04-06-feat_oxfmt_lsp_support_per-directory_config

Conversation

@leaysgur
Copy link
Copy Markdown
Member

@leaysgur leaysgur commented Apr 6, 2026

A.k.a. nested config, for LSP.

I plan to add CLI support later, LSP support for start.
(So, please do not merge for a while. 🙏🏻)

  • Before: At startup, it finds-up for config file starting from the workspace root
    • It followed the same behavior as the CLI
  • After: When a formatting request is made, it finds-up for a config file starting from the target file and then caches
    • Unlike Oxlint, Oxfmt does not have the concept of a root config, so this approach is sufficient
    • In the first place, I don't see any reason to parse a config file when you don't even know if it's going to be used
  • Unchanged:
    • It still resolves a single .prettierignore and .editorconfig as before
    • When configPath is specified, it uses only that config file
    • For in-memory file, it is resolved by workspace root

Copy link
Copy Markdown
Member Author

leaysgur commented Apr 6, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added A-cli Area - CLI A-editor Area - Editor and Language Server A-formatter Area - Formatter C-enhancement Category - New feature or request labels Apr 6, 2026
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 67a8247 to 1971927 Compare April 6, 2026 08:12
@leaysgur leaysgur requested a review from Sysix April 6, 2026 08:14
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 1971927 to ea0c32b Compare April 6, 2026 08:17
Copy link
Copy Markdown
Member

@Sysix Sysix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not test, only looked at the source code what looks "weird" for me :)
In general the code looks great. Thank you 👍

Comment thread apps/oxfmt/src/lsp/server_formatter.rs Outdated
Comment thread apps/oxfmt/src/lsp/server_formatter.rs Outdated
Comment thread apps/oxfmt/src/lsp/server_formatter.rs Outdated
@leaysgur
Copy link
Copy Markdown
Member Author

leaysgur commented Apr 7, 2026

Thanks~! I've addressed.
ConcurrentHashMap is good..., I was impressed by how much shorter the code became!

@leaysgur leaysgur requested a review from Sysix April 7, 2026 01:40
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch 2 times, most recently from eae912f to 5449f52 Compare April 7, 2026 02:10
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 5449f52 to d65c03c Compare April 7, 2026 04:41
@leaysgur leaysgur changed the base branch from main to graphite-base/21081 April 7, 2026 05:18
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from d65c03c to a59e81e Compare April 7, 2026 05:18
@leaysgur leaysgur changed the base branch from graphite-base/21081 to 04-06-refactor_oxfmt_rework_glob_expansion April 7, 2026 05:19
@leaysgur leaysgur force-pushed the 04-06-refactor_oxfmt_rework_glob_expansion branch from 8b38451 to bb040ce Compare April 7, 2026 06:24
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from a59e81e to e668056 Compare April 7, 2026 06:24
@leaysgur leaysgur force-pushed the 04-06-refactor_oxfmt_rework_glob_expansion branch from bb040ce to 1065731 Compare April 7, 2026 06:41
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from e668056 to 1429737 Compare April 7, 2026 06:41
@graphite-app graphite-app Bot changed the base branch from 04-06-refactor_oxfmt_rework_glob_expansion to graphite-base/21081 April 7, 2026 06:59
@graphite-app graphite-app Bot force-pushed the graphite-base/21081 branch from 1065731 to 85075ce Compare April 7, 2026 07:03
@graphite-app graphite-app Bot force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 1429737 to 06b72bd Compare April 7, 2026 07:03
@graphite-app graphite-app Bot changed the base branch from graphite-base/21081 to main April 7, 2026 07:04
@graphite-app graphite-app Bot force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 06b72bd to 75cf93b Compare April 7, 2026 07:04
@leaysgur leaysgur force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch 2 times, most recently from c7dce6a to 821bbc3 Compare April 8, 2026 03:41
Copy link
Copy Markdown
Member

@Sysix Sysix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great ❤️
After testing it with VS Code and looking deeper into your changes, I only have 2 notices/questions :)

EDIT: oh I see why you did it this way. So we do not need to clear cache upwards directories.

Comment thread apps/oxfmt/src/lsp/server_formatter.rs
Comment thread apps/oxfmt/src/lsp/server_formatter.rs
@leaysgur
Copy link
Copy Markdown
Member Author

leaysgur commented Apr 9, 2026

Thank you! 😉

Then, I'll freeze the code for now.
It's going to take a bit more time before we can merge it. As long as #20416 remains unresolved, we're bound to see frequent errors where vite.config.ts is detected during the find-up process...

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 15, 2026

Merge activity

A.k.a. nested config, for LSP.

I plan to add CLI support later, LSP support for start.
(So, please do not merge for a while. 🙏🏻)

- Before: At startup, it finds-up for config file starting from the workspace root
  - It followed the same behavior as the CLI
- After: When a formatting request is made, it finds-up for a config file starting from the target file and then caches
  - Unlike Oxlint, Oxfmt does not have the concept of a root config, so this approach is sufficient
  - In the first place, I don't see any reason to parse a config file when you don't even know if it's going to be used
- Unchanged:
  - It still resolves a single `.prettierignore` and `.editorconfig` as before
  - When `configPath` is specified, it uses only that config file
  - For in-memory file, it is resolved by workspace root
@graphite-app graphite-app Bot force-pushed the 04-06-feat_oxfmt_lsp_support_per-directory_config branch from 076ce9a to 952de06 Compare April 15, 2026 01:26
@graphite-app graphite-app Bot merged commit 952de06 into main Apr 15, 2026
24 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Apr 15, 2026
@graphite-app graphite-app Bot deleted the 04-06-feat_oxfmt_lsp_support_per-directory_config branch April 15, 2026 01:30
camc314 added a commit that referenced this pull request Apr 20, 2026
# Oxlint
### 💥 BREAKING CHANGES

- 24fb7eb allocator: [**BREAKING**] Rename `Box` and `Vec` methods
(#21395) (overlookmotel)

### 🚀 Features

- 38d8090 linter/jest: Implemented jest `version` settings in config
file. (#21522) (Said Atrahouch)
- 7dbbb99 linter/eslint: Implement suggestion for `no-case-declarations`
rule (#21508) (Mikhail Baev)
- 9b4d9f6 linter/prefer-template: Implement autofix (#21502) (François)
- daa64ed linter/no-empty-pattern: Add `allowObjectPatternsAsParameters`
option (#21474) (camc314)
- cf2d281 linter/typescript: Implement explicit-member-accessibility
(#21447) (Hunter Tunnicliff)
- d48de6f linter/unicorn: Add help messages to 3 rule diagnostics
(#21459) (Mukunda Rao Katta)
- cffdc2e linter: Backfill rule version metadata (#21391) (Old Autumn)

### 🐛 Bug Fixes

- 1e69b91 linter/no-useless-assignment: Improve diagnostic spans
(#21581) (camc314)
- f272594 linter/plugins: Align `RuleMeta.replacedBy` type with ESLint
(#21544) (bab)
- 4d57851 linter/eslint: Enhance `no-empty-function` rule to support
async and generator functions in VariableDeclarator (#21542) (Mikhail
Baev)
- 00fc136 codegen: Preserve coverage comments before object properties
(#21312) (bab)
- a56b7b9 oxlint: Dont enable gitlab formatter by default (#21501)
(camc314)
- 9c9b6a2 linter/array-callback-return: Ignore non-exit CFG dead ends
(#21497) (camc314)
- 61088e0 linter/unicorn: Handle computed property access in
`prefer-dom-node-remove` rule (#21470) (Mikhail Baev)
- eab5934 linter: Report an error on unsupported `extends` values
(#21406) (John Costa)
- 3289ba0 linter/valid-expect-in-promise: Check a jest fn to be `test`
instead of `describe` (#21422) (Said Atrahouch)
- 4417fe3 linter/prefer-ending-with-an-expect: Ignore vi.mock factory
callbacks (#21414) (Cédric Exbrayat)
- a904883 linter/consistent-type-imports: Ignore vue/svelte/astro files
(#21415) (bab)
- 2498fe6 linter/no-unused-vars: Allow segments of dotted namespace
declarations (#21416) (bab)
- 44b5b35 linter: Preserve vitest-compatible jest rules when applying
overrides (#21389) (Cameron)
- 7bd8331 linter/prefer-ending-with-an-expect: Add missing `version`
docs (#21390) (Said Atrahouch)
- 43d8f0d linter/no-useless-assignment: Ignore writes read by closures
(#21380) (camc314)

### 📚 Documentation

- c1eeae3 linter: Add version to `rule.json` (#21547) (camchenry)
- 0ec6ab2 linter: Improve the `vitest/no-importing-vitest-globals` rule
documentation. (#21557) (connorshea)
# Oxfmt
### 💥 BREAKING CHANGES

- 24fb7eb allocator: [**BREAKING**] Rename `Box` and `Vec` methods
(#21395) (overlookmotel)

### 🚀 Features

- 5aa7fe1 oxfmt: Add `--disable-nested-config` CLI flag (#21514)
(leaysgur)
- b5cb8d1 oxfmt: Update prettier to 3.8.3 (#21451) (leaysgur)
- 16713d5 oxfmt/cli: Support per-directory config (#21103) (leaysgur)
- 952de06 oxfmt/lsp: Support per-directory config (#21081) (leaysgur)

### 🐛 Bug Fixes

- a501a53 formatter: Handle comments after pipe in single-member union
types (#21487) (John Costa)
- 6f49fad oxfmt: Respect nested config.`ignorePatterns` (#21489)
(leaysgur)
- 7c98d52 oxfmt: Do not panic on finding invalid nested config (#21461)
(leaysgur)
- 41bb2d5 formatter: Preserve more `intrinsic` parens (#21449)
(leaysgur)
- f894750 formatter: Preserve parens around `intrinsic` in type alias
annotation (#21410) (Dunqing)

### ⚡ Performance

- df27b48 oxfmt: Skip ancestors check when no nested config found
(#21517) (leaysgur)
- 5e1522a oxfmt: Do not occupy the rayon thread solely for handover
(#21408) (leaysgur)

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-editor Area - Editor and Language Server A-formatter Area - Formatter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants