www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - SublimeLinter-contrib-dmd: dmd feedback as you type

reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
SublimeLinter-contrib-dmd [1] is a plug-in for the Sublime Text 3 
editor [2]. Unlike linters that are based on DScanner, it 
actually invokes dmd on the file that is being edited, as you 
edit. If dmd finds anything to complain about, an annotation is 
shown in the editor: warnings and deprecations in orange, errors 
in red. If SublimeLinter (a plug-in dependency) is configured to 
show tool tips, the error message pops up after a click on the 
annotation (see screen shots [1]). SublimeLinter offers shortcuts 
for jumping to errors and it is possible to postpone on-the-fly 
linting or lint only on request.

The advantages of using dmd for linting are:

1. The parser is always up-to-date.
2. Full symbol resolution, including imports.
3. Mixins are expanded.
4. Templates are validated.
5. Deprecation warnings are included.
6. The "did you mean …" assistance appears right where it is most 
helpful.

The plug-in is easily installed from within the editor, as 
described on the project page [1].

Dmd does not always get the column number exactly right, which 
can cause the annotation to be misplaced, but that is just a 
cosmetic deficiency. I have not tested this on larger code bases 
and only on Windows, but I expect it to work on all platforms 
supported by Sublime Text 3. Please let me know if you find any 
issues. The editor is not free, but it continues to work after 
your evaluation period has expired.

On request I can add an option to configure the path to dmd, 
currently it expects to find dmd using the system path.


Hope you like it,
Bastiaan.

[1] https://github.com/veelo/SublimeLinter-contrib-dmd
[2] http://www.sublimetext.com/
Oct 30 2017
next sibling parent reply notna <notna.remove.this ist-einmalig.de> writes:
On Monday, 30 October 2017 at 22:22:42 UTC, Bastiaan Veelo wrote:
 SublimeLinter-contrib-dmd [1] is a plug-in for the Sublime Text 
 3 editor [2]. Unlike linters that are based on DScanner, it 
 actually invokes dmd on the file that is being edited, as you 
 edit. If dmd finds anything to complain about, an annotation is 
 shown in the editor: warnings and deprecations in orange, 
 errors in red. If SublimeLinter (a plug-in dependency) is 
 configured to show tool tips, the error message pops up after a 
 click on the annotation (see screen shots [1]). SublimeLinter 
 offers shortcuts for jumping to errors and it is possible to 
 postpone on-the-fly linting or lint only on request.

 [...]
My console says: File "linter in C:\Users\anton\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter-contrib-dmd.sublime-package", line 13, in <module> ImportError: No module named 'SublimeLinter'
Oct 31 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 31 October 2017 at 11:02:23 UTC, notna wrote:
 ImportError: No module named 'SublimeLinter'
Looks like you did not install the SublimeLinter package. You need both.
Oct 31 2017
next sibling parent reply SrMordred <patric.dexheimer gmail.com> writes:
Thank you , works perfectly!

One idea: Integrating with dub.
So you don´t have to manually set lib dirs and flags since its 
all on 'dub.json' already.
Oct 31 2017
next sibling parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 31 October 2017 at 13:32:34 UTC, SrMordred wrote:
 Thank you , works perfectly!

 One idea: Integrating with dub.
 So you don´t have to manually set lib dirs and flags since its 
 all on 'dub.json' already.
That would be nice. I don't have a project yet that uses dub though, so I am not well prepared to do that. Currently, settings are read courtesy the parent plug-in SublimeLinter. It is written in Python and quite extensible and well documented [1] -- do you want to have a go at it? (This was my first exposure to Python by the way.) Out of curiosity, what other plugins from [2] do you use in Sublime Text? How are they integrating with dub? [1] http://www.sublimelinter.com/en/latest/ [2] https://wiki.dlang.org/Editors
Oct 31 2017
parent Moritz Maxeiner <moritz ucworks.org> writes:
On Tuesday, 31 October 2017 at 16:00:25 UTC, Bastiaan Veelo wrote:
 [...]

 Out of curiosity, what other plugins from [2] do you use in 
 Sublime Text? How are they integrating with dub?
If that question is open to the general public: None, I hacked my own [1] to suit my exact needs. [1] https://github.com/MoritzMaxeiner/sublide
Oct 31 2017
prev sibling parent reply Moritz Maxeiner <moritz ucworks.org> writes:
On Tuesday, 31 October 2017 at 13:32:34 UTC, SrMordred wrote:
 Thank you , works perfectly!

 One idea: Integrating with dub.
 So you don´t have to manually set lib dirs and flags since its 
 all on 'dub.json' already.
