elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.43k stars 190 forks source link

Add completion option to control insertion of parentheses #816

Closed c-alpha closed 1 week ago

c-alpha commented 1 year ago

Environment

Current behavior

When inserting a completion candidate for a function, an opening parenthesis gets inserted after the function name.

Example: Typing IO.p gets completed to IO.puts( (note the open parenthesis at the end).

This is undesirable for me, since I use the smartparens package in Emacs, and I have smartparens-strict-mode turned on for all programming languages. smartparens-strict-mode means it is impossible for the user to create unbalanced parentheses, quotes, etc. by typing or deleting text.

Ironically, it means that in the case of the above example (IO.puts(), I am not able to insert the closing ), since smartparens detects that this would lead to unbalanced parentheses. Same holds for deleting the orphaned (.

Thus, with smartparens-strict-mode, the described completion behaviour leaves the code buffer in a deadlock state (not possible to insert or delete any further parentheses).

Expected behavior

It would be great if there were a server option to set from the client, which, when turned on, would make sure that any paired delimiters (parentheses, quotes, etc.) would only ever be inserted in matching pairs when completing code.

This new option could be off by default, so as to preserve the current behaviour, and make it a backwards compatible change.

The documentation for the new option might even choose to make a reference to the smartparens package for Emacs, and its smartparens-strict-mode.

lukaszsamson commented 1 year ago

Please send a PR

lukaszsamson commented 1 week ago

Closing this. Will reopen if there's a PR implementing that