In lsp-mode-20201021.1658, clicking on the light bulb in the mode line to fill in a match statement raises an error saying that yas-expand-snippet is not defined, at the backtrace below.
I do not have yasnippet installed.
Debugger entered--Lisp error: (void-function yas-expand-snippet)
yas-expand-snippet("\\{\n Some(${0:_}) => \\{}\n Non..." 4829 4894 nil)
lsp--expand-snippet("{\n Some(${0:_}) => {}\n None ..." 4829 4894)
#f(compiled-function (edit) #<bytecode 0xdcf815>)(#<hash-table equal 3/3 0xe649e1>)
mapc(#f(compiled-function (edit) #<bytecode 0xdcf815>) [#<hash-table equal 3/3 0xe649e1>])
lsp--apply-text-edits([#<hash-table equal 3/3 0xe649e1>])
lsp--apply-text-document-edit(#<hash-table equal 2/2 0xe64989>)
mapc(lsp--apply-text-document-edit (#<hash-table equal 2/2 0xe64989>))
seq-do(lsp--apply-text-document-edit (#<hash-table equal 2/2 0xe64989>))
lsp--apply-workspace-edit(#<hash-table equal 1/1 0xe64951>)
lsp-execute-code-action(#<hash-table equal 3/3 0xe648f9>)
#f(compiled-function () (interactive nil) #<bytecode 0xe6b869>)()
funcall-interactively(#f(compiled-function () (interactive nil) #<bytecode 0xe6b869>))
call-interactively(#f(compiled-function () (interactive nil) #<bytecode 0xe6b869>) nil nil)
command-execute(#f(compiled-function () (interactive nil) #<bytecode 0xe6b869>))
I think we are calling external function yas-expand-snippet without ensuring the function existence. I think the error is cause by the line here.
I will mark this as bug for now! Thank you for reporting this issue to us!
The issue here is server-side - Rust Analyzer does not support running without snippets which we try to enforce. The only option ATM to fix that client-side is the user to install yasnippet package.
@yyoncho At the moment, lsp-mode.el says:
(require 'yasnippet nil t)
If yasnippet is a hard requirement, then shouldn't that be an ordinary require form? And shouldn't it be listed in lsp-mode-pkg.el?
IMO, we should still fix this issue in the client sider; unless the server is fixed.
@jimblandy Has a good point here. Or maybe we can just simply add yasnippet as a package dependency? 馃槙
If
yasnippetis a hard requirement, then shouldn't that be an ordinaryrequireform? And shouldn't it be listed inlsp-mode-pkg.el?
it is not a hard dependency but soft. You can run perfectly fine without it when the server follows the spec.
We might change the error message though
Okay - I didn't understand that it is rust-analyzer that is misbehaving, and sending Emacs things that it should not.
Do you happen to know if there is an issue filed against rust-analyzer for this problem? I would file one myself, but I don't know the protocol, so I'm not sure how to explain the issue.
They have closed the server side issue - https://github.com/rust-analyzer/rust-analyzer/issues/2518 . I tried it on my side and with snippets being off it all works fine. How do you get that error?
Isn't that issue about snippet completion, not fill-match-arms?
Ah, actually, the issue is not in the completion. I will do the proper fix client side.
Just want to mention that now, if you don't have yasnippet the code actions that require snippets (e. g. Add derive) won't work at all.
@yyoncho is a good error message provided in that case? If not, we might want to fix that.
Hitting the error won't be possible due to the fact that the server will no longer send snippets. When there are no snippets we will behave like in #1907