Sublime Forum

Python autocomplete for methods (problems with parentheses)

#1

Hi, folks!

I’m a newbie with Sublime and Python development. Could some one help me to find option where i can turn on autocomplete for methods in Python in Sublime?

Example:

string = ‘string’
print(string.title())

So problem is that i need to type “()” after “.title” manually. What i want is when i type “.title” and hit Enter it will be look like this “.title()”.

Best,
Andrey.

0 Likes

Is it possible auto complete brackets for functions and methods?
#2

There are several packages out in the wild, which support code intelligence for python. You can find them at https://packagecontrol.io

  • Anaconda
  • LSP (needs python and python-language-server)
  • Python - Autocompletion

Anaconda tries to provide a full featured python IDE, but I personally find it too slow and jerky with lots of flickering during auto-completion. Not fluent to work with.

I currently use LSP which is a common approach to add language-server-protocol support to ST. It works with several languages already. It is the approach Microsoft uses for VSCode to support IntelliSense. It automatically provides completions/tooltips/linters if supported by the language-server. python-language-server uses Jedi library to provide completions and tooltips.

The same library is used by Jedi - Autocompletion which is some kind of proprietary approach of creating a language server. It also uses python to run some kind of server app which uses Jedi to provide completions. But it does not support linting.

0 Likes

#3

Thank you mate! I installed Jedi hours ago and still can’t realise how to solve my issue. In VSCode everything is simple:

I just can’t find settings for this.

0 Likes

#4

Jedi - Autocompletion has a "auto_complete_function_params": "required", setting, which should automatically add the required parameters and also empty brackets.

Such tasks are to be done by the plugins. So you might need to file an issue at the package’s GitHub page to ask for such a function.

0 Likes

#5

It adds parameters but with brackets problems. Maybe it’s something wrong with new sublime build.

0 Likes