Lint D code while you type in Vim

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 16 21:57:03 PDT 2016


On Friday, 16 September 2016 at 22:12:58 UTC, w0rp wrote:
> 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.

You should use Dscanner to do this, not DMD.  DScanner does not 
(or few) semantic, so just the module AST is necessary. It's way 
faster.

I know this because I was doing something similar to build the 
symbol list in Coedit 1 (using "-c -o- -Xf").
Finally a custom tool based on libdparse (and somehow doing one 
of the Dscanner job) was much faster.

Also "dub describe" can be very slow.


More information about the Digitalmars-d mailing list