Sublime Forum

ST2 Completion API

#1

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.

0 Likes

#2

Yes, take a look at the SublimeCodeIntel plugin:

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

To trigger the autocomplete list, you run a command:

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

Passing {‘disable_auto_insert’: True} disables the ST2 completions.

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.

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

0 Likes

#3

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.

0 Likes

#4

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.

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.

[quote=“aparajita”]

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

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.

0 Likes