Editor support: trine lsp (32a-d, 33a-b)

trine lsp is a language server on stdin/stdout (LSP, full-document sync). It gives:

Hover, hints and definitions use the last version of the buffer that type-checked, so they don't flicker away while a line is half-typed.

Neovim (0.10+)

vim.filetype.add({ extension = { tr = "trine" } })
vim.api.nvim_create_autocmd("FileType", { pattern = "trine", callback = function()
  vim.lsp.start({ name = "trine", cmd = { "trine", "lsp" }, root_dir = vim.fn.getcwd() })
  vim.lsp.inlay_hint.enable(true)
end })

VS Code

Any generic LSP client extension works; point it at the command trine lsp for *.tr files.

Helix (languages.toml)

[[language]]
name = "trine"
file-types = ["tr"]
language-servers = ["trine"]

[language-server.trine]
command = "trine"
args = ["lsp"]

Incremental (32d)

The server keeps its work between keystrokes: each file's parse is kept by its content, and while the imported modules haven't changed (their paths and texts are fingerprinted at every check) their functions' types are reused instead of their bodies being checked again (a module can't see the file that imports it, so its types can't depend on it). Only the open file is linted, and a burst of changes is checked once, at its end. A module edited on disk is picked up at the next keystroke.

python3 tools/lsp_bench.py types into a generated 5,000-line project (a main file and four modules) and reports the time from each keystroke to its diagnostics and inlay hints; a test holds the 95th percentile under 100 ms (on the development machine: ~3 ms typical, ~20 ms at worst, against ~50 ms for a full check). TRINE_LSP_TIMING=1 prints the phases to stderr.

Ownership, copy and check hints (33b)

Once the buffer has been still for 300 ms the server runs trine hints on it in another process (the same pipeline native code is compiled with: borrow inference, drop-reuse, the bounds verifier) and asks the editor to refresh its inlay hints:

Each hint's tooltip says why. trine hints f.tr prints them on the command line.