Skip to content
Kona

Language server (kona-lsp)

kona-lsp is a small Language Server Protocol implementation for Crema. It speaks JSON-RPC with Content-Length framing over stdio — the usual shape editors expect when you configure “run this command as the language server.”

Maven coordinates: org.konaframework:kona-lsp (module modules/lsp, package org.konaframework.lsp).

Method Behavior
initialize / initialized Advertise full document sync, completion (trigger @), diagnostic provider
shutdown / exit Clean teardown (exit code 0 after shutdown)
textDocument/didOpen / didChange / didClose Track buffer text; publishDiagnostics on open/change
textDocument/completion Suggest built-in Crema directives
textDocument/diagnostic Pull-model report of unknown @directive names

Comments {{-- … --}} are ignored when scanning for directives so examples inside comments do not warn.

Terminal window
./gradlew :kona-lsp:jar
java -jar modules/lsp/build/libs/kona-lsp-*.jar

Or:

Terminal window
./gradlew :kona-lsp:installDist
modules/lsp/build/install/kona-lsp/bin/kona-lsp

The process reads LSP messages from stdin and writes responses/notifications to stdout. Do not type into it interactively — let the editor own the pipes.

From an app checkout:

Terminal window
./grind ide:lsp

prints the same instructions without starting a server.

The public surface is usable without an editor. Kotlin:

val diags = CremaAnalyzer.diagnostics("@csrf @notReal")
val items = CremaAnalyzer.completions("@for", 0, 4)
val code = LspServer().serve(inputStream, outputStream)

Java:

List<CremaAnalyzer.Diagnostic> diags = CremaAnalyzer.diagnostics("@csrf @notReal");
List<CremaAnalyzer.CompletionItem> items = CremaAnalyzer.completions("@for", 0, 4);
int code = new LspServer().serve(inputStream, outputStream);

CremaDirectives.KNOWN / isKnown(name) expose the built-in directive set shared with completion and diagnostics.

  • Full Crema parsing or HTML validation
  • Route-name completion from your app’s router
  • Formatting or rename refactorings

Those can grow later; this milestone keeps the protocol surface small but real so editors can attach today.