[TxMt] [ANN] Textmate Code Completion

thomas Aylott oblivious at subtlegradient.com
Mon Dec 18 23:12:43 UTC 2006


Alright then.

I have some stuff done.
Update you support folder and Experimental bundle.
Enjoy CodeCompletion goodness.

Only have a CodeCompletions list for Ruby sofar, and that probly  
needs to be recreated.
But the library is pretty hip.

If you want to start creating static completion lists, please do.


How to use this version
Create a tmCommand, input: selection or line, output: insert as  
snippet, contents like this:

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion"
TextmateCodeCompletion.simple


By default, it'll look for a tmPreference in that bundle with the  
name "CodeCompletions".
That preference should be like this:

{	completions = ( 'fibbity', 'flabbity', 'floo' ); }

Where the completions is an array of strings.
You can overwrite that by passing in a different name for the  
preference like this:

TextmateCodeCompletion.simple('SomeOtherNameForMyCompletions')

Or you can use any random plist file like this:

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion"
choices = TextmateCompletionsPlist.new 
('path_to_my_plist_file_of_doom').to_ary
print TextmateCodeCompletion.new(choices,STDIN.read).to_s


Or you can just pass in an array manually like so:

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion"
print TextmateCodeCompletion.new([ 'fibbity', 'flabbity',  
'floo' ],STDIN.read).to_s


Some goals:

Allow for objects as input with snippets as output
Currently, the choices are simple an Array of strings.
We will need to extend this eventually to support objects with values  
that are snippets.
So you'll select your choice based on the key, but the calue of the  
key/value pair is inserted.

Speed improvements.
Maybe cache the plists in ram or something.

Line only input.
Currently we have to do some fancy footwork to insert the right thing  
in the right way
since the input can either be a selection or the current line.
And if you're input is a selection, then the command only replaces  
the selectio,
so you have to make sure you don't reinsert the context and the  
choice_partial and stuff like that.


thomas Aylott Ñ design42 Ñ subtleGradient Ñ CrazyEgg

On Dec 7, 2006, at 10:06 AM, thomas Aylott wrote:

> Ok. There are now a bunch of people that have signed on to work on  
> this thing.
>
> Time to start divvying up the workload.
>
> #1: First, we need a Ruby Class for the core essentials of the  
> completion stuff. It needs to:
> Ã	Be an external library that can be called from a hundred  
> different tmCommands
> X	Be fully runnable from the terminal by manually passing in all  
> the arguments (so, use the TM_* vars only as fallback)
> Ã	Get the text you're in the middle of writing
> Ã	Get the list of completions based on that text from somewhere  
> (see #2)
> Ã	Show the menu and let you make your selection
> Ã	Return a snippet with the results

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20061218/821cbf34/attachment.html>


More information about the textmate mailing list