elixir-ls
elixir-ls copied to clipboard
Can't disable auto closing of do/end block
Environment
- Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [hipe]
Elixir 1.10.3 (compiled with Erlang/OTP 22)
- VSCode ElixirLS version: 0.5.0
- Operating System Version: linux 5.4.62
Troubleshooting
- [x] Restart your editor (which will restart ElixirLS) sometimes fixes issues
- [x] Stop your editor, remove the entire
.elixir_ls
directory, then restart your editor
Issue
When I type do
to start a block and press Enter, VS Code automatically adds a matching end
on the next line. It doesn't seem to be possible to disable that behavior.
Hi, you are correct that it is not currently possible to control that behavior. On the ElixirLS side that is controlled by ElixirLS.LanguageServer.Providers.OnTypeFormatting
. A PR to enable/disable the automatic insertion of end
with a configuration setting would be accepted so I've marked this issue as an enhancement request.
This would be great to be able to disable since the auto-closing doesn't correctly add closing parentheses for anonymous function arguments.
Is there any workaround for this? Anything I use requiring do gets an end immediately inserted after with my cursor after the end, it causes more work than it saves and can run amok sometimes if I'm in the middle of a bunch of unclosed sections.
To disable this I had to:
- Replace this line with
{:ok, nil}
- Comment out two lines that add do and end to suggestions (this may not be necessary)
I also have "Editor: Accept Suggestions on Enter" set to "off"
This results in a bit saner experience for me!
@michallepicki can you create a PR with your fix (and a config setting)
@lukaszsamson I am no longer in need of that tweak, somehow do/end completion works good enough for me now - probably due to other changes done in the meantime... Sorry! I'm not even sure if my links are relevant any more, maybe.
OK, I’m going to close it as it seems the issue is not relevant anymore
Can you reopen this? It still isn't possible to disable the auto closing of do/end blocks, and the extension doesn't respect the "auto closing brackets" setting.
@thmzlt I'm convinced you are mistaking autoclosing with snippet completions. You can disable do-end closing if you disable snippets with editor.suggest.showSnippets
.