www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - I want Sublime 3 D auto import !

reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
I want Sublime D auto import !

When typing code like this:


     class Uno : IStylable
     {
         //
     }


I want will be auto added "import IStylable" at begin of file. 
Like this:


     import ui.istylable : IStylable;

     class Uno : IStylable
     {
         //
     }


1. I want for plugin will scan all files in project, and grep for 
"module <name>".
2. Then "module <name>" replaced to "import <name>".
3. Then "import <name>" inserted in text. At top. After line 
"module ..." if it exist, else just at top.
4. Check for "module <name>" not exists before insert.
Jun 01 2020
next sibling parent reply Johannes Loher <johannes.loher fg4f.de> writes:
On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
 I want Sublime D auto import !

 When typing code like this:


     class Uno : IStylable
     {
         //
     }


 I want will be auto added "import IStylable" at begin of file. 
 Like this:


     import ui.istylable : IStylable;

     class Uno : IStylable
     {
         //
     }


 1. I want for plugin will scan all files in project, and grep 
 for "module <name>".
 2. Then "module <name>" replaced to "import <name>".
 3. Then "import <name>" inserted in text. At top. After line 
 "module ..." if it exist, else just at top.
 4. Check for "module <name>" not exists before insert.
Demanding stuff usually doesn't work in this community. The usual answer is something like this: If you care about this, implement it yourself or pay somebody to do it.
Jun 01 2020
parent aberba <karabutaworld gmail.com> writes:
On Monday, 1 June 2020 at 17:28:16 UTC, Johannes Loher wrote:
 On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
 [...]
Demanding stuff usually doesn't work in this community. The usual answer is something like this: If you care about this, implement it yourself or pay somebody to do it.
Depends on how you interpret it.
Jun 03 2020
prev sibling parent reply Paul Backus <snarwin gmail.com> writes:
On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
 I want Sublime D auto import !

 When typing code like this:


     class Uno : IStylable
     {
         //
     }


 I want will be auto added "import IStylable" at begin of file. 
 Like this:


     import ui.istylable : IStylable;

     class Uno : IStylable
     {
         //
     }


 1. I want for plugin will scan all files in project, and grep 
 for "module <name>".
 2. Then "module <name>" replaced to "import <name>".
 3. Then "import <name>" inserted in text. At top. After line 
 "module ..." if it exist, else just at top.
 4. Check for "module <name>" not exists before insert.
Your best bet for getting IDE-like features like this is probably to use serve-d [1] together with a language server client plugin for your editor [2]. [1] https://github.com/Pure-D/serve-d [2] https://github.com/sublimelsp/LSP
Jun 01 2020
parent reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote:
 On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport
Jun 01 2020
next sibling parent Paul Backus <snarwin gmail.com> writes:
On Tuesday, 2 June 2020 at 06:00:10 UTC, Виталий Фадеев wrote:
 On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote:
 On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport
Great! You should make a post about it in the Announce forum, so that other Sublime Text users will see it.
Jun 02 2020
prev sibling next sibling parent welkam <wwwelkam gmail.com> writes:
On Tuesday, 2 June 2020 at 06:00:10 UTC, Виталий Фадеев wrote:
 On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote:
 On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport
Cool. I dont use classe but I see how this kind of functionality might be useful for other symbols.
Jun 02 2020
prev sibling parent reply bauss <jj_1337 live.dk> writes:
On Tuesday, 2 June 2020 at 06:00:10 UTC, Виталий Фадеев wrote:
 On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote:
 On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:
I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport
What happens if you have the same symbol in multiple modules? Ex. two libraries that implement symbols with same name. Is there a way to be selective? And what about keyboard shortcut?
Jun 02 2020
parent reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
On Tuesday, 2 June 2020 at 20:08:09 UTC, bauss wrote:
 What happens if you have the same symbol in multiple modules? 
 Ex. two libraries that implement symbols with same name.
First module will inserted.
 Is there a way to be selective?
I want it too! :)
 And what about keyboard shortcut?
A specially for you ! Sublime 3 / Preferences / Key bindings: [ { "keys": ["alt+a"], "command": "dlang_auto_import" }, ]
Jun 03 2020
parent reply bauss <jj_1337 live.dk> writes:
On Wednesday, 3 June 2020 at 11:54:57 UTC, Виталий Фадеев wrote:
 On Tuesday, 2 June 2020 at 20:08:09 UTC, bauss wrote:
 What happens if you have the same symbol in multiple modules? 
 Ex. two libraries that implement symbols with same name.
First module will inserted.
 Is there a way to be selective?
I want it too! :)
 And what about keyboard shortcut?
A specially for you ! Sublime 3 / Preferences / Key bindings: [ { "keys": ["alt+a"], "command": "dlang_auto_import" }, ]
Thanks, that's great!
Jun 03 2020
parent =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
On Thursday, 4 June 2020 at 04:48:22 UTC, bauss wrote:
 On Wednesday, 3 June 2020 at 11:54:57 UTC, Виталий Фадеев wrote:
 On Tuesday, 2 June 2020 at 20:08:09 UTC, bauss wrote:
 What happens if you have the same symbol in multiple modules? 
 Ex. two libraries that implement symbols with same name.

 Is there a way to be selective?
I want it too! :)
Updated: - implemented simple way to be selective !
Jun 03 2020