• Stars
    star
    1,058
  • Rank 43,617 (Top 0.9 %)
  • Language
    Vim Script
  • Created over 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A powerful grammar checker for Vim using LanguageTool.

vim-grammarous

vim-grammarous is a powerful grammar checker for Vim. Simply do :GrammarousCheck to see the powerful checking. This plugin automatically downloads LanguageTool, which requires Java 8+.

This plugin can use job feature on Vim 8.0.27 (or later) or Neovim. It enables asynchronous command execution so you don't need to be blocked until the check has been done on Vim8+ or Neovim.

demo screen cast

Commands

:[range]GrammarousCheck [--lang={lang}] [--(no-)preview] [--(no-)comments-only]

Execute the grammar checker for current buffer (when [range] is specified, the target is a text in the range).

  1. It makes LanguageTool check grammar (It takes a while)
  2. It highlights the locations of detected grammar errors
  3. When you move the cursor to a location of an error, it automatically shows the error with the information window (named [Grammarous]).

Please do :GrammarousCheck --help to show more detail about the command.

:GrammarousReset

Reset the current check.

Mappings

Local mappings in the information window

You can use some mappings in the information window, which is opened to show the detail of an error when the cursor moves to the error.

Mappings Description
q Quit the info window
<CR> Move to the location of the error
f Fix the error automatically
r Remove the error without fix
R Disable the grammar rule in the checked buffer
n Move to the next error's location
p Move to the previous error's location
? Show help of the mapping in info window

<Plug> mappings to execute actions anywhere

The above local mappings are enough to deal with grammar errors.

However, for a more convenient use, vim-grammarous provides the following global mappings to enable using all grammarous actions globally within vim. This might be beneficial, as the standard mappings only work within the info window, which loses focus after every action.

By mapping the actions listed below to your favorite shortcuts, it is possible to map all actions that work within the info window, to work globally within vim. This is done via :nmap and an example for a mapping would be :nmap <F5> (grammarous-move-to-next-error).

Mappings Description
<Plug>(grammarous-move-to-info-window) Move the cursor to the info window
<Plug>(grammarous-open-info-window) Open the info window for the error under the cursor
<Plug>(grammarous-reset) Reset the current check
<Plug>(grammarous-fixit) Fix the error under the cursor automatically
<Plug>(grammarous-fixall) Fix all the errors in a current buffer automatically
<Plug>(grammarous-close-info-window) Close the information window from checked buffer
<Plug>(grammarous-remove-error) Remove the error under the cursor
<Plug>(grammarous-disable-rule) Disable the grammar rule under the cursor
<Plug>(grammarous-move-to-next-error) Move cursor to the next error
<Plug>(grammarous-move-to-previous-error) Move cursor to the previous error

Operator mappings

Operator mapping checks grammatical errors in the extent which the text object specifies. This mapping is available when vim-operator-user is installed.

Mappings Description
<Plug>(operator-grammarous) Execute grammar check to a text object

grammarous unite.vim source

If you are unite.vim user, grammarous unite source is available to look and search the error list incrementally. To the candidates of the list, you can do the actions which are the same as ones in the info window. (fixit, remove error and disable rule) Execute below command in the buffer already checked or you want to check.

:Unite grammarous

grammarous denite.nvim source

For denite.nvim users, grammarous denite source is available. Note that the kind is currently set to file, which means that actions a user can use are limited to open(jump), preview, etc. Execute below command in the buffer already checked.

:Denite grammarous

Fix examples

FAQ

How do I check comments only in source code by default?

Please use g:grammarous#default_comments_only_filetypes.

For example, below setting makes grammar checker check comments only except for markdown and vim help.

let g:grammarous#default_comments_only_filetypes = {
            \ '*' : 1, 'help' : 0, 'markdown' : 0,
            \ }

How are rules added to the default rule set?

Please use g:grammarous#enabled_rules to enable additional rules. The value is dictionary whose keys are a filetype (* means 'any') and whose values are a list of rule names.

For example, below setting enables PASSIVE_VOICE rule in all filetypes.

let g:grammarous#enabled_rules = {'*' : ['PASSIVE_VOICE']}

Some rules annoy me.

Please use g:grammarous#disabled_rules to disable specific rules.

For example, below setting disables some rules for each filetype. * means all filetypes, help means vim help.

