Lint D code while you type in Vim
w0rp via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 16 15:12:58 PDT 2016
I have been working on a plugin for Vim 8 and NeoVim which runs
linters while you type in Vim, which is an improvement over the
plugins for Vim so far which can only lint after you save a file
back to disk. So far my plugin seems to work pretty well, and I
have been using it for my job, mainly for Python and JavaScript
code.
https://github.com/w0rp/ale
I'll note again, you need either NeoVim or Vim 8 to use this
plugin, as it uses the new job control functionality for
asynchronous execution in either editor.
I'm pleased to announce I just managed to push some support for
linting with DMD and some extra DUB support which actually works,
with some caveats. It will try and find the DUB project
directory, and use
`dub describe --import-paths` to get the import paths
automatically so it knows about the types imported into your
files, which I helped add to DUB for this explicit purpose a
while ago. (So it's probably in the version of DUB you are using
now.)
The caveats are that I haven't tested this that much, so there
could be some bugs I don't know about, and that this won't work
in Windows at the moment. In order to lint while you type, you
must pass the contents of the file you are editing via stdin to a
particular program. DMD doesn't accept source files via stdin, so
I had to write a Bash wrapper script saved in the plugin
directory which will do that for me.
If anyone is running NeoVim or Vim 8, give it a go. Let me know
what you think. Hopefully someone will find this useful. I've
been dealing with some RSI issues recently, so I won't put too
much work into this for the immediate future, but I'll work on
this some more when my wrists heal up a bit just because I want
to use it personally.
For maintainers of DMD, I would love it if an option to read
source files via stdin could be added. It could be something like
-stdin. Then it would be very easy to use DMD to check source
files from stdin input. It might also be an idea to add a second
option for suggesting what the filename of the stdin input should
be, in case that matters. I know eslint has such an option, and
it could matter in some cases.
More information about the Digitalmars-d
mailing list