Hello, everyone. I have written a more Xcode like completion extension for tm_dialog. My guess is that this is of interrest to more people than me. The code has not been commited yet, but I have made a screencast to show of some of the functionallity. [ http://mail.mac.se/joachimm/TextMateCodeCompletionEnhancements.mov ] , right now I am looking for suggestions for the programmatic and user interface.
what I have so far
"$DIALOG" -f -p '{suggestions = ({title = "foo";filterOn = "foo";},{title = "bar";filterOn = "bar";snippet = "(${1:hello}, ${2:again})";}); mutablePrefix = "fo"; staticPrefix = "";}
as you can see you need to populate an array called 'suggestions' with dicts with the keys 'title' and 'filterOn', the key 'snippet' is optional.
you also have to give the keys mutablePrefix which is the prefix when you launched the command. plus the optional staticPrefix which is handy when you are completing things that are multipart such as objective-c methods (it is not really necessary since filterOn does not have to have the same prefix as title).
Once the command is running it should work as follows.
* an alphanumeric key press appends to mutablePrefix, there by potentially limiting the list of candidates.
* a tab press inserts the longest common prefix among the candidates, this will ofcourse never limit the list in itself, but can quickly be followed up with a alphanumeric keypress, thereby saving lots of typing.
* a return inserts the current selection in the list, plus its snippet key if there is one.
* delete removes a char, if this moves the caret before the beginning of the search prefix the dialog goes away
* up/down moves in the list
* any other key closes the dialog and hands control back to TextMate.
What are your thought, am I missing something that could be useful for your language?
Thanks in advance.
Joachim Mårtensson
I guess the completion menu should linger with a message about no completions beeing available. I have not implemented that though.
wouldn't it be better to simply disappear the menu?
At first I thought so as well, but after some thinking I guess it would be nice to be able to type a wrong char and delete it without having to pop the menu up again, I think that is the reason why xcode has that behaviour.
Joachim Mårtensson
Eclipse (http://www.eclipse.org/) has very good code completion features. Their code completion drop-down also includes snippets (which they call "Template Proposals"). It is also incredibly fast and accurate (it doesn't suggest syntactically invalid completions).
I seriously recommend taking a look at Eclipse's code completion UI and back-end. This is not for the feint of heart.
On 8/17/07, Joachim Mårtensson joachimm@etek.chalmers.se wrote:
what happens if you type something that isn't in the list?
I guess the completion menu should linger with a message about no completions beeing available. I have not implemented that though.
Joachim Mårtensson
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Sounds awesome. Can't wait to use it. This will be the new default for my codecompletion library.
thomas Aylott — subtleGradient — CrazyEgg — bundleForge
Sounds awesome. Can't wait to use it. This will be the new default for my codecompletion library.
thomas Aylott ? subtleGradient ? CrazyEgg ? bundleForge
ScreenCast #2: http://mail.mac.se/joachimm/TextMateCodeCompletionEnhancements2.mov
We talked a bit on IRC about how to avoid having to pre-generate all the snippets. I guess one idea is to supply a shell command that generates the snippet, Which is then inserted by the plugin. I am trying to come up with a syntax for that. Perhaps an additional key to the dict will do?
{mutableString = 'foo'; suggestions = (...) ; shell = { start = 'ruby -e ' '; end = ''';}; }
and then the plist version of whatever was selected gets inserted between start and end? perhaps an optional middle key that tells what key-value from the returned list to insert?
Perhaps someone can come up with a better key-name than shell.
Joachim Mårtensson
On 17-aug-2007, at 19:00, Joachim Mårtensson wrote:
Hello, everyone. I have written a more Xcode like completion extension for tm_dialog. My guess is that this is of interrest to more people than me. The code has not been commited yet, but I have made a screencast to show of some of the functionallity. [ http://mail.mac.se/joachimm/TextMateCodeCompletionEnhancements.mov ] , right now I am looking for suggestions for the programmatic and user interface.
Wow, this looks so promising. I can't wait to start using it.
Without mimicking Xcode too much, I think the user interface could improve. My suggestions: a. the bounding box of the dialog popup should be as small as possible, i.e. decrease the height of the window as the number of completions shrink. b. the dialog popup window could be slightly transparent and would be nice if it would fade in. c. the arguments to a function (the parts of the snippet that should be filled in by the user) could have a different style (italic?) or colour (greyish?) from the non-volatile parts of the function (the function name, the parentheses, etc) d. the addition of a little icon in front of the completion, indicating whether it is a C function, a objective-C method, a constant, a class, etc. (I know this sooo xcode, but I think it's very useful).
Finally: when does this completion window pop up? When you stop typing for a 0.8 seconds (and if *has* available completions)? Or do you have to invoke it with a special key combo? I would very much like the former one, combined with the disappearance of the completion window if no key is pressed in the following 2 seconds. (plus a way to customize these time preferences or disable the automatic popup behavior).
best regards dirk
----------------------------- Dirk van Oosterbosch de Wittenstraat 225 1052 AT Amsterdam the Netherlands
http://labs.ixopusada.com -----------------------------
On 17-aug-2007, at 19:00, Joachim Mårtensson wrote: Wow, this looks so promising. I can't wait to start using it.
Without mimicking Xcode too much, I think the user interface could improve. My suggestions: a. the bounding box of the dialog popup should be as small as possible, i.e. decrease the height of the window as the number of completions shrink.
I have changed the behaviour to work like this.
b. the dialog popup window could be slightly transparent and would be nice if it would fade in.
I am not to certain about the fading part, but some transparency could be nice.
c. the arguments to a function (the parts of the snippet that should be filled in by the user) could have a different style (italic?) or colour (greyish?) from the non-volatile parts of the function (the function name, the parentheses, etc)
I hope to be able to accomplish that, rememember however that the pop-up is to be a reusable component that can work with many different languages, the list of shown methods are given to the popup via a plist. And it will be up to the one supplying the plist to tell how the text should be displayed, I'll have to come up with some method of describing this though.
d. the addition of a little icon in front of the completion, indicating whether it is a C function, a objective-C method, a constant, a class, etc. (I know this sooo xcode, but I think it's very useful).
I find the icons nice to look at if perhaps not very useful, so I will probably give the option of supplying an image path to in the plist.
Finally: when does this completion window pop up? When you stop typing for a 0.8 seconds (and if *has* available completions)? Or do you have to invoke it with a special key combo?
It is currently invoked via a key-combo, ideally it would work as you describe, currently the onIy way I can think of to accomplish what you describe is if I inject the command permanently into the event stream, something I am certain Allan would not approve of. Allan has said that there will be additional ways of invoking commands in the future, perhaps something that I can use.
I would very much like the former one, combined with the disappearance of the completion window if no key is pressed in the following 2 seconds. (plus a way to customize these time preferences or disable the automatic popup behavior).
best regards dirk
Dirk van Oosterbosch de Wittenstraat 225 1052 AT Amsterdam the Netherlands
http://labs.ixopusada.com
thanks for the feedback Joachim Mårtensson
I would love to give more feedback, but since all I've seen is a short screencast, I can only say so much.
Also, aren't we all expecting some kind of code-completion framework in TM2?
I would love to give more feedback, but since all I've seen is a short screencast, I can only say so much.
If you have xcode and use SVN to get bundles, you can easily install the changes by building and installing the Dialog Plugin (the changes were commited 5 days ago)
Also, aren't we all expecting some kind of code-completion framework in TM2?
Not sure what you have heard, but the impression I have been given is that there will be extended snippet syntax for multiple choice tab-placeholders. Even if Allan has something more powerful in addition to this, TM2 is still several months away.
Joachim Mårtensson
On 8/24/07, Thomas Aylott (subtleGradient) oblivious@subtlegradient.com wrote:
On Aug 24, 2007, at 4:17 AM, Oliver Taylor wrote:
Also, aren't we all expecting some kind of code-completion framework in TM2?
Never bank on vaporware
It's not yet vaporware because there isn't any release date set which could be overdue ;)
Niels