An unholy spell checker for code
Please give a ⭐ if you find Codebook useful!
Codebook is a spell checker for code. It binds together the venerable Tree Sitter and the fast spell checker Spellbook. Included is a Language Server for use in (theoretically) any editor. Everything is done in Rust to keep response times snappy and memory usage low.
No configuration needed. Codebook will automatically detect the language you are editing and mark issues for you. Codebook will try to only mark issues for words that you create, where they are initially defined.
However, if you are looking for a traditional spell checker for prose, Codebook may not be what you are looking for. For example, capitalization issues are handled loosely and grammar checking is out of scope.
To see the motivations behind Codebook, read this blog post.
Spell checking is complicated, and opinions about how it should be done, especially for code, differ. This section is about the trade-offs that steer decisions.
No remote calls for spell checking or analytics. Once dictionaries are cached, Codebook needs to be usable offline. Codebook will never send the contents of files to a remote server.
Codebook should have high signal and low noise. It should only highlight words that users have control over. For example, a misspelled word in an imported function should not be highlighted as the user can't do anything about it.
As a consequence, Codebook only marks issues for terms where they are defined, and not where they are used. Correcting both the definition (flagged by Codebook) and all subsequent uses should be done by other language specific tooling - usually available as a LSP for that language.
All features will be weighed against their impact on CPU and memory. Codebook should be fast enough to spell check on every keystroke on even low-end hardware.
Codebook will only check the parts of your code where a normal linter wouldn't. Comments, string literals and variable definitions for example. Codebook knows how to split camel case and snake case variables, and makes suggestions in the original case.
Codebook comes with a language server. Originally developed for the Zed editor, this language server can be integrated into any editor that supports the language server protocol.
Codebook comes with a dictionary manager, which will automatically download and cache dictionaries.
Codebook uses a hierarchical configuration system with global (user-level) and project-specific settings, giving you flexibility to set defaults and override them as needed per project.
✅ Good to go: C, Go, Java, JavaScript, Lua, Markdown, Odin, Plain Text, Python, Ruby, Rust, TOML, TypeScript, Zig
⚠️ Supported, needs more testing (help us improve!): Astro, Bash, C#, C++, CSS, Dart, Elixir, Erlang, Haskell, HTML, Just, LaTeX, OCaml, PHP, Svelte, Swift, Typst, VHDL, Vue, YAML
If Codebook is not marking issues you think it should, please file a GitHub issue!
If you are a Zed user, you may skip this step and consult the Zed section of this document. Otherwise, you will need to install the codebook-lsp binary and make it available on your $PATH. You have a number of options to do this.
.zip files; macOS and Linux artifacts are .tar.gz.$PATH.~/.local/bin/codebook-lsp/usr/bin/codebook-lspYou can install the latest release using eget:
eget blopker/codebookYou can install the Codebook LSP using pacman:
pacman -S codebook-lspYou can also install the Codebook LSP using Cargo:
cargo install codebook-lspYou can install the Codebook LSP using Homebrew:
brew install codebook-lspTo install directly from the GitHub repository:
cargo install --git https://github.com/blopker/codebook codebook-lspYou may also build codebook from source by cloning the repository and running make build.
Codebook is the most popular spell checker for Zed! To install, go to the Extension tab in Zed and look for "Codebook". Done!
Note: The version that Zed displays in the extension menus is for the Zed Extension, and not the LSP version (this repo). The extension will automatically update the LSP. If that updater is broken for some reason, try uninstalling the extension and reinstalling.
Remote development (SSH/WSL2): When Zed opens a remote project, the extension runs on the remote host and downloads the LSP there. Restricted or flaky network access on the remote (a common WSL2 issue) can break that download. The extension always prefers a codebook-lsp binary found on the $PATH, so installing it on the remote host (see Installation) sidesteps the downloader entirely.
If quickfix code actions are not showing up for specific languages, ensure your settings.json file includes the special "...", or "codebook", value in any language_servers values defined:
"languages": {
"Python": {
"language_servers": ["pyright", "ruff", "..."],
// OR
"language_servers": ["pyright", "ruff", "codebook"],
"format_on_save": "on"
}
},Codebook can also be enabled for the Helix editor by adding the LSP to the languages.toml configuration file.
Ensure that codebook-lsp is installed into your $PATH (see Installation).
Then, add into the Helix languages.toml configuration file:
[language-server.codebook]
command = "codebook-lsp"
args = ["serve"]
# Example use in markdown:
[[language]]
name = "markdown"
language-servers = ["codebook"]This can be verified with:
hx --health markdownSuggestions will appear in files opened, and
space-mode a key
binding can be used to accept suggestions.
nvim-lspconfig includes a configuration for Codebook.
Ensure that codebook-lsp is installed into your $PATH (see Installation).
Install nvim-lspconfig if you have not already. Then, add the following to your Neovim configuration:
vim.lsp.enable('codebook')Not yet in the Marketplace. The extension is a work in progress. Install it locally from source if you want to try it. Feedback welcome!
A VS Code extension lives in editors/vscode. The extension manages
the codebook-lsp binary for you, starts it with the right flags, and exposes a
few configuration toggles (codebook.binaryPath, codebook.enablePrerelease,
and codebook.logLevel).
To try it locally:
cd editors/vscode
bun install # or npm install
bun run build
bun run package # or npm run package
code --install-extension codebook-vscode-*.vsixOnce the extension is installed it will activate automatically for every supported language.
Any editor that implements the Language Server Protocol should be compatible with Codebook. After installing Codebook, consult your editor's documentation to learn how to configure and enable a new language server. For your reference, the following command starts the server such that it listens on STDIN and emits on STDOUT:
codebook-lsp serveUnstable. The CLI ships with
codebook-lsptoday, but its flags and output are experimental and subject to breaking changes. Feedback welcome!
Codebook can also be used as a standalone command-line spell checker, which is useful for CI pipelines, pre-commit hooks, or one-off checks.
# Check specific files
codebook-lsp lint src/main.rs src/lib.rs
# Check all files in a directory (recursive)
codebook-lsp lint src/
# Show spelling suggestions
codebook-lsp lint --suggest src/
# Only report each misspelled word once across all files
codebook-lsp lint --unique src/The exit code is 0 if all files are clean, 1 if any spelling errors are found, and 2 if there were unreadable files, invalid UTF-8, etc.
You can also add words to the dictionary from the command line, the same way the "Add to dictionary" editor action does:
# Add words to the project config (codebook.toml), creating it if needed
codebook-lsp add combobulate frobnicate
# Add words to the global config instead
codebook-lsp add --global combobulateCodebook supports both global and project-specific configuration. Configuration files use the TOML format, with project settings overriding global ones.
The global configuration applies to all projects by default. Location depends on your operating system:
$XDG_CONFIG_HOME/codebook/codebook.toml or ~/.config/codebook/codebook.toml%APPDATA%\codebook\codebook.toml or %APPDATA%\Roaming\codebook\codebook.tomlYou can override this location if you sync your config elsewhere by providing initializationOptions.globalConfigPath from your LSP client. When no override is provided, the OS-specific default above is used.
Project-specific configuration is loaded from either codebook.toml or .codebook.toml in the project root. Codebook searches for this file starting from the current directory and moving up to parent directories.
You can override this location by providing initializationOptions.configPath from your LSP client (relative paths are resolved against the workspace root). When the override file does not yet exist, Codebook starts with defaults and creates the file at that path the first time a write happens (e.g., "Add to dictionary"). Auto-discovery is disabled when this override is set.
Note: Codebook picks which config to use on startup. If a config file is manually created or renamed (like switching between codebook.toml and .codebook.toml), restart your editor (or the LSP server) for the new file to be recognized.
The block below shows all options at their default values. Comments show example values where defaults aren't illustrative.
…use_global = false in project config, global settings are ignored entirely[[overrides]] blocks are then layered on top (global first, then project). See Scoped Overrides.The ignore_patterns configuration allows you to define custom regex p
No open issues yet, or sync has not completed.