Closed jcldavid closed 11 years ago
Hi @Apathetic012
We should wait what @JulianEberius says about this issue but I don't see the easy way to perform this change because I think the only behavior what we can control about auto-completion is just for the proposal words list not the behavior of adding the selected word code to the buffer.
Motivated by your question I looked a bit more into what information Rope provides with the completion proposals, and what ST2's API allows. It was in fact quite simple to implement your request, and even more: Sublime Rope will now insert not only the function name and the "()" for functions without arguments, but also a snippet with the argument names that you can tab through if there are arguments. For example, "os.geten" will insert os.getenv(key, default) with "key" selected, and TAB jumping to "default".
Please report if it works for you!
p.s.: This new behavior can also be disabled using the "add_proposal_snippet" setting. p.p.s.: Concerning your question about how to make the completions appear automatically: This has nothing to do with SublimeRope I think, it is ST2 behavior which you can change with a setting called "auto_complete" (should be set to True)
Interesting @JulianEberius I didn't know about this ST2's API possibilities. I'll read your last changes in detail :)
Basically, ST2 allows you to return not only plain strings as proposals but also strings in it's (or originally, TextMate's) Snippet format.
You can look this up at http://docs.sublimetext.info/en/latest/extensibility/completions.html and http://docs.sublimetext.info/en/latest/extensibility/snippets.html
Julian
@Apathetic012 / @JulianEberius:
It is actually quite easy to make SublimeText to show the autocomplete dialog automatically after typing the dot in, for example: "app.".
You just have to create a file named "Python.sublime-settings" in Packages/User (in case you don't have one already), and there, you add a line like this:
"auto_complete_triggers": [ {"selector": "source.python - string - comment", "characters": "."} ],
So the autocomplete gets triggered when hitting "." (but only for Python source code, but not inside strings or comments :D).
For reference, here's more or less what I'm currently using for Python:
{
"word_wrap": false,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"use_tab_stops": true,
"auto_indent": true,
"trim_automatic_white_space": true,
"trim_trailing_white_space_on_save": true,
"auto_complete_selector": "source.python - string - comment - constant.numeric",
"auto_complete_triggers": [ {"selector": "source.python - string - comment", "characters": "."} ],
}
The line "auto_complete_selector": "source.python - string - comment - constant.numeric",
makes the autocomplete not to show inside strings or comments, but fails to do the same with literal hexadecimal numbers (that's seems to be a bug in ST2).
Yes it works this way :-) -> closed
For example when I type:
then I press
ctrl+space
(how do I make the functions automatically appear?), then I press tab, the()
are not included. So it becomes:instead of
Is there a way to make it insert the
()
automatically?