www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Request for editor scripting help

reply "Brian Schott" <briancschott gmail.com> writes:
I've been making some progress on a project called DCD[1], which 
is D's answer to Go's Gocode[2]. It's a command-line 
client/server autocompletion program for D built off the same 
lexer/parser/ast code that powers DScanner.

I'd like to get some help writing integration scripts for the 
editors that I don't use such as Vim, Emacs, Sublime, and of 
course your favorite that I left off the list. If you have 
experience scripting your text editor of choice and some spare 
time to play with new and unstable software, please consider 
creating a pull request.

[1] https://github.com/Hackerpilot/DCD
[2] https://github.com/nsf/gocode
Aug 08 2013
next sibling parent reply "Jacob Carlborg" <doob me.com> writes:
On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], 
 which is D's answer to Go's Gocode[2]. It's a command-line 
 client/server autocompletion program for D built off the same 
 lexer/parser/ast code that powers DScanner.

 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list. If you have 
 experience scripting your text editor of choice and some spare 
 time to play with new and unstable software, please consider 
 creating a pull request.
Sounds like a great idea. Perhaps it's easier if you tell us which editor(s) you're planning to adopt, if any. -- /Jacob Carlborg
Aug 09 2013
parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 9 August 2013 at 10:35:17 UTC, Jacob Carlborg wrote:
 On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], 
 which is D's answer to Go's Gocode[2]. It's a command-line 
 client/server autocompletion program for D built off the same 
 lexer/parser/ast code that powers DScanner.

 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list. If you have 
 experience scripting your text editor of choice and some spare 
 time to play with new and unstable software, please consider 
 creating a pull request.
Sounds like a great idea. Perhaps it's easier if you tell us which editor(s) you're planning to adopt, if any. -- /Jacob Carlborg
I'll look into kate. Can't promise anything due lack of time though. But it's something I'd benefit directly from, so .. :-)
Aug 09 2013
parent reply David <d dav1d.de> writes:
 I'll look into kate. Can't promise anything due lack of time though. But
 it's something I'd benefit directly from, so .. :-)
 
I really hope this will work for Kdevelop, too!
Aug 09 2013
parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 9 August 2013 at 11:00:36 UTC, David wrote:
 I'll look into kate. Can't promise anything due lack of time 
 though. But
 it's something I'd benefit directly from, so .. :-)
 
I really hope this will work for Kdevelop, too!
After one minute of api docs: It's an interface to KTextEditor, so it should somehow :-)
Aug 09 2013
parent reply Val Markovic <val markovic.io> writes:
For Vim, integration with the YouCompleteMe[1] plugin would be a great
option (if I may say so myself). YCM offers a Completer API which can be
used to connect a semantic completion engine for any language. It already
has semantic completion support for C, C++, ObjC, ObjC++ (all through


When DCD becomes stable (is it already?) I'll gladly write the integration
for YCM.

[1]: https://github.com/Valloric/YouCompleteMe


On Fri, Aug 9, 2013 at 4:07 AM, Tobias Pankrath <tobias pankrath.net> wrote:

 On Friday, 9 August 2013 at 11:00:36 UTC, David wrote:

 I'll look into kate. Can't promise anything due lack of time though. But
 it's something I'd benefit directly from, so .. :-)
I really hope this will work for Kdevelop, too!
After one minute of api docs: It's an interface to KTextEditor, so it should somehow :-)
Aug 09 2013
parent "Brian Schott" <briancschott gmail.com> writes:
On Saturday, 10 August 2013 at 18:28:36 UTC, Val Markovic wrote:
 For Vim, integration with the YouCompleteMe[1] plugin would be 
 a great
 option (if I may say so myself). YCM offers a Completer API 
 which can be
 used to connect a semantic completion engine for any language. 
 It already
 has semantic completion support for C, C++, ObjC, ObjC++ (all 
 through


 When DCD becomes stable (is it already?) I'll gladly write the 
 integration
 for YCM.

 [1]: https://github.com/Valloric/YouCompleteMe
I think at this point the command line interface is fairly stable, but I wouldn't call the program itself stable.
Aug 11 2013
prev sibling next sibling parent reply "Idan Arye" <GenericNPC gmail.com> writes:
On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], 
 which is D's answer to Go's Gocode[2]. It's a command-line 
 client/server autocompletion program for D built off the same 
 lexer/parser/ast code that powers DScanner.

 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list. If you have 
 experience scripting your text editor of choice and some spare 
 time to play with new and unstable software, please consider 
 creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
