Document ★ 3,381

lsp

How the atopile Language Server works (pygls), how it builds per-document graphs for completion/hover/defs, and the invariants for keeping it fast and crash-proof.

cd ~/.claude/skills
git clone https://github.com/atopile/atopile.git atopile

LSP Module

The lsp module (located in src/atopile/lsp/) implements the Language Server Protocol for atopile. It provides IDE features like autocomplete, go-to-definition, and diagnostics (error reporting) for ato files.

Quick Start

Run the server on stdio (what editors expect):

python -m atopile.lsp.lsp_server

Relevant Files

  • Server implementation: src/atopile/lsp/lsp_server.py
    • owns global LSP_SERVER (pygls LanguageServer)
    • maintains per-document DocumentState (graph/typegraph/build_result)
    • implements completion/hover/definition/diagnostics handlers
  • Utilities: src/atopile/lsp/lsp_utils.py
  • Optional debugging helper: src/atopile/lsp/_debug_server.py

Dependants (Call Sites)

  • VSCode Extension: The designated client for this server.
  • Compiler: The LSP invokes the compiler (often in a partial or fault-tolerant mode) to understand the code structure.

How to Work With / Develop / Test

Core Concepts

  • Partial Compilation: Unlike the CLI build, the LSP must handle broken or incomplete code without crashing.
  • Latency: Features must be fast (<50ms for typing, <200ms for completion).
  • Per-document graphs: each open document has an isolated GraphView + TypeGraph stored in DocumentState.
  • Keep last good build: the server keeps the last successful BuildFileResult to power completion/hover even when the current edit has errors.

Development Workflow

  1. Edit handlers/helpers in src/atopile/lsp/lsp_server.py.
  2. Run completion tests (fast loop) and verify GraphView cleanup paths.

Testing

  • Integration-style tests: ato dev test --llm test/test_lsp_completion.py -q

Best Practices

  • Robustness: Never let the server crash. Catch all exceptions in handlers and log them.
  • Debouncing: Don’t trigger expensive operations on every keystroke.

Core Invariants (easy to regress)

  • Always destroy old graphs on rebuild/reset (DocumentState.reset_graph calls GraphView.destroy()).
  • Do not assume builds succeed; most features must handle:
    • syntax errors (ANTLR)
    • partial typegraphs
    • exceptions from linking/deferred execution

Benzer skill'ler

canvas-design Document

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

anthropics/skills ★ 146,722
doc-coauthoring Document

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or

anthropics/skills ★ 146,722
docx Document

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images

anthropics/skills ★ 146,722
pdf Document

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or

anthropics/skills ★ 146,722
pptx Document

Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working w

anthropics/skills ★ 146,722
theme-factory Document

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

anthropics/skills ★ 146,722
Daha fazla: Document →