Check your spelling with hunspell
and/or nlprule
.
Run cargo spellcheck --fix
or cargo spellcheck fix
to fix all your
documentation comments in order to avoid nasty typos all over your source tree.
Meant as a helper simplifying review as well as improving CI checks after a
learning phase for custom/topic specific lingo.
zsh
cargo spellcheck check
error: spellcheck --> src/main.rs:44 | 44 | Fun facets shalld cause some erroris. | ^^^^^^ | - shall or shall d |
zsh
cargo spellcheck fix
error: spellcheck(Hunspell) --> /media/supersonic1t/projects/cargo-spellcheck/src/literalset.rs:291 | 291 | Returns literl within the Err variant if not adjacent | ^^^^^^ (13/14) Apply this suggestion [y,n,q,a,d,j,e,?]? lite litter litterer liter l liters literal liter ยป a custom replacement literal
cargo spellcheck
can be configured with -m <code>
to return a non-zero
return code if mistakes are found instead of 0
.
```sh
exec 1>&2
exec cargo spellcheck -m 99 $(git diff-index --cached --name-only --diff-filter=AM HEAD) ```
cargo-spellcheck check
hunspell
nlprule
commonmark
/markdown
aware
README.md
files #37crossterm
...
#42hunspell
(dictionary based lookups) and nlprules
(static grammar rules,
derived from languagetool
) are currently the two supported checkers.
```toml
dev_comments = false
skip_readme = false
[Hunspell]
.dic
filelang = "en_US"
man 5 hunspell
extra_dictionaries = []
true
, the OS specific default search pathsskiposlookups = false
skip_os_lookups=true
builtin
usage for consistentextra_dictionaries = [..]
use_builtin = true
[Hunspell.quirks]
transform_regex = ["^'([^\s])'$", "^[0-9]+x$"]
alphabeta
variants if the checker provides a replacement suggestionalpha-beta
.allow_concatenation = true
allow_dashed = false
[NlpRules]
[Reflow]
maxlinelength = 80 ```
To increase verbosity add -v
(multiple) to increase verbosity.
cargo install --locked cargo-spellcheck
The --locked
flag is the preferred way of installing to get the tested set of
dependencies.
Available checker support
Requires a C++ compiler to compile the hunspell CXX source files which are part
of hunspell-sys
sh
dnf install -y clang
sh
apt install -y clang
sh
brew install llvm
The environment variable LLVM_CONFIG_PATH
needs to point to llvm-config
, to
do so:
sh
export LLVM_CONFIG_PATH=/usr/local/opt/llvm/bin/llvm-config
When compiled with the default featureset which includes nlprules
, the
resulting binary can only be distributed under the LGPLv2.1
since the rules
and tokenizer
definitions are extracted from LanguageTool
(which is itself licensed under LGPLv2.1
) as described by
the library that is used for pulling and integrating - details are to be found
under crate nlprule
's
README.md.
Contributions are very welcome!
Generally the preferred way of doing so, is to comment in an issue that you would like to tackle the implementation/fix.
This is usually followed by an initial PR where the implementation is then discussed and iteratively refined. No need to get it all correct the first time!