adding text after completion is selected

I have a list of functions (min, max, …) that are displayed in the completion popup.
when the user select a function, I want to add () at the end of the function name. nothing fancy.

for now, all I found was to use a completion snippet, and add an apply function to all completion items.

something like this (functions is a list of Completion interface):

const functionsWithApply = functions.map(f => snippetCompletion(f.label + "(${})"), f)

Then I return that new list in the options from the complete function.

It seems to work, but it is not very efficient to add an apply function to all completion items, just to add the same generic code. Is there a better way to do it ?

also, if I want to use “(” as a commitCharacters, it doesn’t work because then I have 2 “()” inserted.

I can’t find a solution in the doc or the forum. Any help is welcome.

It should be possible to just define an apply function that does this, and attach it to your completion objects without wrapping them in a snippet.

Well, yeah, that’s how commit characters work—the entire completion is inserted before they are typed.

ok, so an apply function is needed on every completion object.
when defining the custom apply function, how can I move the cursor inside the 2 parenthesis ?