POSTS
Building Custom Quick Fix Buffers in Vim From JSON
BlogRecently at work we decided to run a linter to check our spelling. This produced a lot of output from years of, uhm, typos. The errors found (and exceptions that needed to go into our custom dictionary!) were saved in a JSON file. I was looking for a way to use this JSON file to help vim help me work through this backlog efficiently. Vim proved up to the challenge when I configured the following values correctly.
:makeprg
:make
- The quickfix window
:errorformat
I’ll give a strategy for using these in the extended post.
Vim’s quickfix window can use the program specified in :makeprg
, as invoked
by the :make
command, to create an input source that it can parse, with the
help of configuration of the :errorformat
string, into a list of easily
traversable, linked-to-the exact file location, “quickfix” links.
One can open up the quickfix window with :copen
. A number of convenient
shortcuts make slicing through it efficient. :cnext
will advance to the next
error, :cprev
to the previous, :cfn
to the next file (“Oh heck, there’s a
bunch of custom stuff in this file that’s safe to ignore.”). I went so far as
to bind \]
and \[
to :cnext
and :cprev
to make things even faster.
Nevertheless, iterating to the precise configuration took some work. I needed a way to bootstrap my development loop. To that end, I found the following resources supremely helpful.