Skip to content

Editor Integration

StarLang ships star-lsp, a single binary that provides both LSP (Language Server Protocol) and DAP (Debug Adapter Protocol) support. Any editor that speaks LSP/DAP can use it.

Language Server (LSP)

The language server runs over JSON-RPC via stdio. Start it with:

star-lsp

Diagnostics

The server compiles your file on every save and reports errors inline. All compile-time checks work: type errors, unused variables, unknown identifiers, missing imports.

Completion

Trigger: typing or pressing . / :

Context What you get
Top-level Keywords (fn, var, if, for, struct, ...), types (number, string, i32, u8, ...), function names, struct names, variables, imported modules
After arr. Array methods: len, push, pop, contains, indexOf, slice, sort, reverse, join
After str. String methods: len, upper, lower, trim, contains, indexOf, split, substring
After dict. Dict methods: len, has, keys, values, delete
After myStruct. Struct field names with types
After console. log
After gc. collect

Each completion item includes type information in the detail field.

Hover

Hover over any identifier to see its type:

Symbol Hover result
Variable var count: i32
Function fn add(a: number, b: number): number
Struct name Full struct definition with all fields
Local variable var name: type (resolves struct names)
Keyword Brief description

Go to Definition

Ctrl+Click or F12 on a function or struct name to jump to its definition.

Find All References

Shift+F12 on any identifier to find all occurrences in the current file.

Rename Symbol

F2 on any identifier to rename it across the current file. All occurrences are updated simultaneously.

Document Symbols

Ctrl+Shift+O to see an outline of all functions and structs in the current file.

Format Document

Shift+Alt+F to auto-format the current file. The formatter normalizes indentation (based on {} blocks) and removes trailing whitespace. Respects the tabSize setting from your editor.

Signature Help

Trigger: ( or , inside a function call

Shows the full function signature with parameter types and highlights the active parameter as you type each argument.

add(a: number, b: number): number
    ^^^^^^^^^
    active parameter

Debug Adapter (DAP)

Start the debug adapter with:

star-lsp --dap

Breakpoints

Set breakpoints on any source line. The debugger stops execution when a breakpoint is hit.

Conditional Breakpoints

Right-click a breakpoint to add a condition. The debugger only stops when the condition is true:

count == 5
name != "test"

Supported operators: ==, !=, <, >, <=, >=.

Stepping

  • Step Over — execute the current line, skip into function calls
  • Step Into — step into the next function call
  • Step Out — run until the current function returns

Watch Expressions

In the Watch panel, add variable names to monitor their values as you step through code. Both local and global variables are supported.

Variable Inspection

When stopped at a breakpoint, inspect all variables in two scopes:

  • Locals — variables in the current function, with names from source
  • Globals — all global variables

Expandable variables: Arrays, dicts, and structs show a summary in the variables panel (e.g., [array:3], {dict:2}, {struct:4}). Click to expand and see individual elements:

Type Expanded view
Array [0], [1], [2], ... with values and types
Dict Key-value pairs with types
Struct Named fields (from struct definition) with values

VS Code Configuration

The StarLang VS Code extension handles LSP and DAP configuration automatically. If you need manual setup:

settings.json:

{
    "starlang.lspPath": "star-lsp"
}

launch.json:

{
    "type": "starlang",
    "request": "launch",
    "name": "Debug StarLang",
    "program": "${file}",
    "stopOnEntry": false
}