digitalmars.D - Lint D code while you type in Vim
- w0rp (39/39) Sep 16 2016 I have been working on a plugin for Vim 8 and NeoVim which runs
- Stefan Koch (2/9) Sep 16 2016 Please file an ER. (Enhancement Request)
- Basile B. (9/35) Sep 16 2016 You should use Dscanner to do this, not DMD. DScanner does not
- w0rp (17/25) Sep 18 2016 I just pushed a commit now which runs DUB in the Bash wrapper
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.
Sep 16 2016
On Friday, 16 September 2016 at 22:12:58 UTC, w0rp wrote: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.Please file an ER. (Enhancement Request)
Sep 16 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.
Sep 16 2016
On Saturday, 17 September 2016 at 04:57:03 UTC, Basile B. wrote: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.I just pushed a commit now which runs DUB in the Bash wrapper script as well, so it will never cause any input lag. I want to run DMD on D source files so I can get semantic analysis in Vim. That lets me know when a function call I am making is wrong, etc. Because the jobs run asynchronously, it doesn't matter if the job takes a few seconds to run. You will see the errors eventually without the process interrupting your editing of a particular file. I plan to add a DScanner linter command too, and I'll be adding a configuration variable for selecting particular linters, so you can only use DScanner if you only want that, or use both DScanner and DMD. I realised that I could easily get Windows support too by switching from using Bash to D for the wrapper script, and I could use maybe RDMD to compile and run the wrapper script. I'll do that eventually.
Sep 18 2016