let g:grammarous#disabled_rules = {
            \ '*' : ['WHITESPACE_RULE', 'EN_QUOTES'],
            \ 'help' : ['WHITESPACE_RULE', 'EN_QUOTES', 'SENTENCE_WHITESPACE', 'UPPERCASE_SENTENCE_START'],
            \ }

The rule names are displayed in Vim command line when you disable the rule in the info window or by <Plug>(grammarous-disable-rule).

How are categories added to the default rule set?

Please use g:grammarous#enabled_categories to enable additional categories. The value is dictionary whose keys are a filetype (* means 'any') and whose values are a list of categories names.

For example, below setting enables PASSIVE_VOICE rule in all filetypes.

let g:grammarous#enabled_categories = {'*' : ['PUNCTUATION']}

Some categories annoy me.

Please use g:grammarous#disabled_categories to disable specific categories.

For example, below setting disables some categories for each filetype. * means all filetypes, help means vim help.

let g:grammarous#disabled_categories = {
            \ '*' : ['PUNCTUATION'],
            \ 'help' : ['PUNCTUATION', 'TYPOGRAPHY'],
            \ }

The category names are displayed in Vim command line when you disable the category in the info window or by <Plug>(grammarous-disable-category).

How do I use this plugin with vim's spelllang?

Please use g:grammarous#use_vim_spelllang. Default 0, to enable 1.

I want to use above <Plug> mappings only after checking.

on_check and on_reset are available.

For example, below setting defines <C-n> and <C-p> mappings as buffer-local mappings when the check has been completed. They are cleared when the check is reset.

let g:grammarous#hooks = {}
function! g:grammarous#hooks.on_check(errs) abort
    nmap <buffer><C-n> <Plug>(grammarous-move-to-next-error)
    nmap <buffer><C-p> <Plug>(grammarous-move-to-previous-error)
endfunction

function! g:grammarous#hooks.on_reset(errs) abort
    nunmap <buffer><C-n>
    nunmap <buffer><C-p>
endfunction

I want to use system global LanguageTool command

g:grammarous#languagetool_cmd is available for the purpose. If some command is set to g:grammarous#languagetool_cmd in your .vimrc, vim-grammarous does not install its own LanguageTool jar and use the command to run LanguageTool.

let g:grammarous#languagetool_cmd = 'languagetool'

I want to see the first error in an information window soon after :GrammarousCheck

Please set g:grammarous#show_first_error to 1. It opens an information window after :GrammarousCheck immediately when some error detected.

I want to use a location list to jump among errors

Please set g:grammarous#use_location_list to 1. It sets all grammatical errors to location list. This variable is set to 0 by default to avoid conflicts of location list usage with other plugins.

Automatic installation

This plugin attempts to install LanguageTool using curl or wget command at first time. If it fails, you should install it manually. Please download zip file of LanguageTool and extract it to path/to/vim-grammarous/misc.

Requirements

Future

  • Ignore specific regions : Enable to specify the region which vim-grammarous should not check. It is helpful for GFM's fenced code blocks.
  • Incremental grammarous check : Check only the sentences you input while starting from entering and leaving insert mode.

Contribution

If you find some bugs, please report it to issues page. Pull requests are welcome. None of them is too short.

License

Copyright (c) 2014 rhysd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

vim.wasm

Vim editor ported to WebAssembly
Vim Script
5,305
star
2

actionlint

:octocat: Static checker for GitHub Actions workflow files
Go
2,605
star
3

NyaoVim

Web-enhanced Extensible Neovim Frontend
TypeScript
2,207
star
4

git-messenger.vim

Vim and Neovim plugin to reveal the commit messages under the cursor
Vim Script
1,263
star
5

vim-clang-format

Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, and so on.
Vim Script
1,036
star
6

clever-f.vim

Extended f, F, t and T key mappings for Vim.
Vim Script
968
star
7

Shiba

Rich markdown live preview app with linter
TypeScript
751
star
8

gocaml

🐫 Statically typed functional programming language implementation with Go and LLVM
Go
732
star
9

kiro-editor

A terminal UTF-8 text editor written in Rust 📝🦀
Rust
728
star
10

committia.vim

A Vim plugin for more pleasant editing on commit messages
Vim Script
687
star
11

go-github-selfupdate

Binary self-update mechanism for Go commands using GitHub
Go
527
star
12

