Editor Setup
BioLang ships with a built-in language server (bl lsp) that provides
real-time diagnostics, completions, hover documentation, and more. This page covers
how to configure it for the most popular editors.
Language Server Features
The BioLang LSP supports the following capabilities:
| Feature | Description |
|---|---|
| Diagnostics | Real-time syntax and type errors as you type |
| Completion | Context-aware completions for functions, variables, modules, and sequence methods |
| Hover | Type information and documentation on hover |
| Go to Definition | Jump to function and variable definitions |
| Find References | Find all usages of a symbol |
| Rename | Safe rename across the file |
| Formatting | Format document using bl fmt rules |
| Signature Help | Parameter hints as you type function arguments |
| Semantic Tokens | Rich syntax highlighting for DNA/RNA/protein literals |
VS Code
The official BioLang extension for Visual Studio Code provides the best out-of-the-box experience with syntax highlighting, LSP integration, and snippet support.
Installation
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "BioLang"
- Click Install
Or install from the command line:
code --install-extension biolang.biolang-vscode
Configuration
The extension automatically detects the bl binary from your PATH. To use a
custom binary path or pass additional LSP flags, add these settings to your
settings.json:
{
"biolang.serverPath": "/usr/local/bin/bl",
"biolang.lsp.args": ["lsp", "--log-level", "info"],
"biolang.formatOnSave": true,
"biolang.trace.server": "messages"
}
Recommended Companion Extensions
- Error Lens — inline diagnostic messages
- indent-rainbow — visualize indentation levels
- Bracket Pair Colorizer — matching bracket colors
Snippets
The extension includes built-in snippets for common patterns:
| Prefix | Expands to |
|---|---|
blfn |
Function definition |
blpipe |
Pipe chain template |
blfastq |
FASTQ reading boilerplate |
blfor |
For loop |
blmatch |
Match expression |
Neovim
Neovim users can configure the BioLang LSP via nvim-lspconfig.
Basic Setup
Add the following to your init.lua:
-- Register BioLang file type
vim.filetype.add({
extension = {
bl = "biolang",
},
})
-- Configure LSP
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.biolang then
configs.biolang = {
default_config = {
cmd = { "bl", "lsp" },
filetypes = { "biolang" },
root_dir = lspconfig.util.root_pattern(".git", "biolang.toml"),
settings = {},
},
}
end
lspconfig.biolang.setup({
on_attach = function(client, bufnr)
-- Format on save
if client.supports_method("textDocument/formatting") then
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ async = false })
end,
})
end
end,
})
Tree-sitter Grammar
For enhanced syntax highlighting, install the BioLang Tree-sitter grammar via
nvim-treesitter:
require("nvim-treesitter.configs").setup({
ensure_installed = { "biolang" },
highlight = { enable = true },
})
Telescope Integration
Use Telescope for fuzzy-finding BioLang symbols:
vim.keymap.set("n", "<leader>bs", function()
require("telescope.builtin").lsp_document_symbols({
symbols = { "function", "variable" },
})
end, { desc = "BioLang symbols" })
Emacs
Emacs users can configure BioLang via lsp-mode or eglot.
lsp-mode Setup
;; Define BioLang major mode
(define-derived-mode biolang-mode prog-mode "BioLang"
"Major mode for editing BioLang files."
(setq-local comment-start "# ")
(setq-local comment-end ""))
(add-to-list 'auto-mode-alist '("\\.bl\\'" . biolang-mode))
;; LSP configuration
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration '(biolang-mode . "biolang"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("bl" "lsp"))
:activation-fn (lsp-activate-on "biolang")
:server-id 'biolang-lsp)))
(add-hook 'biolang-mode-hook #'lsp-deferred)
eglot Setup
(add-to-list 'eglot-server-programs
'(biolang-mode . ("bl" "lsp")))
(add-hook 'biolang-mode-hook #'eglot-ensure)
Other Editors
Any editor that supports the Language Server Protocol can work with BioLang. The LSP server is started with:
bl lsp
It communicates over stdin/stdout using the standard LSP JSON-RPC protocol. Common editors with LSP support include:
- Sublime Text — via the LSP package
- Helix — add to
languages.toml - Zed — custom language server configuration
- Kate — via built-in LSP client
Helix Example
Add to ~/.config/helix/languages.toml:
[[language]]
name = "biolang"
scope = "source.biolang"
file-types = ["bl"]
roots = ["biolang.toml"]
language-servers = ["biolang-lsp"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
[language-server.biolang-lsp]
command = "bl"
args = ["lsp"]
Verifying the Setup
To confirm everything is working, create a test file test.bl:
# test.bl — verify editor integration
let seq = dna"ATCGATCG"
let gc = gc_content(seq)
print("GC content: {gc}")
You should see:
- Syntax highlighting for keywords, strings, DNA literals, and comments
- Completions when typing
seq |>(offeringgc_content,reverse_complement, etc.) - Hover information when hovering over
gc_content - No diagnostic errors (red squiggles)
Next Steps
With your editor configured, explore the REPL Tour to learn about BioLang's interactive mode.