Language Server
LSP features and how to set it up in your editor.
Features
The Loon language server speaks the standard Language Server Protocol, so it works with any editor that has LSP support. Here is what you get out of the box.
Diagnostics
Real-time type errors and warnings as you type.
Hover Types
Hover over any expression to see its inferred type.
Go to Definition
Jump to the definition of any binding or function.
Completions
Context-aware suggestions for names, keywords, and builtins.
Inlay Hints
Inline type annotations displayed next to let bindings and function parameters.
VS Code Setup
There is no official Loon extension on the marketplace yet. In the meantime you can use a generic LSP client extension and point it at loon lsp (see Generic LSP Setup below). Syntax highlighting is available via the tree-sitter grammar in the repository's tree-sitter-loon directory.
Neovim Setup
Neovim has excellent LSP support built in. Add this to your config and Loon files will get full language server features as soon as you open them.
LUA
vim.api.nvim_create_autocmd('FileType', {
pattern = 'loon',
callback = function()
vim.lsp.start({
name = 'loon',
cmd = { 'loon', 'lsp' },
root_dir = vim.fs.dirname(
vim.fs.find({ 'main.loon' }, { upward = true })[1]
),
})
end,
})Tip
Set filetype detection with: vim.filetype.add({ extension = { loon = 'loon' } })
Generic LSP Setup
If you use a different editor, you can still get full LSP support as long as it has an LSP client. Point it at the Loon binary with these settings.
Command
loon lsp
Transport
stdio (stdin/stdout)
File types
.loon
The server communicates over standard input/output using the LSP JSON-RPC protocol. No special flags or initialization options are required.