Skip to content

Use xpd in an editor

Point your editor's LSP client at xpd lsp to receive diagnostics, quick fixes, and rule documentation on hover as you type. xpd lsp runs inside the compiled Rust binary over stdio and needs no Python runtime.

textDocument/didOpen (bad.py)publishDiagnostics (5 diagnostics with rule URLs)textDocument/didChangepublishDiagnostics for newest buffer texttextDocument/codeAction (line 6)Quick fix edit for pandas/chained-assignmentEditorxpd lspEditorxpd lsp

Install xpd on PATH as Get started shows, then configure your editor.

Editor Launcher Fix all safe issues
Neovim 0.11+ vim.lsp.config() and vim.lsp.enable() vim.lsp.buf.code_action() with source.fixAll.xpd
Helix languages.toml Code action menu
Zed Three-file dev extension Format action
VS Code Generic LSP Client extension editor.codeActionsOnSave
Another editor Any stdio LSP client source.fixAll.xpd

Add the block below to init.lua for Neovim 0.11 or newer. Use K for hover help, gra for quick fixes, and save buffers after editing project rules on Linux.

init.lua
vim.lsp.config('xpd', {
cmd = { 'xpd', 'lsp' },
filetypes = { 'python' },
root_markers = { 'pyproject.toml', '.git' },
init_options = { unsafeFixes = false },
})
vim.lsp.enable('xpd')
:lua vim.lsp.buf.code_action({ context = { only = { 'source.fixAll.xpd' } }, apply = true })

Add xpd to languages.toml (global or .helix/). Keep your existing Python servers in language-servers, and place xpd first if you want xpd hover docs to win.

languages.toml
[language-server.xpd]
command = "xpd"
args = ["lsp"]
config = { unsafeFixes = false }
[[language]]
name = "python"
language-servers = ["ty", "ruff", "jedi", "pylsp", "xpd"]

Create a local extension folder with three files and install it via zed: install dev extension (requires rustup).

xpd-zed/
├── extension.toml
├── Cargo.toml
└── src/lib.rs
extension.toml
id = "xpd"
name = "xpd"
version = "0.0.1"
schema_version = 1
authors = ["Your Name <you@example.com>"]
description = "Starts the xpd language server for Python files"
repository = "https://git.cafe/dynd/xpd"
[language_servers.xpd]
name = "xpd"
languages = ["Python"]
Cargo.toml
[package]
name = "xpd-zed"
version = "0.0.1"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.7.0"
src/lib.rs
use zed_extension_api::{self as zed, settings::LspSettings, LanguageServerId, Result};
struct Xpd;
impl zed::Extension for Xpd {
fn new() -> Self {
Self
}
fn language_server_command(
&mut self,
_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let command = worktree
.which("xpd")
.ok_or("xpd is not on PATH. Install it with: uv tool install xpd")?;
Ok(zed::Command {
command,
args: vec!["lsp".into()],
env: worktree.shell_env(),
})
}
fn language_server_initialization_options(
&mut self,
id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<Option<zed::serde_json::Value>> {
Ok(LspSettings::for_worktree(id.as_ref(), worktree)?.initialization_options)
}
}
zed::register_extension!(Xpd);

Enable fix-on-format in Zed settings.json (put your existing Python formatter after the code action if you want both).

settings.json
{
"lsp": {
"xpd": {
"initialization_options": { "unsafeFixes": false }
}
},
"languages": {
"Python": {
"formatter": { "code_action": "source.fixAll.xpd" }
}
}
}

Install the Generic LSP Client extension and add the settings below to settings.json.

settings.json
{
"glspc.serverCommand": "xpd",
"glspc.serverCommandArguments": ["lsp"],
"glspc.languageId": "python",
"glspc.initializationOptions": { "unsafeFixes": false },
"editor.codeActionsOnSave": { "source.fixAll.xpd": "explicit" }
}
Setting Value
Command xpd lsp over stdio
Languages Python and every language named in project rules
Settings {"unsafeFixes": false} (or {"xpd": {"unsafeFixes": true}})
Exit code 0 after shutdown and exit, 1 on unexpected disconnect

xpd lsp runs the same rules as xpd check, respects # ast-grep-ignore: <pack>/<rule>, and links every diagnostic codeDescription to its rule page. Hover over any diagnostic to read the rule documentation inline. On file open and save, xpd lsp also publishes workspace-level structural HINT diagnostics from xpd enhance untangle (untangle/import-cycle, untangle/orphaned-module, and untangle/single-use-module).

Code action Kind Offered when
xpd: fix <pack>/<rule> quickfix (preferred) Cursor is on an issue with a safe fix
xpd: fix <pack>/<rule> (unsafe fix, may change behavior) quickfix Cursor is on an issue with an unsafe fix
xpd: apply every safe fix source.fixAll.xpd unsafeFixes is false and safe fixes exist
xpd: apply every fix, also unsafe ones that may change behavior source.fixAll.xpd unsafeFixes is true and fixes exist

xpd recognizes interactive cell markers (# %%, # <codecell>, and # In[1]:) and adjusts script-oriented rules automatically. Convert .ipynb notebooks to percent scripts with jupytext --to py:percent notebook.ipynb before checking.

Rule Behavior in cell files
python/import-side-effect and pandas/script-steps Skipped
numpy/result-discarded Ignores the final expression of each cell
pandas/filter-ladder, pandas/reassign-ladder, pandas/frame-column-write Cell markers reset statement runs
workspace and venv lookup
├── project root innermost workspace folder, else the file's directory
├── virtual env VIRTUAL_ENV, else nearest .venv (re-read on open and save)
└── project rules sgconfig.yml and xpd.yml (re-read on open, save, and YAML change)
Not provided by xpd lsp Reason
Completion, go-to-definition, rename, references xpd lints syntax without cross-file type resolution
Formatting Use Ruff
Dataflow graph of pipeline steps from xpd data-prep Separate command
Per-rule enable flags Run all rules and silence individual lines with # ast-grep-ignore