elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

do<enter><tab> expands as snippet, replacing `do` with `defoverridable()`

Open mikl opened this issue 4 years ago • 3 comments

Environment

  • Elixir & Erlang versions (elixir --version):
Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.12.3 (compiled with Erlang/OTP 24)
  • Operating system: MacOS 12.1
  • Editor or IDE name (e.g. Emacs/VSCode): VSCode 1.62.3
  • Editor Plugin/LSP Client name: ElixirLS

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

Logs

(Not an error, no relevant logs)


Issue

This is very similar to #610, but a slightly different pattern.

This happens when you don’t use a snippet while defining a block, like if you just type def x do<enter><tab>. The reason I press tab here is because VSCode does not add an indent level by itself, so to have properly indented code inside the do-block, pressing tab is the natural thing to do. Unfortunately, tab is also the default binding for expanding snippets in VSCode, so it decides that I was trying to type defoverridable(), so deletes my linebreak and replaces the do with that. To get around this, I have to consciously avoid properly indenting the new block and instead rely on the code formatter to do it for me.

I have tried finding a way to tell VSCode that defoverridable() is not a snippet I want to expand ever, but I have not been able to find a way.

mikl avatar Nov 24 '21 01:11 mikl

Also related: #593 – unfortunately, this issue still haunts me in ElixirLS v0.8.1.

mikl avatar Nov 24 '21 01:11 mikl

Defining a do-block snippet as mentioned in this comment does make the problem go away, so that might be a possible workaround.

mikl avatar Nov 24 '21 01:11 mikl

Also present for me in 0.9.0

ChilloManiac avatar Feb 15 '22 07:02 ChilloManiac

Fixed in https://github.com/elixir-lsp/elixir-ls/commit/e4576def20c479dc7be7cc7e6079d017cb980c98 and released in v0.11

lukaszsamson avatar Oct 02 '22 12:10 lukaszsamson

still running into this issue on v0.11 😅 I am using neovim with nvim-lsp. Deleted my project's .elixir_ls folder and no change unfortunately. Tested with vscode as well, and it seems to work as intended there, not sure why the functionality would be different though. Going to mess around some more with my lsp config and see if it's an issue there maybe

torifaye avatar Oct 18 '22 14:10 torifaye

@RobertYost my guess is nvim-lsp is sorting items differently or not respecting the preselect flag...

lukaszsamson avatar Oct 18 '22 14:10 lukaszsamson