Skip to content

LSP integration (auto-detect + auto-install) for Codex CLI #8745

@Daniel-Santiago-Acosta-1013

Description

What feature would you like to see?

Summary

Please add built-in Language Server Protocol (LSP) support to Codex CLI, including auto-detection and auto-installation of popular language servers. The goal is for Codex CLI to use LSP diagnostics and symbol intelligence to produce more precise, language- and project-aware code edits with minimal or zero manual setup.

Motivation / Problem

Codex CLI is often used on real repositories that are:

  • multi-language (frontend + backend + infra)
  • strongly typed / toolchain-driven (TypeScript, Go, Rust, C#, Java, etc.)
  • linted and configured per-project (eslint rules, tsconfig, deno.json, etc.)

Without structured feedback, the model can produce changes that:

  • fail type-checking or compilation (wrong imports/types/symbols)
  • violate project conventions/tooling config
  • require repeated manual cycles of build/test/lint to discover issues

LSP servers provide semantic diagnostics + code intelligence. If Codex CLI can optionally leverage LSP signals during the edit loop, it becomes significantly more reliable.

Proposal

Add an LSP Manager to Codex CLI with:

  1. Auto-detection based on file extensions and project markers (package.json, deno.json, go.mod, etc.)
  2. A built-in server mapping (language -> LSP server + install strategy + requirements)
  3. Auto-install (opt-in by default, or prompted) for servers that can be installed automatically
  4. Lifecycle management (start/stop, per-workspace, prefer stdio transport)
  5. Document sync (didOpen/didChange/didSave)
  6. Use LSP output as feedback for code edits:
    • publishDiagnostics (must)
    • document/workspace symbols, definition/references (high value)
    • optional: hover/signatureHelp

CLI / UX suggestion

  • codex --lsp=auto (or --lsp=on), codex --lsp=off
  • codex lsp status (which servers detected, installed, running)
  • codex lsp diagnostics [--file path] (print diagnostics used by Codex)
  • Optional: codex fix --with-lsp (iterate until diagnostics improve / are clean)

Built-in LSP server matrix (target scope)

Codex CLI should ship with a curated built-in list like:

LSP Server Extensions Requirements / Install behavior
astro .astro Auto-installs for Astro projects
bash .sh, .bash, .zsh, .ksh Auto-installs bash-language-server
clangd .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ Auto-installs for C/C++ projects
csharp .cs .NET SDK installed
clojure-lsp .clj, .cljs, .cljc, .edn clojure-lsp command available
dart .dart dart command available
deno .ts, .tsx, .js, .jsx, .mjs deno command available (auto-detect deno.json/deno.jsonc)
elixir-ls .ex, .exs elixir command available
eslint .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue eslint dependency in project
fsharp .fs, .fsi, .fsx, .fsscript .NET SDK installed
gleam .gleam gleam command available
gopls .go go command available
jdtls .java Java SDK (version 21+) installed
kotlin-ls .kt, .kts Auto-installs for Kotlin projects
lua-ls .lua Auto-installs for Lua projects
nixd .nix nixd command available
ocaml-lsp .ml, .mli ocamllsp command available
oxlint .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue, .astro, .svelte oxlint dependency in project
php intelephense .php Auto-installs for PHP projects
prisma .prisma prisma command available
pyright .py, .pyi pyright dependency installed
ruby-lsp (rubocop) .rb, .rake, .gemspec, .ru ruby and gem commands available
rust .rs rust-analyzer command available
sourcekit-lsp .swift, .objc, .objcpp swift installed (xcode on macOS)
svelte .svelte Auto-installs for Svelte projects
terraform .tf, .tfvars Auto-installs from GitHub releases
tinymist .typ, .typc Auto-installs from GitHub releases
typescript .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts typescript dependency in project
vue .vue Auto-installs for Vue projects
yaml-ls .yaml, .yml Auto-installs Red Hat yaml-language-server
zls .zig, .zon zig command available

This is the “built-in” experience requested: detection + install + run handled by Codex CLI without users wiring it manually.

Installation model (recommended)

  • Install servers into a Codex-managed cache directory (per-user), pinned versions.
  • Prefer official distribution channels:
    • npm-based servers (typescript-language-server, bash-language-server, yaml-language-server, etc.)
    • GitHub releases for binaries (terraform-ls, tinymist, etc.) with checksums
    • Respect “project-provided” servers when present (eslint/ts in node_modules, pyright dependency, etc.)
  • Provide safe defaults and clear logs:
    • prompt before downloads, or allow --yes for non-interactive installs
    • allow --lsp=off to disable all LSP activity

Acceptance criteria

  • codex --lsp=auto detects language(s) and starts appropriate server(s) or explains unmet requirements.
  • For supported auto-install servers, Codex CLI can install them and cache them.
  • Codex CLI can surface or internally use LSP diagnostics for edited files.
  • Optional “fix loop”: improve patches using diagnostics until stable/clean or max iterations reached.
  • Graceful fallback when a server is missing/unavailable, without breaking Codex CLI.

Security / Privacy considerations

  • LSP processes run locally and only access the workspace.
  • Clear opt-in behavior for downloads and execution.
  • Ability to disable LSP entirely and to view which commands are being executed.

Additional information

Primary use cases

  • Multi-language repos (e.g., TS + Python + Terraform)
  • Large refactors where symbol navigation/definitions matter
  • Reducing trial-and-error cycles with build/lint/test

Environment

  • OS: macOS (can also test on Linux if needed)
  • Common toolchains available depending on repo: Node/npm, Go, Rust, .NET, Java

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentIssues related to the core agent loopenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions