Skip to content
Draft

Language Server

Draft provides a Language Server for IDE integration with full editing features.

Terminal window
draft lsp install

Intelligent completion for:

  • Variables and actions
  • Record fields
  • Module imports
  • Type members
  • Keywords
@// Type @user# to see available fields
@user = User { name: "Alice", age: 30 }
@user#name @// Completion shows: name, age, email

Hover over any symbol to see:

  • Type information
  • Documentation
  • Signature
action add(@a: Int, @b: Int) -> Int
return @a + @b
fin action.
@// Hover over "add" shows:
@// action add(a: Int, b: Int) -> Int
@// Returns the sum of two integers.

Jump to where a symbol is defined:

  • F12 or Ctrl+Click — Go to definition
  • Ctrl+Alt+Click — Go to type definition

Find all references to a symbol:

  • Shift+F12 — Find all references
  • F2 — Rename symbol

Real-time error and warning reporting:

  • Type errors
  • Unused variables
  • Missing fields
  • Unreachable code

Quick fixes and refactorings:

  • Add missing imports
  • Generate record fields
  • Implement missing actions
  • Fix type mismatches

Format document or selection:

  • Shift+Alt+F — Format document
  • Format on save

Parameter hints when calling actions:

@add(|) @// Shows: add(a: Int, b: Int) -> Int

Navigate symbols in the file:

  • Ctrl+Shift+O — Go to symbol

Search symbols across the project:

  • Ctrl+T — Go to symbol in workspace

Inline information:

  • Reference counts
  • Test status
  • Implementation counts

Inline type annotations:

@x = 42 @// Shows: @x: Int = 42
@name = "Alice" @// Shows: @name: String = "Alice"

Syntax highlighting with semantic information:

  • Variables
  • Types
  • Actions
  • Keywords
  • Comments

Install the Draft extension:

Terminal window
code --install-extension draft-lang.draft

Or search for “Draft” in the extension marketplace.

Features:

  • Syntax highlighting
  • Code completion
  • Error checking
  • Formatting
  • Debugging
  • Testing

Using nvim-lspconfig:

require'lspconfig'.draft_lsp.setup{}

Using coc.nvim:

{
"languageserver": {
"draft": {
"command": "draft",
"args": ["lsp"],
"filetypes": ["draft"],
"rootPatterns": ["draft.toml"]
}
}
}

Using vim-lsp:

if executable('draft')
augroup lsp_draft
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'draft',
\ 'cmd': {server_info -> ['draft', 'lsp']},
\ 'allowlist': ['draft'],
\ })
augroup END
endif

Using lisp-mode:

(use-package lsp-draft
:ensure t
:hook (draft-mode . lsp))

Install using Package Control:

  1. Ctrl+Shift+P — Command Palette
  2. “Package Control: Install Package”
  3. “Draft”

Or manually:

{
"clients": {
"draft": {
"command": ["draft", "lsp"],
"enabled": true,
"languageId": "draft",
"scopes": ["source.draft"],
"syntaxes": ["Packages/Draft/Draft.sublime-syntax"]
}
}
}

Install the Draft plugin:

  1. Settings → Plugins → Marketplace
  2. Search “Draft”
  3. Install and restart
[lsp]
inlay_hints = true
code_lens = true
semantic_tokens = true
diagnostics = true
completion_snippets = true
{
"draft.lsp.path": "draft",
"draft.lsp.inlayHints": true,
"draft.lsp.codeLens": true,
"draft.lsp.semanticTokens": true,
"draft.format.enable": true,
"draft.format.onSave": true
}
Terminal window
draft lsp [options]

Options:

  • --stdio — Use stdio transport (default)
  • --tcp <port> — Use TCP transport
  • --pipe <name> — Use named pipe
  • --log <level> — Log level (error, warn, info, debug, trace)
  • --log-file <path> — Log file path

The Draft LSP implements the Language Server Protocol 3.17:

Feature Status
textDocument/completion Full
textDocument/hover Full
textDocument/definition Full
textDocument/references Full
textDocument/diagnostic Full
textDocument/codeAction Full
textDocument/formatting Full
textDocument/signatureHelp Full
textDocument/documentSymbol Full
textDocument/rename Full
textDocument/inlayHint Full
textDocument/semanticTokens Full
textDocument/codeLens Full
workspace/symbol Full
workspace/didChangeWatchedFiles Full
Terminal window
@// Check installation
draft lsp --version
@// Check logs
draft lsp --log debug --log-file lsp.log
Terminal window
@// Ensure project is initialized
draft init
@// Check draft.toml exists
ls draft.toml
@// Disable expensive features
[lsp]
semantic_tokens = false
code_lens = false
Metric Value
Startup time < 100ms
Completion latency < 50ms
Memory usage ~50 MB
Index time (10k LOC) < 2s