Sublime Forum

Custom Auto Complete list (mandatory list items)

#1

Hey guys!, i’m trying to find out how can i push the auto complete box to show my own wanted items (setted programmatically) instead of showing the normal completion list (indexed by sublime suggestions)

def on_query_completions(self, view, prefix, locations): list_of_items = [("item1", "content of item1"), ("item2", "content of item2")] return list_of_items

i’m trying to do an IDE that smart autocompletes the content (variables, functions, classes…)
any help is much appreciated!

0 Likes

#2

See: This Post

1 Like

#3

Thanks for the reply mate, but i’m not seeing it’s helpful as i think it’s not what i’m looking for, since i’m looking for a way to force autocompletion to show determined list items depending on the context (variables input, functions, etc…)

0 Likes

#4

from your on_query_completions method, you need to return a Tuple, the first item being your list of autocompletion entries to show, and the second being the sublime.INHIBIT_WORD_COMPLETIONS flag, which will tell ST not to show words from the file in the completions list.

1 Like

#5

Actually, i tried that and it does not work.
it would be like this?:

return (completions, sublime.INHIBIT_WORD_COMPLETIONS)

0 Likes

#6

 



 
The link was more in response to:

i’m trying to find out how can i push the auto complete box to show my own wanted items (setted programmatically) instead of showing the normal completion list

in order to provide a basic example of working with programmatic completions.
 



 
The rest of what you’re looking to do:

i’m trying to do an IDE that smart autocompletes the content (variables, functions, classes…)

would pretty much be a ton of validation within on_query_completions to determine which completions should be active.

You can utilize regions, substrings, scopes, etc. to implement contextual validation.

 
Anything in particular you’re looking to figure out?

1 Like

#7

I’m trying to avoid sublime to autocomplete words from buffer and complete only fields, variables, functions and entities used in the actual editing file

Note: of course, i distinguish the scopes (file types) only getting worked for python, java, c# and basic parsed languages

0 Likes

#8

I guess you also want to use the flag sublime.INHIBIT_EXPLICIT_COMPLETIONS then.

Documentation here: https://github.com/guillermooo/sublime-undocs/pull/190/files

To use both flags together, you can use the or keyword:

return (list_of_items, sublime.INHIBIT_WORD_COMPLETIONS or sublime.INHIBIT_EXPLICIT_COMPLETIONS)
2 Likes

#9

Thanks!, It works perfectly mate, but i still get words in the buffer listed in the autocompletion list, how can i make sublime not to show them?, any tips?

0 Likes

#10

Thanks for that, i will give them a try mate!

0 Likes

#11

There is nothing you can do to stop other plugins from also using an on_query_completions listener and adding their own items to the autocompletions list.

1 Like

#12

I understand that, however, sublime.INHIBIT_WORD_COMPLETIONS flag does not work as expected cause it is not deleting words from buffer, Sublime Text should have that option, i think it has that.

0 Likes