You can pretty much copy paste from sublide for this [1] (my own D plugin for ST3). [1] https://github.com/MoritzMaxeiner/sublide/blob/master/dub.py#L40
Oct 31 2017
parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 31 October 2017 at 16:06:24 UTC, Moritz Maxeiner 
wrote:
 On Tuesday, 31 October 2017 at 13:32:34 UTC, SrMordred wrote:
 Thank you , works perfectly!

 One idea: Integrating with dub.
 So you don´t have to manually set lib dirs and flags since its 
 all on 'dub.json' already.
You can pretty much copy paste from sublide for this [1] (my own D plugin for ST3). [1] https://github.com/MoritzMaxeiner/sublide/blob/master/dub.py#L40
Thank you Moritz! The plugin now looks for DUB project configuration files in open folders and adds any required import paths that can be determined from those automatically. If you have installed the plugin using Sublime Text's Package Control, you'll get the update automatically.
Nov 09 2017
prev sibling parent notna <notna.remove.this ist-einmalig.de> writes:
On Tuesday, 31 October 2017 at 11:30:00 UTC, Bastiaan Veelo wrote:
 On Tuesday, 31 October 2017 at 11:02:23 UTC, notna wrote:
 ImportError: No module named 'SublimeLinter'
Looks like you did not install the SublimeLinter package. You need both.
Thanks, seems to work now ;)
Oct 31 2017
prev sibling next sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On Monday, 30 October 2017 at 22:22:42 UTC, Bastiaan Veelo wrote:
 SublimeLinter-contrib-dmd [1] is a plug-in for the Sublime Text 
 3 editor [2].
[snip]
 The advantages of using dmd for linting are:

 1. The parser is always up-to-date.
 2. Full symbol resolution, including imports.
 3. Mixins are expanded.
 4. Templates are validated.
 5. Deprecation warnings are included.
 6. The "did you mean …" assistance appears right where it is 
 most helpful.
Sounds cool, I assume you use -o- option to disable DMD codegen? Should be fairly fast.
 [1] https://github.com/veelo/SublimeLinter-contrib-dmd
 [2] http://www.sublimetext.com/
Oct 31 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 31 October 2017 at 13:47:26 UTC, Dmitry Olshansky 
wrote:

 Sounds cool, I assume you use -o- option to disable DMD codegen?
yes
 Should be fairly fast.
indeed
Oct 31 2017
parent reply Basile B. <b2.temp gmx.com> writes:
On Tuesday, 31 October 2017 at 15:43:08 UTC, Bastiaan Veelo wrote:
 On Tuesday, 31 October 2017 at 13:47:26 UTC, Dmitry Olshansky 
 wrote:

 Sounds cool, I assume you use -o- option to disable DMD 
 codegen?
yes
 Should be fairly fast.
indeed
Surprising. Back in 2014 i used something similar to display the AST in my IDE (also -o- but to get the JSON output) and found it slow (especially in projects since the dmd command line had to include all the imports and sources to avoid false positives). Tt's been replaced by something based on libdparse, which also allows to show syntax errors fast.
Nov 01 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Wednesday, 1 November 2017 at 12:54:38 UTC, Basile B. wrote:
 On Tuesday, 31 October 2017 at 15:43:08 UTC, Bastiaan Veelo 
 wrote:
 On Tuesday, 31 October 2017 at 13:47:26 UTC, Dmitry Olshansky 
 wrote:

 Sounds cool, I assume you use -o- option to disable DMD 
 codegen?
yes
 Should be fairly fast.
indeed
Surprising. Back in 2014 i used something similar to display the AST in my IDE (also -o- but to get the JSON output) and found it slow (especially in projects since the dmd command line had to include all the imports and sources to avoid false positives). Tt's been replaced by something based on libdparse, which also allows to show syntax errors fast.
To be frank, I have only tested this on the minimal examples from dlang.org. "Fast" and "slow" are subjective measures, the question is: when is it too slow? I am interested to hear how this does for people with large code bases, but because dmd works in the background and you don't have to wait for it to get your code typed out, I suppose speed is not very important as long as it stays within a few seconds. Remember it is used for linting only, if it were used for code completion or go-to-definition it could be too slow.
Nov 01 2017
parent reply Temtaime <temtaime gmail.com> writes:
Works too strange.
Seems it checks only syntax and doesn't display non-syntax 
related errors.
Nov 01 2017
next sibling parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Wednesday, 1 November 2017 at 20:09:02 UTC, Temtaime wrote:
 Works too strange.
 Seems it checks only syntax and doesn't display non-syntax 
 related errors.