conflict-marker.vim

Weapon to fight against conflicts in Vim.
Vim Script
442
star
13

wain

WebAssembly implementation from scratch in Safe Rust with zero dependencies
Rust
425
star
14

hgrep

Grep with human-friendly search results
Rust
419
star
15

electron-about-window

'About This App' mini-window for Electron apps
TypeScript
405
star
16

Mstdn

Tiny web-based mastodon client for your desktop
TypeScript
390
star
17

tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
Rust
287
star
18

vim-color-spring-night

Low-contrast calm color scheme for Vim
Rust
276
star
19

cargo-husky

Setup Git hooks automatically for cargo projects with 🐶
Rust
260
star
20

dot-github

.github directory generator
Go
248
star
21

8cc.vim

C Compiler written in Vim script
Vim Script
227
star
22

vim-startuptime

A small Go program for better `vim --startuptime` alternative
Go
191
star
23

notes-cli

Small markdown note taking CLI app playing nicely with your favorite editor and other CLI tools
Go
191
star
24

dotfiles

dotfiles symbolic links management CLI
Go
191
star
25

neovim-component

<neovim-editor> WebComponent to embed Neovim to your app with great ease
TypeScript
188
star
26

reply.vim

REPLs play nicely with :terminal on Vim and Neovim
Vim Script
183
star
27

monolith-of-web

A chrome extension to make a single static HTML file of the web page using a WebAssembly port of monolith CLI
TypeScript
183
star
28

github-complete.vim

Vim input completion for GitHub
Vim Script
168
star
29

Trendy

Menubar app to keep you in the loop of GitHub trends :octocat:
TypeScript
166
star
30

git-brws

Command line tool to open repository, file, commit, diff, tag, pull request, blame, issue or project's website in browser for various repository hosting services.
Rust
166
star
31

devdocs.vim

Open devdocs.io from Vim
Vim Script
164
star
32

react-vimjs

Vim in Your Web App
JavaScript
158
star
33

vim-operator-surround

Vim operator mapping to enclose text objects with surrounds like paren, quote and so on.
Vim Script
137
star
34

react-vim-wasm

Vim editor embedded in your React web application
TypeScript
128
star
35

action-setup-vim

GitHub Action to setup Vim or Neovim on Linux, macOS and Windows for testing Vim plugins
TypeScript
126
star
36

accelerated-jk

A vim plugin to accelerate up-down moving!
Vim Script
125
star
37

dogfiles

dog + dotfiles = dogfiles
Vim Script
120
star
38

vim-gfm-syntax

GitHub Flavored Markdown syntax highlight extension for Vim
Vim Script
117
star
39

wandbox-vim

Wandbox plugin for vimmers. http://melpon.org/wandbox/
Vim Script
108
star
40

fixjson

JSON Fixer for Humans using (relaxed) JSON5
TypeScript
99
star
41

tinyjson

Simple JSON parser/generator for Rust
Rust
97
star
42

remark-emoji

Remark markdown transformer to replace :emoji: in text
JavaScript
93
star
43

YourFukurou

Hackable YoruFukurou alternative Twitter client
TypeScript
88
star
44

vim-lsp-ale

Bridge between vim-lsp and ALE
Vim Script
86
star
45

Dachs

Dachs; A Doggy 🐶 Programming Language
C++
81
star
46

vim-textobj-anyblock

A text object for any of '', "", (), {}, [] and <>.
Vim Script
79
star
47

vim-wasm

WebAssembly filetype support for Vim
Vim Script
77
star
48

world-map-gen

🗺️Random world map generator CLI and library for Rust and WebAssembly
Rust
74
star
49

vim-go-impl

A Vim plugin to use `impl` command
Vim Script
72
star
50

rust-doc.vim

Search Rust documents and open with browser from Vim.
Vim Script
71
star
51

ghci-color

colorize ghci output
PowerShell
71
star
52

electron-in-page-search

Module to introduce Electron's native in-page search avoiding pitfalls
TypeScript
66
star
53

translate-markdown

CLI tool to translate Markdown document with Google translate
JavaScript
66
star
54

tweet-app

Desktop Twitter client only for tweeting. Timeline never shows up.
TypeScript
65
star
55

dirname-filename-esm

__dirname and __filename for ES Modules environment
JavaScript
65
star
56

github-clone-all

