Editor Support
xx lsp runs a Language Server Protocol server over standard input and standard output. Configure an editor's LSP client to start xx lsp for xx Starlark files.
The server handles .star, .build, .starlark, .bzl, and .bazel files inside a .xx directory. Files elsewhere are ignored.
Supported features include:
- Completion for built-in package names, package symbols, loaded symbols, local variables, function parameters, and standard Starlark names.
- Hover documentation and signatures from xx's built-in package catalog.
- Go to definition for names defined in the same file, including loaded symbol aliases.
- Syntax, name-resolution, package-version, package-symbol, and built-in function-call type diagnostics.
The server uses full-document synchronization and UTF-16 positions. It does not execute build files or download tools while analyzing them.
Neovim
Neovim 0.11 and newer can configure the server through vim.lsp.config. This setup uses Neovim's existing starlark and bzl filetypes so syntax highlighting continues to work. It also recognizes .build files below .xx as Starlark and prevents the server from attaching to files outside .xx.
local function xx_root_dir(bufnr, on_dir)
local filename = vim.api.nvim_buf_get_name(bufnr)
for directory in vim.fs.parents(filename) do
if vim.fs.basename(directory) == ".xx" then
on_dir(vim.fs.dirname(directory))
return
end
end
end
-- Set .build files as Starlark
vim.filetype.add({
pattern = {
[".*/%.xx/.*%.build"] = { "starlark", { priority = 1000 } },
},
})
vim.lsp.config("xx", {
cmd = { "xx", "lsp" },
filetypes = { "starlark", "bzl" },
root_dir = xx_root_dir,
})
vim.lsp.enable("xx")
The xx executable must be available on Neovim's PATH.
OpenCode
Add xx as a custom language server in the project's opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"lsp": {
"xx": {
"command": ["xx", "lsp"],
"extensions": [".star", ".build", ".starlark", ".bzl", ".bazel"]
}
}
}
The xx executable must be available on OpenCode's PATH. Restart OpenCode after changing its configuration.
Visual Studio Code
Build the extension yourself using xx run vscode or install it from Open VSX Registry or Visual Studio Marketplace.
Other Editors
The exact configuration depends on the editor. Register a Starlark language server with this command:
xx lsp
Associate it with the supported file extensions, then use a .xx directory as part of the file path. No project initialization request or command-line arguments are required.