I wrote the Vim script for your Dscanner, so it shouldn't be a problem to copy it and convert ti to use DCD. But before I do that, I need you to implement a very important functionality that Dscanner has - the ability to take input from SDTIN. Without this, we would have to save the source file before we can query it - and saving the file is not something an autocompletion feature should do... It would also be nice to be able to trick DCD into thinking that the data it got from STDIN is actually the content of the unsaved source file. I don't think it should affect the results now, but it might have impact on features you will add in the future, and I think all editors should support it before those new features come out. Anyways, I think such a project should be integrated with a build system, so it could take the import information(and maybe some other data) from there.
Aug 09 2013
parent "Brian Schott" <briancschott gmail.com> writes:
On Friday, 9 August 2013 at 21:47:33 UTC, Idan Arye wrote:
 I wrote the Vim script for your Dscanner, so it shouldn't be a 
 problem to copy it and convert ti to use DCD.

 But before I do that, I need you to implement a very important 
 functionality that Dscanner has - the ability to take input 
 from SDTIN. Without this, we would have to save the source file 
 before we can query it - and saving the file is not something 
 an autocompletion feature should do...
That was one of the several things that I have planned that I hadn't gotten to yet. It's on Github now.
 It would also be nice to be able to trick DCD into thinking 
 that the data it got from STDIN is actually the content of the 
 unsaved source file. I don't think it should affect the results 
 now, but it might have impact on features you will add in the 
 future, and I think all editors should support it before those 
 new features come out.
Right now the file name wouldn't change anything. When it does, I'll add an option for it.
 Anyways, I think such a project should be integrated with a 
 build system, so it could take the import information(and maybe 
 some other data) from there.
Which one? I'd rather have the editor integration module figure that out and pass the correct -I options.
Aug 09 2013
prev sibling next sibling parent reply "Idan Arye" <GenericNPC gmail.com> writes:
On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], 
 which is D's answer to Go's Gocode[2]. It's a command-line 
 client/server autocompletion program for D built off the same 
 lexer/parser/ast code that powers DScanner.

 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list. If you have 
 experience scripting your text editor of choice and some spare 
 time to play with new and unstable software, please consider 
 creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
I can build the client just fine, but I get errors when I try to build the server: acvisitor.d(107): Error: no property 'startLocation' for type 'stdx.d.ast.EnumBody' acvisitor.d(108): Error: no property 'endLocation' for type 'stdx.d.ast.EnumBody' acvisitor.d(107): Error: no constructor for Scope acvisitor.d(138): Error: no property 'location' for type 'stdx.d.ast.Constructor' autocomplete.d(252): Error: no property 'setTokens' for type 'Parser' autocomplete.d(253): Error: struct stdx.d.parser.Parser member isSliceExpression is not accessible autocomplete.d(268): Error: no property 'setTokens' for type 'Parser' autocomplete.d(270): Error: struct stdx.d.parser.Parser member isSliceExpression is not accessible autocomplete.d(83): Error: template instance autocomplete.setCompletions!(SortedRange!(const(Token)[], "a < b")) error instantiating ../dscanner/stdx/d/parser.d(386): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(401): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(415): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(429): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(448): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(462): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(476): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(490): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(504): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(522): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(536): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(550): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(587): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(607): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(621): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(3640): Warning: statement is not reachable ../dscanner/stdx/d/parser.d(5606): Warning: statement is not reachable Since the `EnumBody` class is defined in Dscanner, I'm gonna take a wild guess and say you need to do some pushing to Dscanner. DCD depends on Dscanner's source, so wouldn't it be a better idea to include it as a submodule? Event if you are developing them in parallel, and modifying Dscanner's source all the time to suit DCD's needs, you can use two build scripts - one that takes Dscanner from the parallel directory and used actively during the development, and one that takes it from the submodule and only used before a release\push to make sure other people can build it too.
Aug 12 2013
parent reply "Brian Schott" <briancschott gmail.com> writes:
On Monday, 12 August 2013 at 19:16:34 UTC, Idan Arye wrote:
 Since the `EnumBody` class is defined in Dscanner, I'm gonna 
 take a wild guess and say you need to do some pushing to 
 Dscanner.
You're correct. I forgot to do a push last night. Unfortunately I won't be able to get this fixed for another 5 hours or so.
Aug 12 2013
next sibling parent "Idan Arye" <GenericNPC gmail.com> writes:
On Monday, 12 August 2013 at 19:34:53 UTC, Brian Schott wrote:
 On Monday, 12 August 2013 at 19:16:34 UTC, Idan Arye wrote:
 Since the `EnumBody` class is defined in Dscanner, I'm gonna 
 take a wild guess and say you need to do some pushing to 
 Dscanner.
