by Marciano on Fri Mar 11, 2011 5:31 am
I *did* try the on_query_completions api, but I can't get it to work the way I'd like it to.
I am trying to implement something similar to the automatic label insertion facility I had working in my ST1 LaTeX plugin. There, I was using the showCompletions API. Here, my idea was to have the following functionality: the user types, say "ref", then hits ctrl+space, and the completion pop-up appears, listing all labels in the current file. Upon selecting a label, "ref" is replaced with, say, "\ref{selected_label}"
To do so, I tried returning a list of tuples of the form:
[(expr, "\\ref{first_label}"), (expr, "\\ref{second_label}")...]
where expr is the expression to be expanded (it will contain e.g. "ref"). However, what happens is that the drop-down menu only shows the value of expr in each entry (i.e. "ref"), NOT the suggested completion.
I also tried returning sometihing else, e.g.
[("first_label", "\\ref{first_label}") etc.]
but this does not even work, because the cursor is right after "ref", and of course "first_label" is not a match for it.
So, I guess what I am trying to do is just not possible using on_query_completion. Hence, the need for direct access to a popup. But, I'd love it if it was possible to use on_query_completion some other way! The entire completions system is amazing---I am loving the .sublime-completions file, for instance.
M