Write Better in Neovim With Languagetool
Tags: helixeditor, writing, tooling, helix
Published: 2022-10-26 09:11:05

---
title: Write Better in Neovim With Languagetool
published: true
date: 2022-10-26 12:00:00 UTC
tags: helixeditor, writing, tooling, helix
cover_image: https://images.unsplash.com/photo-1643780668909-580822430155?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=420&w=1000
canonical_url: https://www.rockyourcode.com/write-better-in-neovim-with-languagetool/
---

**[LanguageTool](https://languagetool.org/)** is a grammar tool and spell checker with an open-source core.

I have used [grammarly](https://www.grammarly.com/) for a while, but the browser extension was crap.  
A colleague recommended LanguageTool (LT), and I’ve been a happy user of the browser extension ever since.

LT has superior support for other languages than English. It also features decent suggestions for improving your grammar. The free tier of LT has been a better experience for me than grammarly.

Did you know that you can use LT as a language server for NeoVim and other editors?

## Install ltex-ls

LT has no direct support for the [language server protocol](https://microsoft.github.io/language-server-protocol/), but fear not – a clever programmer has included the LT server in his LSP implementation.

The tool is called **[ltex-ls](https://valentjn.github.io/ltex/)**, and it’s free software.

You can find the installation instructions on the [ltex-ls website](https://valentjn.github.io/ltex/ltex-ls/installation.html).

For macOS, you can use [homebrew](https://brew.sh):

```bash
brew install ltex-ls
```

The command installs the server as `ltex-ls` in your standard homebrew location and thus adds it to your `$PATH`.

If you manually install the program, make sure to add the binary to your `$PATH`, for example with [`fish_add_path`](https://fishshell.com/docs/current/cmds/fish_add_path.html).

## Integration With nvim-lsp

Check the [recommended configuration on the nvim-lsp GitHub](https://github.com/neovim/nvim-lspconfig#suggested-configuration) and add the following configuration:

```lua
require('lspconfig')['ltex']({
 on_attach = on_attach,
 cmd = { "ltex-ls" },
 filetypes = { "markdown", "text" },
 flags = { debounce_text_changes = 300 },
})

```

You should add the server command into the `cmd` section. On macOS, `ltex-ls` worked fine for me.

Here you can see how the tool points out possible errors in my text:

![neovim languagetool example](https://www.rockyourcode.com/languagetool-neovim.png)

## Other Editors

I originally found the instructions for using ltex-lsp on a blog about the [Helix Editor](https://helix-editor.com): [Note talking with Helix, Tp-Note and LanguageTool](https://blog.getreu.net/20220828-tp-note-new8/).

Here is the the content of `~/.config/helix/languages.toml`:

```
[[language]]
file-types = ["md", "txt"]
indent = { tab-width = 2, unit = " " }
injection-regex = "md|markdown"
language-server = { command = "ltex-ls" }
name = "markdown"
roots = [".git"]
scope = "source.md"

```

If you use [VS Code](https://code.visualstudio.com/), you can use the extension [vscode-ltex](https://github.com/valentjn/vscode-ltex).

## Links

- [LanguageTool](https://languagetool.org/)
- [ltex-ls](https://valentjn.github.io/ltex/)
- [Note talking with Helix, Tp-Note and LanguageTool](https://blog.getreu.net/20220828-tp-note-new8/)