You're correct. I forgot to do a push last night. Unfortunately I won't be able to get this fixed for another 5 hours or so.
Well, more time for me to be lazy I guess.
Aug 12 2013
prev sibling parent reply "Brian Schott" <briancschott gmail.com> writes:
On Monday, 12 August 2013 at 19:34:53 UTC, Brian Schott wrote:
 You're correct. I forgot to do a push last night. Unfortunately 
 I won't be able to get this fixed for another 5 hours or so.
It's checked in now.
Aug 12 2013
parent "Idan Arye" <GenericNPC gmail.com> writes:
On Tuesday, 13 August 2013 at 01:34:37 UTC, Brian Schott wrote:
 On Monday, 12 August 2013 at 19:34:53 UTC, Brian Schott wrote:
 You're correct. I forgot to do a push last night. 
 Unfortunately I won't be able to get this fixed for another 5 
 hours or so.
It's checked in now.
OK, I got it to work. I'm gonna copy and modify the Dscanner plugin to use DCD instead so you can have something to bundle with your repo, but in the long run, I think it's better to have a combined plugin - one that first tries DCD, and if it can't connect to the server uses Dscanner as backup. That's the way the Clojure plugins work(though to be fair - they have to. Clojure takes ages to load, so you either use a live REPL server or smash your computer with a sledgehammer) Such combined plugin shouldn't be in part of one tool's repository - since it depends on both - so when I finally get down to write one I'll put it in a separate repository. Also, I would probably make it a plugin for a build system(probably dub), so I could take import paths from there.
Aug 13 2013
prev sibling next sibling parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], 
 which is D's answer to Go's Gocode[2]. It's a command-line 
 client/server autocompletion program for D built off the same 
 lexer/parser/ast code that powers DScanner.

 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list. If you have 
 experience scripting your text editor of choice and some spare 
 time to play with new and unstable software, please consider 
 creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
How hard would it be for dcd to offer completion based on line and column numbers instead of byte offsets?
Aug 12 2013
parent "Brian Schott" <briancschott gmail.com> writes:
On Tuesday, 13 August 2013 at 06:58:23 UTC, Tobias Pankrath wrote:
 How hard would it be  for dcd to offer completion based on line 
 and column numbers instead of byte offsets?
It's more code to maintain, but it's possible. The token structure stores its line and column. https://github.com/Hackerpilot/Dscanner/blob/master/stdx/d/lexer.d#L129
Aug 13 2013
prev sibling next sibling parent "Brian Schott" <briancschott gmail.com> writes:
Status update:

Preliminary Emacs support has been pulled into the repository.
Kate and Vim are in progress. Textadept is working.

Autocomplete works in most cases now. Only a few features remain
between here and a beta release.

Tonight I managed to get a function call tip for a variable whose
type is an alias of a function pointer. Yes, I have a use case
for this[1].

http://i.imgur.com/JMXcHTZ.png

[1] https://github.com/aldacron/Derelict3
Aug 14 2013
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-08-09 08:41, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], which is D's
 answer to Go's Gocode[2]. It's a command-line client/server
 autocompletion program for D built off the same lexer/parser/ast code
 that powers DScanner.

 I'd like to get some help writing integration scripts for the editors
 that I don't use such as Vim, Emacs, Sublime, and of course your
 favorite that I left off the list. If you have experience scripting your
 text editor of choice and some spare time to play with new and unstable
 software, please consider creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
I tried to compile this and I got these errors: acvisitor.d(289): Error: no property 'name' for type 'stdx.d.ast.AliasInitializer' acvisitor.d(311): Error: no property 'name' for type 'stdx.d.ast.AliasDeclaration' acvisitor.d(322): Error: no property 'name' for type 'stdx.d.ast.AliasDeclaration' I tried this on Mac OS X, yes I know it's not supported but I wanted to try anyway. A couple of comments: * If DCD depends on DScanner, why don't you add it as a submodule? * If you don't want to include DScanner as a submodule, you should at least have a link to it * If you clone with "git clone --recursive" submodules are automatically cloned * Actually, "git clone --recursive" won't work. I think it's because you haven't used the Git protocol when including message pack * It should be mentioned how to build the project, i.e. build.sh * Does this even build out of the box on Linux? If you just clone DScanner it will create a directory "DScanner", not "dscanner" which is required by the build script. This only happened to work on Mac OS X because the file system is case insensitive -- /Jacob Carlborg
Aug 15 2013
parent reply "Brian Schott" <briancschott gmail.com> writes:
On Thursday, 15 August 2013 at 07:27:08 UTC, Jacob Carlborg wrote:
The updates to the AST library are checked in, and I've set up a 
submodule. It should build now. (Maybe now I'll remember to push 
the changes to both projects.)
Aug 15 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-08-15 10:11, Brian Schott wrote:
 On Thursday, 15 August 2013 at 07:27:08 UTC, Jacob Carlborg wrote:
 The updates to the AST library are checked in, and I've set up a
 submodule. It should build now. (Maybe now I'll remember to push the
 changes to both projects.)