It may be that the regex needs to be adjusted. Could you please post a reduced example at https://github.com/veelo/SublimeLinter-contrib-dmd/issues? Thanks.
Nov 01 2017
prev sibling parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Wednesday, 1 November 2017 at 20:09:02 UTC, Temtaime wrote:
 Works too strange.
 Seems it checks only syntax and doesn't display non-syntax 
 related errors.
Also, what is your compiler version, OS, and do you have other plugins active?
Nov 01 2017
parent reply Temtaime <temtaime gmail.com> writes:
On Thursday, 2 November 2017 at 06:43:36 UTC, Bastiaan Veelo 
wrote:
 On Wednesday, 1 November 2017 at 20:09:02 UTC, Temtaime wrote:
 Works too strange.
 Seems it checks only syntax and doesn't display non-syntax 
 related errors.
Also, what is your compiler version, OS, and do you have other plugins active?
No way to post a reduced example. I tried it with one-file test example and it displays all the errors correctly, but in my projects with 30 KLOCS it displays only syntax erorrs. DMD from git master branch, windows, no other plugins.
Nov 02 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Thursday, 2 November 2017 at 08:35:08 UTC, Temtaime wrote:
 On Thursday, 2 November 2017 at 06:43:36 UTC, Bastiaan Veelo 
 wrote:
 On Wednesday, 1 November 2017 at 20:09:02 UTC, Temtaime wrote:
 Works too strange.
 Seems it checks only syntax and doesn't display non-syntax 
 related errors.
