We all make typos from to time, and it is time-consuming to do this manually.
Comparison of spelling check tools#
There are some tools we can use to detect the typos.
This is a rough comparison
| codespell | typos | cspell | |
|---|---|---|---|
| Written in | Python | rust | typescript |
| Speed | ok | fast | ok |
| support for locale | no | no | yes |
| false positives | little | little | a lot |
Upon trying cspell for one of our projects, it is producing too much false positives without config. It basically mark every word that it does not recognize as error. This approach is too much aggressive.
Codespell and typos produce much less false positives: they basically only look for genuine spelling errors.
How to set up typos#
After the initial try, I decided to stick with typos. Typos can be install via uv:
uv add --dev typosThen you can check your project typos via:
uv run typos --format=brief ./For configuration, you can write inside your pyproject.toml or with _typos.toml file.
[tool.typos]
files.extend-exclude = [
"my_file.txt"
"*.json",
]
[tool.typos.default.extend-words]
## Project-specific ignores, mostly non-english words
someword = "someword"
# identifier are made of words basically, see https://github.com/crate-ci/typos/blob/master/docs/design.md
[tool.typos.default.extend-identifiers]
fooBar = "fooBar"You can also integrate this into pre-commit if you want.
Neovim setup for typos#
You can also use typo via typos-lsp in Neovim. Just install the tools via homebrew:
brew install typos-lspIf you have nvim-lspconfig installed, you can enable typos-lsp with a simple line:
vim.lsp.enable("typos_lsp")