Code Monkey home page Code Monkey logo

cargo-spellcheck's Introduction

cargo-spellcheck

crates.io CI commits-since

Check your spelling with hunspell and/or languagetool.

Use Cases

Run cargo spellcheck --fix or cargo spellcheck fix to fix all your documentation comments in order to avoid narsty 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 specifc lingo.

Check For Spelling and/or Grammar Mistakes

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

Apply Suggestions Interactively

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

Continuous Integration / CI

cargo spellcheck can be configured with -m <code> to return a non-zero return code if mistakes are found instead of 0.

Implemented Features + Roadmap

  • Parse doc comments from arbitrary files
  • Decent error printing
  • cargo-spellcheck check
  • Spell checking using hunspell
  • Merge multiline doc comments
  • Handle multiline and fragmented mistakes (i.e. for grammar) #25
  • Grammar check using languagetool http API
  • Follow module declarations rather than blindly recurse
  • Be commonmark aware
    • Handle doctests with ```rust as virtual files #43
    • Verify all types of links #44
  • Check README.md files #37
  • Check mdbook book.toml file trees #62
  • Improve interactive user interface with crossterm
  • Ellipsize overly long statements with ... #42
  • Learn topic lingo and filter false-positive-suggestions #41
  • Handle cargo workspaces #38
  • Re-wrap doc comments #39
  • Word split validation #40

hunspell and languagetool are currently the two supported featuresets.

Configuration

# 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 ]
search_dirs = []
extra_dictonaries = []

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

Installation

cargo install cargo-spellcheck

Checkers

Available checker support

Hunspell

Requires a C++ compiler to compile the hunspell CXX source files which are part of hunspell-sys

Fedora 30+
dnf install -y clang
Ubuntu 19.10+
apt install -y clang
Mac OS X
brew install llvm

The environment variable LLVM_CONFIG_PATH needs to point to llvm-config, to do so:

export LLVM_CONFIG_PATH=/usr/local/opt/llvm/bin/llvm-config

LanguageTool

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

cargo-spellcheck's People

Contributors

drahnr avatar kuabem avatar laysauchoa avatar rhysd avatar zhiburt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.