Also, what is your compiler version, OS, and do you have other plugins active?
No way to post a reduced example. I tried it with one-file test example and it displays all the errors correctly, but in my projects with 30 KLOCS it displays only syntax erorrs. DMD from git master branch, windows, no other plugins.
Maybe the error is actually detected but shown in a different location? Use Tools->SublimeLinter->Show All Errors to see if it is there. You can turn on debugging from the menu Tools->SublimeLinter->Debug Mode, and open the console (Ctrl+` or icon in lower left corner) to see the dmd output. Do you see the error messages you expect? The linter calls dmd on just the file that is in your view (in a temp directory). That is probably not how you compile your 30KLOCS project, maybe errors depend on that? Does dmd give the error message you expect when you call dmd on that particular file by hand? The linter uses these command line switches: -o- -w -wi -vcolumns. If there is a difference in what dmd produces and what is picked up by the linter, we should adjust the python regex [1]. Note that it should discard tracebacks like "called from here". I used [5] to help with that. If you want to hack on it yourself, you can remove the package SublimeLinter-contrib-dmd and clone [2] into C:\Users\<user>\AppData\Roaming\Sublime Text 3\Packages. Maybe dmd sends some of its output to stdout. Change [3] from util.STREAM_STDERR to util.STREAM_BOTH to make it read from both streams. Does it help setting the linter working directory [4]? Note that currently the regex relies on the substring "SublimeLinter3" being present in the path to the temp file, I am unsure whether that would still work then. [1] https://github.com/veelo/SublimeLinter-contrib-dmd/blob/e2b4270c2318381eb113620631e93de2b18d436e/linter.py#L24-L33 [2] https://github.com/veelo/SublimeLinter-contrib-dmd [3] https://github.com/veelo/SublimeLinter-contrib-dmd/blob/e2b4270c2318381eb113620631e93de2b18d436e/linter.py#L37 [4] http://www.sublimelinter.com/en/latest/linter_settings.html?highlight=working#chdir [5] https://regex101.com/, select python flavor.
Nov 02 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Thursday, 2 November 2017 at 09:26:48 UTC, Bastiaan Veelo 
wrote:
 Does dmd give the error message you expect when you call dmd on 
 that particular file by hand? The linter uses these command 
 line switches: -o- -w -wi -vcolumns.
How long does that take? Could be timeout...
Nov 02 2017
parent reply Temtaime <temtaime gmail.com> writes:
On Thursday, 2 November 2017 at 09:43:11 UTC, Bastiaan Veelo 
wrote:
 On Thursday, 2 November 2017 at 09:26:48 UTC, Bastiaan Veelo 
 wrote:
 Does dmd give the error message you expect when you call dmd 
 on that particular file by hand? The linter uses these command 
 line switches: -o- -w -wi -vcolumns.
How long does that take? Could be timeout...
Takes about 3s to compile single file. Sorry, figured out an error : missed some include path for dub package. Support for dub will be great :) Now all works Thanks !
Nov 02 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Thursday, 2 November 2017 at 10:00:25 UTC, Temtaime wrote:
 Support for dub will be great :)
Yes...
 Now all works
 Thanks !
Alright :-)
Nov 02 2017
parent reply Suliman <evermind live.ru> writes:
On Thursday, 2 November 2017 at 10:04:44 UTC, Bastiaan Veelo 
wrote:
 On Thursday, 2 November 2017 at 10:00:25 UTC, Temtaime wrote:
 Support for dub will be great :)
Yes...
 Now all works
 Thanks !
Alright :-)
Could you write more detail installation instruction? Do I need only SublimeLinter and your plugin, or I need something more? Like tool-tips plugin? Which paths and in which menu should I edit?
Nov 02 2017
parent reply Suliman <evermind live.ru> writes:
On Thursday, 2 November 2017 at 15:13:31 UTC, Suliman wrote:
 On Thursday, 2 November 2017 at 10:04:44 UTC, Bastiaan Veelo 
 wrote:
 On Thursday, 2 November 2017 at 10:00:25 UTC, Temtaime wrote:
 Support for dub will be great :)
Yes...
 Now all works
 Thanks !
Alright :-)
Could you write more detail installation instruction? Do I need only SublimeLinter and your plugin, or I need something more? Like tool-tips plugin? Which paths and in which menu should I edit?
I am getting error: Package Control: No updated packages Unable to open /C/Users/suliman/AppData/Roaming/Sublime Text 3/Packages/User/SublimeLinter.sublime-settings
Nov 02 2017
next sibling parent Suliman <evermind live.ru> writes:
it's seems that it is work, at last it show red labels on code, 
but for example it is do not show right auto completion after 
point in `std.`
https://snag.gy/uP6Uxl.jpg
Nov 02 2017
prev sibling parent reply Suliman <evermind live.ru> writes:
I install Sublime Linter first and then this linter and error:
Unable to open /C/Users/suliman/AppData/Roaming/Sublime Text 
3/Packages/User/SublimeLinter.sublime-settings

is gone. But issue with auto-completion is still exists.
Nov 02 2017
parent reply Suliman <evermind live.ru> writes:
On Thursday, 2 November 2017 at 15:28:36 UTC, Suliman wrote:
 I install Sublime Linter first and then this linter and error:
 Unable to open /C/Users/suliman/AppData/Roaming/Sublime Text 
 3/Packages/User/SublimeLinter.sublime-settings

 is gone. But issue with auto-completion is still exists.
Oh, my bad. it's Linter but not auto-completion tool. Really sorry.
Nov 02 2017
parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Thursday, 2 November 2017 at 15:53:08 UTC, Suliman wrote:
 On Thursday, 2 November 2017 at 15:28:36 UTC, Suliman wrote:
 I install Sublime Linter first and then this linter and error:
 Unable to open /C/Users/suliman/AppData/Roaming/Sublime Text 
 3/Packages/User/SublimeLinter.sublime-settings

 is gone. But issue with auto-completion is still exists.
Oh, my bad. it's Linter but not auto-completion tool. Really sorry.
Correct. You can get tool tips by going to Tools->sublimeLinter->Open Settings and change to
         "tooltips": true,
in the right hand side pane.
Nov 02 2017
prev sibling next sibling parent reply drug <drug2004 bk.ru> writes:
31.10.2017 01:22, Bastiaan Veelo пишет:
 SublimeLinter-contrib-dmd [1] is a plug-in for the Sublime Text 3 editor 
 [2]. Unlike linters that are based on DScanner, it actually invokes dmd 
 on the file that is being edited, as you edit. If dmd finds anything to 
 complain about, an annotation is shown in the editor: warnings and 
 deprecations in orange, errors in red. If SublimeLinter (a plug-in 
 dependency) is configured to show tool tips, the error message pops up 
 after a click on the annotation (see screen shots [1]). SublimeLinter 
 offers shortcuts for jumping to errors and it is possible to postpone 
 on-the-fly linting or lint only on request.
 
 The advantages of using dmd for linting are:
 
 1. The parser is always up-to-date.
 2. Full symbol resolution, including imports.
 3. Mixins are expanded.
 4. Templates are validated.
 5. Deprecation warnings are included.
 6. The "did you mean …" assistance appears right where it is most helpful.
 
 The plug-in is easily installed from within the editor, as described on 
 the project page [1].
 
 Dmd does not always get the column number exactly right, which can cause 
 the annotation to be misplaced, but that is just a cosmetic deficiency. 
 I have not tested this on larger code bases and only on Windows, but I 
 expect it to work on all platforms supported by Sublime Text 3. Please 
 let me know if you find any issues. The editor is not free, but it 
 continues to work after your evaluation period has expired.
 
 On request I can add an option to configure the path to dmd, currently 
 it expects to find dmd using the system path.
 
 
 Hope you like it,
 Bastiaan.
 
 [1] https://github.com/veelo/SublimeLinter-contrib-dmd
 [2] http://www.sublimetext.com/
Thank you for your tool! It works like a charm even in mixins and works out of box. I installed it just in case but now I've caught myself that I start using it.
Nov 21 2017
parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 21 November 2017 at 18:43:29 UTC, drug wrote:
 31.10.2017 01:22, Bastiaan Veelo пишет:
 SublimeLinter-contrib-dmd [1] is a plug-in for the Sublime 
 Text 3 editor [2]. Unlike linters that are based on DScanner, 
 it actually invokes dmd on the file that is being edited, as 
 you edit.
Thank you for your tool! It works like a charm even in mixins and works out of box. I installed it just in case but now I've caught myself that I start using it.
Thanks for the thumbs up :-)
Nov 21 2017
prev sibling parent reply Manuel Maier <mjmaier gmx.de> writes:
On Monday, 30 October 2017 at 22:22:42 UTC, Bastiaan Veelo wrote:
 [...] Unlike linters that are based on DScanner, it actually 
 invokes dmd on the file that is being edited, as you edit. [...]
I just tried the plugin and it seems to work very well! Thanks for the good work. Have you considered invoking dub instead of dmd if there's a dub.json/.sdl file? I imagine when people use "preBuildCommands" to generate code, for example, the linter might report false positives. Same goes for custom D versions (e.g. `version(Have_foo) { ... }`). There's also the --single feature of dub: https://code.dlang.org/advanced_usage Such files may not work correctly with this linter at this time I presume. All in all they way this plugin works is a great idea! The more it knows about the full commandline of the resulting dmd invocation, the more accurate it is.
Nov 26 2017
parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Sunday, 26 November 2017 at 10:15:05 UTC, Manuel Maier wrote:
 On Monday, 30 October 2017 at 22:22:42 UTC, Bastiaan Veelo 
 wrote:
 [...] Unlike linters that are based on DScanner, it actually 
 invokes dmd on the file that is being edited, as you edit. 
 [...]
I just tried the plugin and it seems to work very well! Thanks for the good work.
Thanks.
 Have you considered invoking dub instead of dmd if there's a 
 dub.json/.sdl file? I imagine when people use 
 "preBuildCommands" to generate code, for example, the linter 
 might report false positives. Same goes for custom D versions 
 (e.g. `version(Have_foo) { ... }`).
No I haven't considered using dub. Does dub allow the processing of a single file from the project without generating code? Note that you don't want to build the whole project upon every activation of the linter, because of speed but also because of errors that do not apply to the file in the current view.
 There's also the --single feature of dub: 
 https://code.dlang.org/advanced_usage Such files may not work 
 correctly with this linter at this time I presume.
I don't see why not?
 All in all they way this plugin works is a great idea! The more 
 it knows about the full commandline of the resulting dmd 
 invocation, the more accurate it is.
If you have a case where it isn't sufficient, I am interested to see how it can be improved. You can experiment with it as explained here: https://forum.dlang.org/post/zugbovfvfviapcjqdhxw forum.dlang.org
Nov 27 2017
parent reply Manuel Maier <mjmaier gmx.de> writes:
On Monday, 27 November 2017 at 11:26:51 UTC, Bastiaan Veelo wrote:
 On Sunday, 26 November 2017 at 10:15:05 UTC, Manuel Maier wrote:
 On Monday, 30 October 2017 at 22:22:42 UTC, Bastiaan Veelo 
 wrote:
 [...] Unlike linters that are based on DScanner, it actually 
 invokes dmd on the file that is being edited, as you edit. 
 [...]
I just tried the plugin and it seems to work very well! Thanks for the good work.
Thanks.
 Have you considered invoking dub instead of dmd if there's a 
 dub.json/.sdl file? I imagine when people use 
 "preBuildCommands" to generate code, for example, the linter 
 might report false positives. Same goes for custom D versions 
 (e.g. `version(Have_foo) { ... }`).
No I haven't considered using dub. Does dub allow the processing of a single file from the project without generating code? Note that you don't want to build the whole project upon every activation of the linter, because of speed but also because of errors that do not apply to the file in the current view.
Not sure about that, would need some investigating. From what I can tell, dub docs have improved quite a bit in the past year.
 There's also the --single feature of dub: 
 https://code.dlang.org/advanced_usage Such files may not work 
 correctly with this linter at this time I presume.
I don't see why not?
Sorry, let me rephrase. What I meant is that, with dub, you can add dependencies (e.g. some http library) and define D versions. So even tho it's only a single file, the invocation of dmd alone is not sufficient to understand the code completely. I guess it would be most useful if I created some test cases and documented them.
 All in all they way this plugin works is a great idea! The 
 more it knows about the full commandline of the resulting dmd 
 invocation, the more accurate it is.
If you have a case where it isn't sufficient, I am interested to see how it can be improved. You can experiment with it as explained here: https://forum.dlang.org/post/zugbovfvfviapcjqdhxw forum.dlang.org
Haven't experimented with it yet so it's all just speculation so far. I'm quite interested in a dub linter. As far as I can tell from a first glance at your plugin code, it doesn't seem too complicated. I think I will investigate whether dub is suitable for this endeavor and implement that aspect of the plugin myself. If I have enough time in the coming days, of course. Will keep you posted!
Nov 28 2017
parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 28 November 2017 at 18:07:35 UTC, Manuel Maier wrote:
 On Monday, 27 November 2017 at 11:26:51 UTC, Bastiaan Veelo 
 wrote:
 On Sunday, 26 November 2017 at 10:15:05 UTC, Manuel Maier 
 wrote:
 Have you considered invoking dub instead of dmd if there's a 
 dub.json/.sdl file? I imagine when people use 
 "preBuildCommands" to generate code, for example, the linter 
 might report false positives. Same goes for custom D versions 
 (e.g. `version(Have_foo) { ... }`).
No I haven't considered using dub. Does dub allow the processing of a single file from the project without generating code? Note that you don't want to build the whole project upon every activation of the linter, because of speed but also because of errors that do not apply to the file in the current view.
Not sure about that, would need some investigating. From what I can tell, dub docs have improved quite a bit in the past year.
I had a look, and I don't think it does support this.
 There's also the --single feature of dub: 
 https://code.dlang.org/advanced_usage Such files may not work 
 correctly with this linter at this time I presume.
I don't see why not?
Sorry, let me rephrase. What I meant is that, with dub, you can add dependencies (e.g. some http library) and define D versions. So even tho it's only a single file, the invocation of dmd alone is not sufficient to understand the code completely.
Then I guess "dub describe" would report that dependency. We could add support for that, when a file starts with a dub shebang. The plugin does not detect versions from dub yet, but I am not sure it needs to. IIANM then the code inside version() blocks is required to be syntactically correct, and it could well be that dmd will bark at syntax errors inside version blocks even when they are not selected. Possibly some errors relating to symbol resolution and mixins may still go undetected though. If there are multiple versions, you would ultimately want to lint all available ones? This can become a bit hairy.
 I guess it would be most useful if I created some test cases 
 and documented them.
Yes.
 All in all they way this plugin works is a great idea! The 
 more it knows about the full commandline of the resulting dmd 
 invocation, the more accurate it is.
If you have a case where it isn't sufficient, I am interested to see how it can be improved. You can experiment with it as explained here: https://forum.dlang.org/post/zugbovfvfviapcjqdhxw forum.dlang.org
Haven't experimented with it yet so it's all just speculation so far. I'm quite interested in a dub linter. As far as I can tell from a first glance at your plugin code, it doesn't seem too complicated.
You are right, and starting a new linter is easy as well, and well documented: http://sublimelinter.readthedocs.io/en/latest/creating_a_linter.html
 I think I will investigate whether dub is suitable for this 
 endeavor and implement that aspect of the plugin myself. If I 
 have enough time in the coming days, of course. Will keep you 
 posted!
Have fun, Bastiaan.
Nov 29 2017