Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion always returns snippets, even if snippets are not supported by the client #171

Closed
miquecg opened this issue Mar 30, 2020 · 9 comments · Fixed by #177
Closed

Comments

@miquecg
Copy link

miquecg commented Mar 30, 2020

I'd like to ask what to expect from suggestions like do/end blocks. In my case they are literally inserted:

def foo do^@ $0^@end

I was expecting to have:

def foo do
  ‸ (cursor goes here)
end

Looks like a problem supporting snippets provided by the LS. It didn't happend before with previous versions of elixir-ls. I'm running Vim on terminal with ALE.

@miquecg miquecg changed the title [question] Autocomplete do/end block Completion snippets not working for do/end blocks and similar Mar 31, 2020
@axelson
Copy link
Member

axelson commented Mar 31, 2020

@miquecg The "$0" indicates where the cursor is supposed to be. I'm not sure why this would change recently since not changes have been made in that area in quite a while. What version did you upgrade from and to? Are you sure you're using this repository vs https://github.com/JakeBecker/elixir-ls ?

Also does Vim ALE support the snippetSupport option?

		/**
		 * Client supports snippets as insert text.
		 *
		 * A snippet can define tab stops and placeholders with `$1`, `$2`
		 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
		 * the end of the snippet. Placeholders with equal identifiers are linked,
		 * that is typing in one will update others too.
		 */
		snippetSupport?: boolean;

@miquecg
Copy link
Author

miquecg commented Apr 1, 2020

Hi @axelson.

Well, I've started using your Elixir LS recently, from version 0.3.0 I think. Probably snippets were not working at all before, but I don't remember to have placeholders inserted in place.

I'm using your fork, not the original repo.

Regarding ALE, looks like it doesn't support snippets feature: dense-analysis/ale#1821

In fact, support for snippets is disabled on the init message to the server: https://github.com/dense-analysis/ale/blob/master/autoload/ale/lsp.vim#L355

Knowing this, what should I expect from do/end or similar suggestions?

@axelson
Copy link
Member

axelson commented Apr 1, 2020

@miquecg looking at this further it seems that even though ElixirLS reads snippet support, it is always sends snippets even if snippet support is disabled, which is a bug. I edited the issue title to better reflect the bug. It should be a relatively straightforward fix that is constrained to apps/language_server/lib/language_server/providers/completion.ex.

@axelson axelson changed the title Completion snippets not working for do/end blocks and similar Completion always returns snippets, even if snippets are not supported by the client Apr 1, 2020
@miquecg
Copy link
Author

miquecg commented Apr 2, 2020

Thanks, glad to help discovering a bug :)

axelson added a commit that referenced this issue Apr 2, 2020
Note: the previous regex did not match snippets

Fixes #171
@axelson
Copy link
Member

axelson commented Apr 2, 2020

@miquecg can you confirm that the fix works for you on the latest master?

@miquecg
Copy link
Author

miquecg commented Apr 3, 2020

@axelson Looks like it's working ok.

Thanks!

@axelson
Copy link
Member

axelson commented Apr 3, 2020

Great, glad to hear it!

@jeffrey-xiao
Copy link
Contributor

jeffrey-xiao commented Apr 16, 2020

I'm not entirely sure if this issue has been fixed. On master, it seems like function completions always return snippets even if snippetSupport is false.

I'm using vim-lsp which specifies snippetSupport as false.

When completing Enum.join, elixir-ls gives me this as a completion: Enum.join(${1:enumerable}, ${2:joiner \\\\ ""}).

Looking into the code, it seems like function completion always expands to snippet form.

Also I don't think the regex for checking if it's snippet handles the case with a text placeholder (e.g. ${1:enumerable}).

Ideally, I would like it if the function completion without snippets is just an empty arguments list.

@axelson
Copy link
Member

axelson commented Apr 16, 2020

@jeffrey-xiao you're probably right, can you file that as a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants