Language Server Protocol

Turn ships with a built-in Language Server Protocol (LSP) implementation, providing real-time editor support for syntax highlighting, error diagnostics, navigation, and documentation. The LSP server is compiled into the same Turn binary — no separate installation is required.


Starting the Server

The Turn binary includes a lsp subcommand that starts the language server over standard I/O. Any editor that supports the Language Server Protocol can connect to it.

terminal
turn lsp

This spawns a long-running process that communicates with the editor using the LSP JSON-RPC protocol over stdin and stdout. The server initializes by scanning the workspace for .tn files and building an in-memory representation of the project structure.


Capabilities

The Turn language server currently supports the following editor features. The implementation priority follows real-world developer workflows — diagnostics and navigation first, with intelligent completions planned for an upcoming release.

FeatureStatusDetails
Syntax highlighting✅ ShippingProvided via a TextMate grammar bundled with the VS Code extension. Highlights keywords, strings, comments, types, and Turn-specific primitives.
Error diagnostics✅ ShippingReal-time parse errors and semantic errors are reported to the editor as the developer types. Errors include source locations and contextual messages.
Go-to-definition✅ ShippingJump to the definition of variables, turn closures, structs, and imported modules. Works across file boundaries for use declarations.
Hover documentation✅ ShippingHovering over an identifier shows its inferred type, the defining location, and a brief description for built-in primitives.
Completions🚧 PlannedContext-aware auto-completion for keywords, variable names, struct fields, and module exports.

VS Code Extension

The official Turn extension for Visual Studio Code lives in the editors/vscode/ directory of the Turn repository. It provides syntax highlighting out of the box and connects to the Turn LSP server for advanced features.

Installation from source:

terminal
cd editors/vscode
npm install && npm run compile
# Then in VS Code: "Developer: Install Extension from Location..."
# and select the editors/vscode directory

Once installed, the extension performs the following on activation:

  1. Locates the Turn binary. The extension searches for turn on the system $PATH. If the binary is not found, it displays a notification with installation instructions.
  2. Spawns the language server. The extension starts turn lsp as a child process, communicating over standard I/O.
  3. Connects the Language Client. The VS Code Language Client connects to the server and begins receiving diagnostics, hover information, and definition locations.

The extension registers .tn files as the Turn language type and applies the bundled TextMate grammar for basic syntax highlighting independent of the LSP server.

TIP

The VS Code extension will be published to the Visual Studio Code Marketplace once Turn reaches a stable release. In the meantime, install it from source using the instructions above, or build the .vsix package with npx vsce package and install it directly.


Other Editors

Any editor that supports the Language Server Protocol can use the Turn language server. The setup is the same across editors:

  1. Ensure the turn binary is on your $PATH.
  2. Configure your editor's LSP client to run turn lsp as the server command for .tn files.
  3. Set the language identifier to turn.

This has been tested with Neovim (via nvim-lspconfig), Helix, and Sublime Text. Emacs support via lsp-mode or eglot works with the same configuration.