Problem
Developers editing .gwdk files need live feedback from the same language tooling used by the CLI. The current VS Code extension shells out to separate CLI commands for diagnostics and formatting, which works for one editor but does not give other editors a standard integration surface.
Goals
- Provide a Language Server Protocol entrypoint through
gowdk lsp. - Reuse existing lexer, parser, formatter, and compiler validation behavior.
- Support unsaved editor buffers without writing temporary files.
- Keep the first version dependency-free and small enough to evolve with the language grammar.
Non-Goals
- Implement semantic analysis beyond the current manifest validation rules.
- Replace the site-map visualizer or file-moving VS Code commands.
- Add request-time SSR behavior or compile/codegen features.
- Add editor-specific packages to the Go compiler core.
Users And Permissions
- Primary users: developers authoring
.gwdkpages and components. - Roles or permissions: local editor process only.
- Data visibility rules: diagnostics and edits are derived from local file contents and should not leave the machine.
User Flow
- User starts an LSP-capable editor for a workspace containing
.gwdkfiles. - The editor launches
gowdk lspover stdio. - The language server validates opened buffers, publishes diagnostics, returns formatting edits, offers completions, returns hover text, jumps to declarations, finds references, offers quick fixes, and colors syntax through semantic tokens.
Requirements
Functional
- Start a JSON-RPC/LSP server with
gowdk lsp. - Handle
initialize,initialized,shutdown, andexit. - Accept full-document
textDocument/didOpen,textDocument/didChange,textDocument/didSave, andtextDocument/didClosenotifications. - Publish diagnostics using the current GOWDK parser and validation rules.
- Return whole-document formatting edits using
gowdk fmtbehavior. - Return keyword completions for annotations, render modes, blocks, and
g:directives. - Return project completions for open-document components, layouts, guards, routes, page IDs, stores, local component props, and inferred component state or value fields.
- Return hover text for known annotations, directives, blocks, routes, stores, props, components, layouts, guards, and handler symbols from open documents.
- Return go-to-definition locations for same-package and
use-qualified component calls from open documents. - Return go-to-definition locations for exported Go handler symbols when the matching Go file is open in the editor session.
- Return references for exact
.gwdkproject symbols across open documents, including page IDs, routes, components, stores, and guards. - Return quick-fix code actions for old action/API block syntax migrations and
missing GOWDK
usealiases. - Return full-document semantic tokens for
.gwdkdecorators, identifiers, strings, and operators.
Non-Functional
- Performance: validate one open buffer quickly enough for interactive editing.
- Reliability: malformed protocol messages should return JSON-RPC errors instead of crashing.
- Accessibility: editor clients should receive standard diagnostics and completion metadata.
- Security/privacy: no network access and no external process execution inside the language server.
- Observability: protocol errors should be written to stderr.
Acceptance Criteria
gowdk lspstarts and answers an LSPinitializerequest.- Opening an invalid
.gwdkbuffer publishes diagnostics without requiring the buffer to be saved. textDocument/formattingreturns a replacement edit matchinggowdk fmt.textDocument/completionreturns the same language keywords exposed by editor tooling.textDocument/completionreturns open-project symbols for components, layouts, guards, routes, stores, props, and component state/value fields.textDocument/hoverreturns concise markdown help for language tokens and open-project symbols.textDocument/definitionreturns component declaration locations for open-project component calls.textDocument/definitionreturns open-buffer Go declaration locations for exported handler symbols.textDocument/referencesreturns open-document references for page IDs, routes, components, stores, and guards.textDocument/codeActionreturns quick fixes for old endpoint syntax and missing GOWDK use aliases.textDocument/semanticTokens/fullreturns encoded token data for open.gwdkbuffers.go test ./...andgo build ./cmd/gowdkpass.
Edge Cases
- Missing
@routeor@guardshould publish a diagnostic at the relevant source location when available.@pageis optional for file-backed pages. - Closing a document should clear diagnostics for that URI.
- Unknown LSP requests should return a method-not-found error.
- Notifications without params should be ignored when safe.
Dependencies
- Internal:
internal/lang,internal/parser,internal/compiler,internal/gwdkir. - External: none.
Open Questions
- Workspace-wide manifest validation can reuse the existing duplicate page and route checks once the LSP maintains a project-wide manifest.
- Incremental sync can replace full-document sync if large
.gwdkfiles become common.