lsp-format-code

Format files or selections using the language server's formatter.

102|5|Updated Apr 6, 2026
One-click install
npx skills add https://github.com/blackwell-systems/agent-lsp --skill lsp-format-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lsp-format-code
Source: https://github.com/blackwell-systems/agent-lsp/tree/main/skills/lsp-format-code
Command: npx skills add https://github.com/blackwell-systems/agent-lsp --skill lsp-format-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Format a file or selection using the language server's formatter. Ensures consistent style across codebases.

Core Features & Use Cases

  • Full-file formatting via format_document.
  • Range-based formatting via format_range.
  • Apply edits with apply_edit to commit changes.
  • Check server capabilities with get_server_capabilities to determine support for documentFormattingProvider and documentRangeFormattingProvider.

Quick Start

Open a file and run the lsp-format-code skill to format the entire file, then apply the edits with the provided apply_edit action.

Frequently Asked Questions about lsp-format-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format code using a language server?

Format code using a language server by invoking document formatting providers that return TextEdit arrays for application. This skill normalizes code style across supported languages via the agent-lsp MCP server.

Can I format a specific selection of code instead of the entire file?

Yes, you can format a specific code selection using documentRangeFormattingProvider capabilities. This range-based formatting targets only the highlighted text rather than normalizing the entire document.

How do I check if my language server supports code formatting?

Check if your language server supports code formatting by querying get_server_capabilities for documentFormattingProvider and documentRangeFormattingProvider. These capabilities determine if full-file or range formatting is available.

Do I need the agent-lsp MCP server to format code?

Yes, you need the agent-lsp MCP server to format code because it exposes the documentFormattingProvider and documentRangeFormattingProvider interfaces and returns TextEdit arrays required to apply formatting changes.

When should I format code with a language server formatter?

Format code with a language server formatter before committing changes or after code generation to normalize formatting. This ensures consistent style across your codebase regardless of the input source.

How do I apply formatting edits returned by the language server?

Apply formatting edits by executing the apply_edit action on the TextEdit array returned by the formatting provider. This commits the style normalization changes directly to your file or selection.