cargo-spellcheck

crates.io CI commits-since

Check your spelling with hunspell and/or languagetool.

Usecase

Run cargo spellcheck --fix or cargo spellcheck fix to fix all your documentation comments in order to avoid narsty types all over the place.

Meant as a helper simplifying review as well as possibly improving CI after a learning phase for custom/topic specifc lingo. cargo spellcheck has a return code 1 if any unknown words are found, and 0 on success.

Use Cases

Check

zsh cargo spellcheck check

error: spellcheck
   --> src/main.rs:44
    |
 44 | Fun facets shalld cause some erroris.
    |            ^^^^^^
    | - shall or shall d
    |

Interactive fixing

zsh cargo spellcheck fix --interactive

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

Implemented Features + Roadmap

hunspell and languagetool are currently the two supported featuresets.

Configuration

```toml

Linux: /home/alice/.config/cargo_spellcheck/config.toml

Windows: C:\Users\Alice\AppData\Roaming\cargo_spellcheck\config.toml

macOS: /Users/Alice/Library/Preferences/cargo_spellcheck/config.toml

[LanguageTool] url = "127.0.0.1:8010"

[Hunspell]

lang and name of .dic file

lang = "en_US"

OS specific additives

Linux: [ /usr/share/myspell ]

Windows: []

macOS [ /home/alice/Libraries/hunspell, /Libraries/hunspell ]

searchdirs = [] extradictonaries = [] ```

Installation

cargo install cargo-spellcheck

To increase verbosity use CARGO_SPELLCHECK=cargo_spellcheck=trace to see internal details or add -v (multiple) to increase verbosity.

Hunspell

Requires the native library

```sh

Fedora 30+

dnf install -y hunspell-devel

Ubuntu 19.10+

apt install -y libhunspell-dev

Mac OS X

brew install hunspell ```

and building should succeed just fine.

LanguageTool

Run a instance of the LanguageTool server i.e. as container .