R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
128 stars 15 forks source link

Open/close parenthesis no longer works when using autocomplete? #123

Open PMassicotte opened 2 months ago

PMassicotte commented 2 months ago

Is it just me, but it seems that the opening/closing parenthesis are not working when selecting a function from the completion menu?

I think before it was inserting () and placing the cursor right inside ready to use arguments. It seems that I have to type them manually now.

Peek 2024-04-19 13-45

PMassicotte commented 2 months ago

Suggestion: could be nice to automatically add the = character when it is not present in the parameter list (will save some keystrokes :))

image

jalvesaq commented 2 months ago

I think before it was inserting () and placing the cursor right inside ready to use arguments. It seems that I have to type them manually now.

When I insert the opening parenthesis after a function name, the completion menu with the list of arguments appears immediately.

jalvesaq commented 2 months ago

Suggestion: could be nice to automatically add the = character when it is not present in the parameter list (will save some keystrokes :))

It makes sense. Although the = character isn't in the output of args(), if the user is going to type it, the = character will have to be typed too.

PMassicotte commented 2 months ago

I think before it was inserting () and placing the cursor right inside ready to use arguments. It seems that I have to type them manually now.

When I insert the opening parenthesis after a function name, the completion menu with the list of arguments appears immediately.

yeah me also, but I mean when you select the function, it writes it up in the buffer but without the (). Maybe it is just a matter of preference :)

PMassicotte commented 2 months ago

Suggestion: could be nice to automatically add the = character when it is not present in the parameter list (will save some keystrokes :))

It makes sense. Although the = character isn't in the output of args(), if the user is going to type it, the = character will have to be typed too.

For example

[ins] r$> args(lm)
function (formula, data, subset, weights, na.action, method = "qr", 
    model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, 
    contrasts = NULL, offset, ...) 

When we build the argument list, we could check if it ends up with = and if not, insert it?

jalvesaq commented 2 months ago

When we build the argument list, we could check if it ends up with = and if not, insert it?

No need to check. We can simply always insert it unless it is ....

jalvesaq commented 2 months ago

yeah me also, but I mean when you select the function, it writes it up in the buffer but without the (). Maybe it is just a matter of preference :)

This would almost always be useful, but not when using a function such as tapply() which receives a function as its third argument.

PMassicotte commented 2 months ago

yeah me also, but I mean when you select the function, it writes it up in the buffer but without the (). Maybe it is just a matter of preference :)

This would almost always be useful, but not when using a function such as tapply() which receives a function as its third argument.

Ah yeah you are right, did not thought about this :) Well I do not have a strong feeling about it :)

jalvesaq commented 2 months ago

Nvim-R's omni completion shows the default value of arguments:

image

This is useful because the user can immediately realise that there is no need to insert the argument if the argument has a pre-defined value and the value is what he/she would insert. This was the advantage of having the = sign only for arguments with default values.

PMassicotte commented 2 months ago

ah I see, did not realize it. I will close it as I can see that both ways are perfectly fine.

jalvesaq commented 2 months ago

I think always adding the = is a good idea, but I have to find the best way of informing cmp-r users the default value of an argument.

PMassicotte commented 2 months ago

ok I will re-open it :) I will think about a good way on my side.

Thank you.