Title: Using vale with vim
Date: 2024-03-10 17:15

[LWN](https://en.wikipedia.org/wiki/LWN.net) recently published an excellent
(subscriber only) [article](https://lwn.net/Articles/964075/) on
[vale](https://vale.sh/), an *editorial style* linter. One of the original goal
of this little corner on the internet was to improve my English, a purpose it
keeps serving. Adding some lightweight tooling to my text editor to push this
goal even further sounds great.

Like all good software, vale [is
packaged](https://gitlab.alpinelinux.org/alpine/aports/-/tree/master/testing/vale)
in Alpine, although it looked a tad neglected, so I sent [a
pull-request](https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/61919)
to get it updated.
Its configuration is pretty straightforward: a `~/.vale.ini` file, with
where to store/read its data and some preferences. It comes with a
[couple of *packages*](https://vale.sh/hub/) for popular styles, like the ones
from [Microsoft](https://vale.sh/hub/microsoft/),
[Google](https://vale.sh/hub/google/), [RedHat](https://vale.sh/hub/redhat/), … then a simple `vale sync` to force it to
download and store the data, and you're good to go.

While `vale` can be called from the command line, integration with my text
editor is way more comfy. I'm sure there are a ton of plugins to integrate it
with vim, but I'm not a huge fan of having my text editor run arbitrary code
from the internet, so I threw the following 6 lines in [my vimrc](
https://dustri.org/pub/vimrc ) instead:

```vimrc
augroup vale
  if filereadable(expand("~/.vale.ini"))
    autocmd FileType markdown setlocal makeprg=vale\ --output=line\ % errorformat=%f:%l:%c:%o:%m
    nnoremap <Leader>M :make<CR><CR>
  end
augroup end
```

It checks if I have a `~/vale.ini` file, and if so sets
[`makeprg`](https://vimhelp.org/options.txt.html#%27makeprg%27) to vale, and
configure [`errorformat`](https://vimhelp.org/quickfix.txt.html#errorformat) to
properly parse vale's output. Now every time I type `<Leader> M`, I get vale's
diagnostics in my [quickfix window](https://vimhelp.org/quickfix.txt.html).

The next steps would likely be to <s>waste</s> spend some time improving the theme
of the aforementioned window, add some ad-hoc rules to vale, and maybe try to
show the diagnostics inline like the spellchecker is doing.
