Language Server for Moose projects. Provides real-time SQL syntax validation for SQL strings embedded in TypeScript sql tagged templates and Python sql() function calls.
These features appear directly in your IDE when editing sql tagged template literals (TypeScript) or sql() function calls (Python):
| Feature | What You See in Your Editor |
|---|---|
| Error Diagnostics | Red squiggly underlines on SQL syntax errors with error messages |
| Auto-Complete | Popup suggestions for ClickHouse functions, keywords, data types, table engines, formats, and settings |
| Context-Aware Completions | Only relevant completions based on cursor position (e.g., only table engines after ENGINE =, only formats after FORMAT) |
| Hover Documentation | Tooltip with syntax, description, and examples when you hover over any ClickHouse function, keyword, or type |
| Code Actions | "Format SQL" action available in your editor's quick-fix menu to auto-format SQL strings (TypeScript only) |
| Snippet Support | Function completions insert with tab stops for parameters (e.g., toHour($1)) |
- ClickHouse dialect - Uses the same SQL parser as the Moose CLI
- ClickHouse version awareness - Detects your ClickHouse version from
docker-compose.ymland provides version-appropriate completions - Editor agnostic - Works with any LSP-compatible editor
- Monorepo support - Automatically detects Moose projects in subdirectories
- Zero configuration - Just install and it works
- Node.js 18+ (for running the LSP server)
- A Moose project with:
- TypeScript:
@514labs/moose-libinpackage.json - Python:
moose-libinpyproject.toml,requirements.txt, orsetup.py
- TypeScript:
- An LSP-compatible editor
npm install -g @514labs/moose-lspVerify installation:
which moosestack-lspSee Development for build prerequisites and instructions. After building, link the package globally:
cd packages/lsp-server
pnpm link --globalVerify installation:
which moosestack-lspAdd to ~/.config/nvim/lua/plugins/moosestack-lsp.lua:
-- Setup moosestack LSP after plugins load
vim.api.nvim_create_autocmd("User", {
pattern = "LazyDone",
callback = function()
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.moosestack then
configs.moosestack = {
default_config = {
cmd = { "moosestack-lsp", "--stdio" },
filetypes = { "typescript", "python" },
root_dir = lspconfig.util.root_pattern("moose.config.toml", "package.json", "pyproject.toml"),
},
}
end
lspconfig.moosestack.setup({})
end,
})
return {}The extension is published to both the VS Code Marketplace and Open VSX Registry (used by Cursor). To install:
- Open VS Code or Cursor
- Press
Cmd+Shift+X(Mac) orCtrl+Shift+X(Windows/Linux) to open Extensions - Search for "MooseStack LSP" or "moosestack-lsp"
- Click Install
That's it! The extension will automatically start when you open TypeScript or Python files in a Moose project.
For TypeScript:
- Open a TypeScript file in a Moose project (must have
@514labs/moose-libinpackage.json) - Type some SQL in a
sqltagged template literal - You should see:
- Error diagnostics (red squiggles) for invalid SQL
- Completions when typing in SQL strings (press
Ctrl+SpaceorCmd+Space) - Hover documentation when hovering over ClickHouse functions
For Python:
- Open a Python file in a Moose project (must have
moose-libinpyproject.tomlorrequirements.txt) - Type some SQL in a
sql()function call or f-string with:colformat - You should see the same diagnostics, completions, and hover documentation
- Project Detection - The LSP searches for:
package.jsonfiles containing@514labs/moose-lib(TypeScript)pyproject.toml,requirements.txt, orsetup.pycontainingmoose-lib(Python)
- Source Analysis:
- TypeScript: Uses the TypeScript compiler API to parse source files and find
sqltagged template literals - Python: Uses tree-sitter to parse Python files and find
sql()function calls and f-strings with:colformat
- TypeScript: Uses the TypeScript compiler API to parse source files and find
- Validation - Each SQL string is validated using a WASM-compiled Rust SQL parser with ClickHouse dialect
- Diagnostics - Validation errors are published as LSP diagnostics, appearing as error squiggles in your editor
Prerequisites: Rust, wasm-pack, pnpm
# Clone the repository
git clone https://github.com/514-labs/moosestack-lsp.git
cd moosestack-lsp
# Install dependencies
pnpm install
# Build all packages (includes WASM compilation)
pnpm build
# Run tests
pnpm test
# Lint (Biome + Clippy)
pnpm lintmoosestack-lsp/
├── packages/
│ ├── sql-validator/ # Rust SQL validator (compiles to WASM)
│ ├── sql-validator-wasm/ # WASM wrapper + TypeScript bindings
│ ├── lsp-server/ # LSP server implementation
│ └── vscode-extension/ # VS Code/Cursor extension
├── scripts/
│ └── release.sh # Release automation script
└── .github/workflows/ # CI/CD pipelines
- Check your editor's LSP logs to ensure the server is starting
- Verify your project has:
- TypeScript:
@514labs/moose-libinpackage.jsondependencies - Python:
moose-libinpyproject.toml,requirements.txt, orsetup.py
- TypeScript:
- Ensure you're editing
.tsor.pyfiles - For TypeScript: Check that
tsconfig.jsonexists in your project root
- As-you-type validation
- SQL completions with intelligent sorting (functions, keywords, types, engines, formats)
- Hover documentation for ClickHouse functions and types
- ClickHouse version detection
- Context-aware completions (show only relevant items based on SQL context)
- VS Code extension
- Python support
Contributions welcome! Please open an issue or PR on GitHub.
MIT
The team at Fiveonefour labs, the maintainers of MooseStack.