-
-
Notifications
You must be signed in to change notification settings - Fork 726
feat(cli): add --lsp flag to oxlint to run language server #15038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
CodSpeed Performance ReportMerging #15038 will not alter performanceComparing Summary
|
84758d2 to
5cb143e
Compare
5cb143e to
bc288e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Language Server Protocol (LSP) support to the oxlint CLI by introducing a new --lsp flag. When this flag is provided, oxlint starts as a language server instead of running as a traditional linter.
Key changes:
- Added
--lspcommand-line flag to start the language server - Refactored the language server startup code into a reusable
run_server()function - Updated command-line help and documentation to reflect the new flag
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src/command/lint.rs | Adds the lsp boolean field to LintCommand with documentation |
| apps/oxlint/src/run.rs | Makes lint_impl async and checks command.lsp flag to conditionally run the language server |
| apps/oxlint/src/lsp.rs | New module containing run_lsp() wrapper function |
| apps/oxlint/src/lib.rs | Exports run_lsp function in the CLI module |
| crates/oxc_language_server/src/lib.rs | Adds public run_server() function extracted from main.rs |
| crates/oxc_language_server/src/main.rs | Refactored to call the new run_server() function |
| apps/oxlint/Cargo.toml | Adds oxc_language_server dependency and tokio features for async I/O |
| Cargo.toml | Registers oxc_language_server in workspace dependencies |
| tasks/website/src/linter/snapshots/*.snap | Updates help text snapshots to show new --lsp flag |
| Cargo.lock | Updates dependency versions (cc, jiff, napi, quote, ureq) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If --lsp flag is set, run the language server | ||
| if command.lsp { | ||
| crate::lsp::run_lsp().await; | ||
| return CliRunResult::LintSucceeded; | ||
| } |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --lsp flag check happens inside the NAPI-specific lint_impl function, but the main binary (main.rs) doesn't handle this flag. When running oxlint --lsp from the command line (not via NAPI), the flag will be parsed but ignored, and the linter will run normally instead of starting the language server. The flag check should also be added to apps/oxlint/src/main.rs after parsing the command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I should add this to main.rs as well.
Closes #12251 - Add `--lsp` flag to oxlint CLI command - Create shared `run_server()` function in oxc_language_server - Deduplicate LSP initialization code between oxlint and standalone binary - Make flag visible in help/documentation by removing hide_usage - Handle async runtime properly within NAPI context
bc288e9 to
53ca2ca
Compare
this will break #15038 but it was aligned with it :)
|
Closing in favor of #15611 |
closes #15038 and #12251 > This PR adds a --lsp flag to the oxlint command-line tool that starts the language server directly, allowing for a unified binary that can function as both a linter and a language server. This addresses the need for a simpler deployment model where a single oxlint binary can be used in different modes.
Closes #12251
Summary
Adds
--lspflag to the oxlint CLI that starts the language server. This allows users to runoxlint --lspinstead of needing a separateoxc_language_serverbinary.