Awesome, thanks. -- /Jacob Carlborg
Aug 15 2013
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-08-09 08:41, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], which is D's
 answer to Go's Gocode[2]. It's a command-line client/server
 autocompletion program for D built off the same lexer/parser/ast code
 that powers DScanner.

 I'd like to get some help writing integration scripts for the editors
 that I don't use such as Vim, Emacs, Sublime, and of course your
 favorite that I left off the list. If you have experience scripting your
 text editor of choice and some spare time to play with new and unstable
 software, please consider creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
I have read the documentation, but one thing I don't understand, when will "calltips" show up. BTW, how hard would it be to add some type information to the output? -- /Jacob Carlborg
Aug 15 2013
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-08-09 08:41, Brian Schott wrote:
 I've been making some progress on a project called DCD[1], which is D's
 answer to Go's Gocode[2]. It's a command-line client/server
 autocompletion program for D built off the same lexer/parser/ast code
 that powers DScanner.

 I'd like to get some help writing integration scripts for the editors
 that I don't use such as Vim, Emacs, Sublime, and of course your
 favorite that I left off the list. If you have experience scripting your
 text editor of choice and some spare time to play with new and unstable
 software, please consider creating a pull request.

 [1] https://github.com/Hackerpilot/DCD
 [2] https://github.com/nsf/gocode
I was able to try this now. It works on Mac OS X as well, at least with a simple test case. This looks awesome. -- /Jacob Carlborg
Aug 15 2013
prev sibling next sibling parent reply "Idan Arye" <GenericNPC gmail.com> writes:
OK, I got dotComplete working in Vim, but I can't get the 
parenComplete calltips. Which cursor position should I give? The 
left-paren? The last character of the function name? Right after 
the left-paren? I can't seem to get any to work...
Aug 16 2013
parent "Brian Schott" <briancschott gmail.com> writes:
On Friday, 16 August 2013 at 19:21:53 UTC, Idan Arye wrote:
 OK, I got dotComplete working in Vim, but I can't get the 
 parenComplete calltips. Which cursor position should I give? 
 The left-paren? The last character of the function name? Right 
 after the left-paren? I can't seem to get any to work...
It should work if you call it when the cursor is directly after the left paren.
Aug 16 2013
prev sibling parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 9 August 2013 at 06:41:10 UTC, Brian Schott wrote:
 I'd like to get some help writing integration scripts for the 
 editors that I don't use such as Vim, Emacs, Sublime, and of 
 course your favorite that I left off the list.
How do the existing plugins handle completion of non-saved parts of the file? Currently I'm just saving the file on every completion request. However that is a usability nightmare. Would saving to a temporary do without confusing DCD?
Aug 17 2013
parent "Brian Schott" <briancschott gmail.com> writes:
On Saturday, 17 August 2013 at 18:25:50 UTC, Tobias Pankrath 
wrote:
 How do the existing plugins handle completion of non-saved 
 parts of the file? Currently I'm just saving the file on every 
 completion request. However that is a usability nightmare. 
 Would saving to a temporary do without confusing  DCD?
There are several ways that you can solve this, depending on the implementation of whatever function you use to launch the client. The client supports reading from a file (which should be a temporary file to avoid the UI issues you mentioned), or from standard input. It writes to standard output. 1. Write the buffer to a temporary file, run the client on this file and redirect to another temporary. Then read this file and display the completions 2. popen "dcd-client > output.txt" and read the completions. This is what I use with Lua because its implementation of popen doesn't allow reading and writing to the same process. (I know the implementation in git at the moment does this backwards. I'm going to fix it this evening) 3. popen the client and handle everything in memory. This is probably the best way to handle it.
Aug 17 2013