Sublime Forum

Anaconda Autoinsertion of parenthesis for callables

#1

In the last two weeks Sublime I have grown keen on Sublime.

But one feature I painfully miss is the automatic insertion of parenthesis upon choosing a callable from the autocomplete/hint box. Sublime/Anaconda give me print but not print ().

  • Ideally the caret would be also placed in between those brackets, so I could immediately start typing parameters/arguments.

  • Even more ideal the caret would be placed after the closing bracket for callables not accepting or not requiring parameters/arguments.

Can this behavior I seek maybe unlocked with existing resources, like a setting in Sublime/Anaconda or a different plugin I have not yet found?

In case such is not possible. Can you give me any idea how complex it would be to write a plugin for it? (For simplicity restricting use case to python, maybe JavaScript here).

Thanks.

UPDATE: I checked autocompletion in JavaScript again and parenthesis plus argument placeholders are indeed sometimes added. I am not sure what to make out of this findings though.

  • PyBen
1 Like

#2

This is also bothering me with Anaconda package. You need to edit the Anaconda package and add the parenthesis when sending the auto-completion list to Sublime Text.

I added this on another package for Amxx Pawn language, you can see the code on:

		if g_add_paremeters:
			i = 1
			autocomplete = funcname + '('

			for param in params:

				if i > 1 :
					autocomplete += ', '

				autocomplete += '${%d:%s}' % (i, param.strip())
				i += 1

			autocomplete += ')'

		else:
			autocomplete = funcname + "()"
  1. https://github.com/evandrocoan/SublimeAMXX_Editor/blob/4f7be6338c6991142a9e76ea038832deddb83e5b/AMXXEditor.py#L1664-L1678
1 Like

#3

Thanks addons_zz for your reply and even more so your snippet!

DamnWidget, the master mind behind anaconda replied to me on GitHub and stackoverflow.
Indeed there is a method to activate parenthesis auto-insertion, yet on the expense of signature display of the callable.

The respective part in the Anaconda configuration file according to the stackoverflow thread is:

  • If complete_parameters is true, anaconda will add function and class
    parameters to its completions.
    If complete_all_parameters is true, it will add all the possible
    parameters, if it’s false, it will add only required parameters
    */
    “complete_parameters”: false,
    “complete_all_parameters”: false,
1 Like

#4

Did you get it to work? Even after setting the parameters to true, it’s still not completing with parentehsis.

0 Likes