Clone (~1000) repos matched to query on GitHub using Search API
Go
63
star
57

Tui

Twitter client based on mobile.twitter.com in menu bar
TypeScript
62
star
58

array_view

Wrapper for references to array in C++.
C++
58
star
59

vim-textobj-ruby

Make text objects with various ruby block structures.
Vim Script
56
star
60

fast-json-clone

Clone plain JSON value faster than the fastest
TypeScript
56
star
61

riscv32-cpu-chisel

Learning how to make RISC-V 32bit CPU with Chisel
Scala
55
star
62

changelog-from-release

Simple changelog generator via GitHub releases
Go
54
star
63

vim-llvm

Vim filetype support for LLVM (including official files)
Vim Script
49
star
64

Tilectron

Tiling window browser built on Electron.
JavaScript
45
star
65

nyaovim-markdown-preview

Live Markdown Preview on NyaoVim
HTML
45
star
66

Chromenu

Mobile Chrome in your menubar
TypeScript
43
star
67

Crisp

Lisp dialect implemented with Crystal
Crystal
43
star
68

path-slash

Tiny Rust library to convert a file path from/to slash path
Rust
41
star
69

open-pdf.vim

Convert pdf file to plain text, cache it and open it quickly in vim using pdftotext.
Vim Script
39
star
70

fixred

Fix outdated links in files with redirect URLs
Rust
35
star
71

ghpr-blame.vim

Vim plugin which is like `git-blame`, but for pull requests on GitHub
Vim Script
34
star
72

vim-healthcheck

Polyfill of Neovim's health-check for Vim
Vim Script
33
star
73

nyaovim-mini-browser

Embedded Mini Browser for NyaoVim
HTML
31
star
74

vim-color-splatoon

Vim Splatoon randomized color scheme. Let's play!
Vim Script
29
star
75

vim-fixjson

Vim plugin for fixjson; a JSON fixer for Humans
Vim Script
24
star
76

unite-redpen.vim

A unite.vim integration of redpen for automatic proof reading
Vim Script
24
star
77

vimwasm-try-plugin

Try Vim plugin on your browser without installing it using vim.wasm!
Go
24
star
78

react-component-octicons

Zero-dependency React component for Octicons
TypeScript
24
star
79

go-fakeio

Small Go library to fake stdout/stderr/stdin mainly for unit testing
Go
24
star
80

unite-codic.vim

A unite.vim source for codic-vim.
Vim Script
23
star
81

vim-goyacc

Vim filetype support for goyacc
Vim Script
22
star
82

gofmtrlx

(a bit) relaxed gofmt
Go
22
star
83

try-colorscheme.vim

Try colorscheme on your Vim without installation
Vim Script
21
star
84

node-github-trend

node.js library for scraping GitHub trending repositories.
TypeScript
20
star
85

node-github-emoji

Node.js library for GitHub Emoji :octocat: with TypeScript support
TypeScript
20
star
86

vim-syntax-christmas-tree

Vim filetype plugin for X'mas
Vim Script
20
star
87

toy-riscv-backend

Toy RISC-V LLVM backend
C++
18
star
88

FrozenString

C++ immutable string library in C++11 constexpr and type-level
C++
18
star
89

nyaovim-tree-view

Tree-view sidebar for NyaoVim
JavaScript
18
star
90

vim-github-actions

(Outdated) Vim syntax/indent support for GitHub Actions *.workflow files
Vim Script
18
star
91

zsh-bundle-exec

No longer need to type in 'bundle exec'.
Shell
17
star
92

locerr

❌ locerr (locational error): Library for nice-looking errors in source code
Go
16
star
93

rhysd

README.md for my profile page
Ruby
16
star
94

unite-ruby-require.vim

A unite.vim source for searching gems to require
Vim Script
15
star
95

vim-textobj-conflict

Vim text object plugin to select conflicts
Vim Script
15
star
96

electron-open-url

Open URL with Electron window from command line or Node.js program
JavaScript
15
star
97

vim-notes-cli

Vim plugin for notes-cli
Vim Script
15
star
98

marked-sanitizer-github

A sanitizer for marked.js which sanitizes HTML elements in markdown with the same manner as GitHub
TypeScript
14
star
99

api-dts

d.ts generator from JSON API response
Go
13
star
100

Irasutoyer

Desktop app for Irasutoya lovers
TypeScript
13
star