Using vale with vim
Sun 10 March 2024 — download

LWN recently published an excellent (subscriber only) article on vale, 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 in Alpine, although it looked a tad neglected, so I sent a pull-request 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 for popular styles, like the ones from Microsoft, Google, 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 instead:

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 to vale, and configure errorformat to properly parse vale's output. Now every time I type <Leader> M, I get vale's diagnostics in my quickfix window.

The next steps would likely be to waste 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.