Commit Graph

17 Commits

Author SHA1 Message Date
leaysgur 47fb154918 test(oxfmt): Add tests and conformance (#21832) 2026-05-11 01:24:38 +00:00
Sysix 38d1e8211c fix(oxfmt/lsp): format non file:// URIs without a authority (#21647)
> ## Pull request overview

> This PR updates oxfmt’s LSP in-memory formatting to handle URIs that don’t have an authority component (i.e., non-`file://` URIs like `vscode-userdata:/...`) by deriving a “fake” file path from the URI’s authority *or* path, and updates the LSP formatting tests/snapshots accordingly.
2026-04-24 05:19:11 +00:00
leaysgur e3081e12a9 feat(oxfmt): Gate vite.config.ts recognition behind VP_VERSION env var (#21295)
Fixes #20416 for Oxfmt

- Gate `vite.config.ts` recognition behind `VP_VERSION` env var
  - With it, only vite.config.ts is recognized
  - Without it, excluded from config candidates (.oxfmtrc.json, oxfmt.config.ts are used)
- Refactor JS config loader into `loadJsConfig` / `loadVitePlusConfig` with shared `importJsConfig` helper
  - `loadVitePlusConfig` should be updated to use `resolveConfig` from `vite-plus` soon
- Split tests into `vite_config` (non VP mode) and `vite_plus` (VP mode)
2026-04-13 01:10:46 +00:00
Sysix c1b461b877 fix(oxfmt/lsp): revert #19977, prefer file extension over languageId for format strategy (#20623)
closes https://github.com/oxc-project/oxc-vscode/issues/140
Preferring the languageID over the real file extension creates inconsistency between the editor and the CLI.
Reverting the changes from #19977 back to align back with CLI.

This only effects `file://` scheme, where we can expect a real file on a disk. Other schemes are still preferring the languageID, because we do not to what exactly they are relating to.
2026-03-23 00:45:32 +00:00
leaysgur 89ce30b641 fix(oxlint,oxfmt): Redirect JS stdout to stderr for LSP (#20321)
Fixes #20320

(It's fine to release this as scheduled one)
2026-03-16 10:15:23 +00:00
leaysgur 95943aa6f2 feat(oxfmt): Support vite.config.* .fmt field (#20197)
NOTE: I'll do a self-review and add the test tomorrow.

<details>
<summary>Prompt</summary>

```
# Support `vite.config.*` as a Configuration File

## Target Files

- `vite.config.ts`
- `vite.config.mts`
- `vite.config.cts`
- `vite.config.js`
- `vite.config.mjs`
- `vite.config.cjs`

## Auto-Discovery Priority

When searching for a config file from `cwd` upwards, the following priority applies within the same directory:

1. Tool-specific JSON/JSONC config files (e.g. `.oxfmtrc.json`, `.oxlintrc.json`)
2. Tool-specific JS/TS config files (e.g. `oxfmt.config.ts`, `oxlint.config.ts`)
3. `vite.config.*`

## Extracting Configuration

The default export of `vite.config.*` is expected to contain tool-specific configuration under a dedicated field:

- oxfmt: `.fmt`
- oxlint: `.lint`

If the field does not exist, an error is returned (e.g. `Expected a 'fmt' field in the default export.`).

## Explicit `--config` Flag

When `--config vite.config.ts` is explicitly specified, the same behavior applies. The file name is used to determine whether to extract a nested field.

## LSP

`vite.config.*` files are added to the file watch patterns so that configuration changes trigger a reload.
```

</details>
2026-03-11 04:34:48 +00:00
leaysgur 172fc072f3 feat(oxfmt): .js/.ts config file support (#20135)
Fixes #19711, also resolves some of the demands for nested configs.
2026-03-11 04:34:48 +00:00
copilot-swe-agent 114f974d25 fix(oxfmt/lsp): prefer language_id over file extension when formatting (#19977)
- [x] Explore the codebase (apps/oxfmt/src/lsp/, test/lsp/format/)
- [x] Make `get_file_extension_from_language_id` accessible (pub(super)) in `mod.rs`
- [x] Modify `format_file` in `server_formatter.rs` to prefer `language_id` over file extension
- [x] Update `run_format` to pass `language_id` to `format_file`
- [x] Create test fixture `apps/oxfmt/test/lsp/format/fixtures/format/test.ts.txt`
- [x] Add test case in `format.test.ts` for `.txt` file with TypeScript `language_id`
- [x] Update snapshot
- [x] Refactor: extract `apply_language_id_extension` helper shared by both `create_fake_file_path_from_language_id` and `format_file`

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)
2026-03-04 00:25:24 +00:00
Sysix 3415cf8c81 test(oxfmt/lsp): snapshot fixture uri instead of (fake) path (#19883)
Because we are not testing URIs where there should be no local file related to it, it is better to show the URI
2026-03-02 00:32:37 +00:00
Sysix 4888a99e86 feat(oxfmt/lsp): support other schemes beside file:// and untitled:// (#19872)
> This PR expands `oxfmt`’s LSP formatting support to treat additional non-`file://` document URIs as “in-memory” documents (instead of only handling `file://` and `untitled://`), and extends the test suite/snapshots to cover new schemes.

closes https://github.com/oxc-project/oxc-vscode/issues/8
2026-03-02 00:32:37 +00:00
Alexander S. 87cb667e82 test(oxfmt/lsp): add nested workspace folders test (#19507)
Added test coverage for a bug a possible
https://github.com/oxc-project/oxc-vscode/issues/66
From the snapshots, I could not detect something wrong. Still worth to
include it
2026-02-20 09:57:25 +09:00
Sysix 652c34602c feat(oxfmt/lsp): support untitled:// schema (#19287)
related https://github.com/oxc-project/oxc-vscode/issues/25

> This PR adds support for formatting unsaved documents using the untitled:// URI scheme in the oxfmt LSP server. This enables VS Code and other LSP clients to format in-memory documents that haven't been saved to disk yet.

Angular is not supported for the moment, could not find a VS Code extension which defines a language ID for it  :/
2026-02-17 01:49:45 +00:00
Sysix cdb593a3ab test(oxfmt/lsp): fix snapshots when fixture format did not change content (#19343) 2026-02-12 23:06:08 +00:00
leaysgur 91e67f304a feat(oxfmt/lsp): Do not refer .gitignore (#19206)
Fixes #19082

The CLI can format paths specified directly, even if they are `.gitignore`d.
LSP should also be able to format files if they are open in the editor.
2026-02-10 07:20:50 +00:00
Sysix ffec86b148 test(oxfmt/lsp): define type OxfmtLSPConfig for initializationOptions (#18351) 2026-01-22 00:28:03 +00:00
Sysix d0834c8062 test(oxfmt/lsp): use workspace folders in initialize (#18255) 2026-01-19 16:35:46 +00:00
leaysgur 1a02f6ee8c test(oxfmt): Arrange test files and directries (#17822)
Sorry for the large diff! 🙇🏻

But it's mostly just file relocations (and path updates).
Details on the changes are also documented in [`AGENTS.md`](https://github.com/oxc-project/oxc/pull/17822/changes#diff-b9a8ddc83e0b93133df7274e37b5fcdaec808090721eec2194782fe968819e69), so please refer to that file.

TL;DR: I wanted to colocate test cases and fixtures in the same directory.
2026-01-09 15:11:35 +00:00