Home Download Buy Blog Forum Support

ST2 Completion API

ST2 Completion API

Postby DisposaBoy on Fri Aug 26, 2011 12:49 pm

I was looking through the docs and couldn't find anything relevant so before (possibly) filing some feature requests I wanted to know if the following were already possible.
  • is it possible to disable the ST2 word (words in the document) completion list or otherwise separate it from my supplied completions - on large files it has a tendency is simply add useless noise to the list
  • is it possible to make the completions visually distinct so at at glance you can see which of the list are functions, variables, etc.
  • is it possible to specify which type of files a plugin should be accessible from - i just don't see how it can be automatically detected, and if it's loading all the plugins for every file then we're asking for trouble due to conflicts, etc.
thanks.
DisposaBoy
 
Posts: 23
Joined: Tue Aug 23, 2011 3:39 pm

Re: ST2 Completion API

Postby aparajita on Fri Aug 26, 2011 7:26 pm

is it possible to disable the ST2 word (words in the document) completion list


Yes, take a look at the SublimeCodeIntel plugin:

Code: Select all
https://github.com/Kronuz/SublimeCodeIntel/blob/master/python_codeintel.py


To trigger the autocomplete list, you run a command:

Code: Select all
view.run_command('auto_complete', {'disable_auto_insert': True})


Passing {'disable_auto_insert': True} disables the ST2 completions.

is it possible to make the completions visually distinct so at at glance you can see which of the list are functions, variables, etc.


You have to add text to the item that appears in the completion list. You can specify a separate value that is returned when the item is clicked.

is it possible to specify which type of files a plugin should be accessible from


For event listeners you have to determine what the current file type is (by checking view.scope_name) and act accordingly.
aparajita
 
Posts: 177
Joined: Sun Jul 24, 2011 10:42 pm

Re: ST2 Completion API

Postby jps on Fri Aug 26, 2011 9:20 pm

btw, disable_auto_insert will only stop the completion from being inserted when there's one logical choice, there's no way to disable the inbuilt completion sources yet.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: ST2 Completion API

Postby DisposaBoy on Sat Aug 27, 2011 11:12 am

aparajita wrote:
is it possible to disable the ST2 word (words in the document) completion list


Yes, take a look at the SublimeCodeIntel plugin:

Code: Select all
https://github.com/Kronuz/SublimeCodeIntel/blob/master/python_codeintel.py


To trigger the autocomplete list, you run a command:

Code: Select all
view.run_command('auto_complete', {'disable_auto_insert': True})


Passing {'disable_auto_insert': True} disables the ST2 completions.


Sorry I don't think I was very clear, I don't want to trigger the completion. What I wanted to do was effectively turn off the builtin sources if I was able to fulfil the request... which isn't currently possible as jps said, but I'll see how it goes I practice, maybe it's not as bad as it seems.

aparajita wrote:
is it possible to make the completions visually distinct so at at glance you can see which of the list are functions, variables, etc.


You have to add text to the item that appears in the completion list. You can specify a separate value that is returned when the item is clicked.


I'm aware of, and already do that, what I was wondering is if there was a way to say, this is a function and an appropriate icon would be placed next to it. I was already thinking of using unicode characters so I'll experiment down that route for now which at least for functions (ƒ) looks great.

aparajita wrote:
is it possible to specify which type of files a plugin should be accessible from


For event listeners you have to determine what the current file type is (by checking view.scope_name) and act accordingly.

I was hoping the editor would take care of that but this (e.g for whatever reason I get html completion in my go files) but this is workable. As long as my plugin doesn't interfere with others' I'm happy I suppose.

Thanks for yours and jps' help.
DisposaBoy
 
Posts: 23
Joined: Tue Aug 23, 2011 3:39 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests