惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
博客园 - 【当耐特】
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Grammar Check in Neovim with LanguageTool
2020-09-20 · via jdhao's digital space

As a Neovim user who writes frequently, I want to use Neovim to check my grammar before posting it in my blog. In this post, I will compare several plugins used for grammar checking. Under the hood, they all use the opensource tool languagetool.

I will use macOS as example here. First, we need to install languagetool using homebrew:

brew install languagetool

It will also install open-jdk for you, but the path is not set by default. We have to set the open-jdk path manually:

export PATH="/usr/local/opt/openjdk/bin:$PATH"

Now I introduce several similar plugins that use languagetool for grammar checking.

update 2023-01-04: This plugins has been deprecated.

LanguageTool.nvim is neovim plugin that support asynchronous grammar checking. Install LanguageTool.nvim using vim-plug:

Plug 'vigoux/LanguageTool.nvim'

The only setting to make it work is:

let g:languagetool_server_jar="/usr/local/opt/languagetool/libexec/languagetool-server.jar"

Then open a file, run the following commands:

  • :LanguageToolSetup: set up the languagetool server
  • :LanguageToolCheck: check the current file
  • :LanguageToolSummary: open a buffer and list all the grammar errors found in the file.

It seems that languagetool.nvim is fork of vim-LanguageTool, but the author intends to rewrite it to use more neovim-specific features.

Pros and cons#

  • Pros: asynchronous grammar check. Has error highlighting.
  • Cons: very slow.

vim-grammarous#

vim-grammarous is a more polished plugin.

Install:

Plug 'rhysd/vim-grammarous'

Run command: :GrammarousCheck to check grammar. It is asynchrous and non-blocking. When it finishes, it will notify the user in the statusline how many errros have been found.

It has options for you to configure the rules and categories for languagetool. See my config here. The explanation of categories and rules can be found here.

Pros and cons#

  • Pros: Asynchronous and relatively fast. Various configs for you to tweak. Can specifiy the rules and categories to use for languagetool. Has error highlighting.
  • Cons: not found yet.

vim-languagetool#

Another plugin: https://github.com/dpelle/vim-LanguageTool

Install with vim-plug:

Plug 'dpelle/vim-LanguageTool'

Only config you need:

let g:languagetool_jar="/usr/local/opt/languagetool/libexec/languagetool-commandline.jar"

Run command: :LanguageToolCheck to check grammar.

Pros and cons#

  • Pros: Has error highlighting.
  • Cons: It is not asynchronous, so it will hang until the results are produced.

vim-langtool#

Another similar plugin is vim-langtool. Install:

Plug 'Konfekt/vim-langtool'

Simple config:

let g:langtool_jar = '/usr/local/opt/languagetool/libexec/languagetool-commandline.jar'

Command to run: :LangTool.

Pros and cons#

  • Pros: It will populate quickfix list with errors.
  • Cons: It is not asynchronous. No error highlighting.

Ale#

Ale also support languagetool, add the following config:

let g:ale_linters = {
    \ 'python': ['pylint'],
    \ 'vim': ['vint'],
    \ 'cpp': ['clang'],
    \ 'c': ['clang'],
    \ 'markdown': ['languagetool']
\}

Then Ale will populate errors in the quickfix list.

Pros and cons#

  • Pros: It will populate quickfix list with errors.
  • Cons: No custom config available.

Common issues#

A common issue with languagetool is that it is intended for plain text, while filetypes like Markdown or LaTeX contains a lot of formatting commands or structure. So using languagetool directly on these filetypes produces a lot of false positives, as discussed here. However, it is not easy to fix this problem.

Conclusion#

Right now, it seems vim-grammarous the best plugin we can use for grammar checking.