llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clangd] option to disable adding parenthesis for function with auto-completion

Open z64rankaisija opened this issue 1 year ago • 2 comments

I personally am not a huge fan of having this happening. I would really love to see this option available!

What I mean is kind of like this option: --function-arg-placeholders=0. This disabling the automatic filling of argument slots. In the same way I'd love to see clangd not adding the parenthesis when auto-completion is used.

z64rankaisija avatar Jun 28 '23 02:06 z64rankaisija

@llvm/issue-subscribers-clangd

llvmbot avatar Jun 28 '23 02:06 llvmbot

https://github.com/clangd/clangd/issues/1252 is another request for a configuration option related to what text is inserted when when selecting a completion proposal.

Perhaps it would be appropriate to add both options in the Completion section of the config file?

Should --function-arg-placeholders be deprecated in favour of a config file option as well, to have everything in one place?

HighCommander4 avatar Jun 28 '23 03:06 HighCommander4

Is there any progress on this issue? This has always been disrupting and annoying for me, as it always duplicates opening parentheses unlike any other editor.

lhmouse avatar Mar 01 '24 14:03 lhmouse

Here's a concrete proposal for a config file syntax that would address this request, https://github.com/clangd/clangd/issues/1252, and supersede --function-arg-placeholders: add a new key under Completion called ArgumentLists, with the following supported values:

Value Description Function Example Template Example
None Nothing inserted in argument list position std::atan2 std::array
Delimiters Empty pair of delimiters inserted std::atan2() std::array<>
NamePlaceholders Delimiters and placeholder arguments are inserted. The placeholders are just the names of the parameters. std::atan2(y, x) std::array<T, N>
FullPlaceholders Delimiters and placeholder arguments are inserted. The placeholders are the names and types of the parameters. (Current behaviour) std::atan2(float y, float x) std::array<typename T, size_t N>

For backwards compatibility:

  • the default would be FullPlaceholders (matching the current default behaviour)
  • --function-arg-placeholders would continue to be supported, with:
    • --function-arg-placeholders=0 being an alias for ArgumentLists: Delimiters
    • --function-arg-placeholders=1 being an alias for ArgumentLists: FullPlaceholders

If both --function-arg-placeholders and ArgumentLists are specified, ArgumentLists would take precedence (I believe that's the behaviour that falls out of FlagsConfigProvider in similar cases).

Thoughts?

HighCommander4 avatar Mar 03 '24 06:03 HighCommander4

This would fix all my annoyances I have with clangd in VScode. really hope this gets approved and implemented (soon).! I really love clangd, it really improves my work but I need the None option to 100% happy with it.! Keeping my fingers crossed!

MK-Alias avatar Mar 03 '24 07:03 MK-Alias

The idea sounds great to me, too.

lhmouse avatar Mar 04 '24 04:03 lhmouse

It sounds good to me.

zyd2001 avatar Apr 29 '24 03:04 zyd2001