lsp-format-code

Solid

Format a file or selection using the language server's formatter. Use before committing to apply consistent style, or after generating code to clean up indentation and spacing. Supports full-file and range-based formatting.

Code & Development 56 stars 2 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
58
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

> Requires the agent-lsp MCP server. # lsp-format-code Format a file or selection using the language server's formatter — the same formatting engine your IDE uses. Applies language-specific rules (gofmt, prettier, rustfmt, black) without requiring those tools to be on PATH separately. ## When to use - Before committing: ensure consistent style across edited files - After generating code: clean up AI-generated indentation and spacing - After a refactor that shifted indentation levels - When a linter flags style violations fixable by the formatter Use `/lsp-safe-edit` instead when you are making a logic change and want before/after diagnostic comparison alongside the edit. --- ## Workflow ### Step 1 — Check formatting is supported (optional) If unsure whether the language server supports formatting for this file, check capabilities first: ``` mcp__lsp__get_server_capabilities({ "file_path": "<file>" }) ``` Look for `documentFormattingProvider` (full-file) and `documentRangeFormattingProvider` (range). If neither is present, the server does not support formatting — stop and report. Skip this step if you know the language supports formatting (Go, TypeScript, Rust, Python all do via their standard servers). ### Step 2 — Open the file ``` mcp__lsp__open_document({ "file_path": "/abs/path/to/file.go", "language_id": "go" }) ``` ### Step 3 — Request formatting edits **Full file:** ``` mcp__lsp__format_document({ "file_path": "/abs/path/to/file.go" }) ``` **Selection ...

Details

Author
blackwell-systems
Repository
blackwell-systems/agent-lsp
Created
2 months ago
Last Updated
today
Language
Go
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category