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.
turn lspThis 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.
| Feature | Status | Details |
|---|---|---|
| Syntax highlighting | ✅ Shipping | Provided via a TextMate grammar bundled with the VS Code extension. Highlights keywords, strings, comments, types, and Turn-specific primitives. |
| Error diagnostics | ✅ Shipping | Real-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 | ✅ Shipping | Jump to the definition of variables, turn closures, structs, and imported modules. Works across file boundaries for use declarations. |
| Hover documentation | ✅ Shipping | Hovering over an identifier shows its inferred type, the defining location, and a brief description for built-in primitives. |
| Completions | 🚧 Planned | Context-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:
cd editors/vscode
npm install && npm run compile
# Then in VS Code: "Developer: Install Extension from Location..."
# and select the editors/vscode directoryOnce installed, the extension performs the following on activation:
- Locates the Turn binary. The extension searches for
turnon the system$PATH. If the binary is not found, it displays a notification with installation instructions. - Spawns the language server. The extension starts
turn lspas a child process, communicating over standard I/O. - 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:
- Ensure the
turnbinary is on your$PATH. - Configure your editor's LSP client to run
turn lspas the server command for.tnfiles. - 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.