A language server for the Stan probabilistic programming language written in TypeScript and using Bun to build an executable binary.
- Auto-completion: Keywords, functions, distributions, data types, and constraints
- Hover information: Documentation and type information
- Diagnostics: Real-time syntax and semantic error detection
- Code formatting: Using the official Stan compiler
- Include file support: Full
#includeresolution and compilation
Install the extension from Marketplace or open-vsx.
The Stan language server is installable with
Mason by running :MasonInstall stan-language-server.
The language server can also be configured manually by first installing
the language server executable. This can be done directly via npm install -g stan-language-server-bin or by downloading the latest executable from
GitHub and putting
it somewhere in your PATH.
Add lsp/stan_ls.lua to your Neovim config directory (e.g., ~/.config/nvim/):
return {
cmd = { "stan-language-server", "--stdio" },
filetypes = { "stan" },
root_markers = { ".git" },
settings = {
maxLineLength = 78,
includePaths = {},
},
}Then enable it:
vim.lsp.enable("stan_ls")local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
configs.stan_ls = {
default_config = {
cmd = { "stan-language-server", "--stdio" },
filetypes = { "stan" },
root_dir = lspconfig.util.root_pattern(".git"),
settings = {
maxLineLength = 78,
includePaths = {},
},
},
}
lspconfig.stan_ls.setup({})Install the Stan extension.
Using LSP for Sublime Text, download the latest release and add the following to the settings file:
{
"clients": {
"stan-lsp": {
"enabled": true,
"command": ["/YOUR/PATH/TO/stan-language-server", "--stdio"],
"selector": "source.stan | source.stanfunctions",
"initializationOptions": {},
"settings": {
"stan-language-server": { "includePaths": [], "maxLineLength": 78 }
}
}
}
For emacs users, we recommend using mason.el to download from the same source as neovim above.
Assuming you are using stan-ts-mode,
add the following to your init.el.
(use-package mason
:config
(mason-setup
(dolist (pkg '("stan-language-server"))
(unless (mason-installed-p pkg)
(ignore-errors (mason-install pkg))))) )
(use-package eglot
:hook (stan-ts-base-mode . eglot-ensure)
:config
(add-to-list 'eglot-server-programs '(stan-ts-base-mode
. ("stan-language-server" "--stdio")))Development uses bun
To install dependencies:
bun installBuilding a binary executable:
bun build:binaryTo run unit tests:
bun testTo run end-to-end tests:
bun test:e2e