Skip to content

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Oct 28, 2025

Closes #12251

Summary

Adds --lsp flag to the oxlint CLI that starts the language server. This allows users to run oxlint --lsp instead of needing a separate oxc_language_server binary.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 28, 2025

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 hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-editor Area - Editor and Language Server C-enhancement Category - New feature or request labels Oct 28, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 28, 2025

CodSpeed Performance Report

Merging #15038 will not alter performance

Comparing feat/oxlint-lsp-flag (53ca2ca) with main (732205e)

Summary

✅ 37 untouched

@Boshen Boshen force-pushed the feat/oxlint-lsp-flag branch from 84758d2 to 5cb143e Compare October 28, 2025 14:21
@Boshen Boshen force-pushed the feat/oxlint-lsp-flag branch from 5cb143e to bc288e9 Compare November 8, 2025 10:33
@Boshen Boshen marked this pull request as ready for review November 8, 2025 10:33
@Boshen Boshen requested review from Sysix and camc314 as code owners November 8, 2025 10:33
Copilot AI review requested due to automatic review settings November 8, 2025 10:33
Copy link
Contributor

Copilot AI left a 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 --lsp command-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.

Comment on lines +94 to +98
// If --lsp flag is set, run the language server
if command.lsp {
crate::lsp::run_lsp().await;
return CliRunResult::LintSucceeded;
}
Copy link

Copilot AI Nov 8, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

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
@Sysix
Copy link
Member

Sysix commented Nov 12, 2025

Closing in favor of #15611

@Sysix Sysix closed this Nov 12, 2025
@Sysix Sysix deleted the feat/oxlint-lsp-flag branch November 12, 2025 21:50
graphite-app bot pushed a commit that referenced this pull request Nov 14, 2025
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.
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-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oxlint: Single binary for oxlint and oxc_language_server

4 participants