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

Warning (lsp-mode): Unknown method: metals/executeClientCommand #973

Closed
colin4124 opened this issue Aug 14, 2019 · 24 comments
Closed

Warning (lsp-mode): Unknown method: metals/executeClientCommand #973

colin4124 opened this issue Aug 14, 2019 · 24 comments

Comments

@colin4124
Copy link

Describe the bug
When I open scala file to start lsp-mode, it pops up Warning (lsp-mode): Unknown method: metals/executeClientCommand

To Reproduce
Open scala file to start lsp-metals

Expected behavior

Which Language Server did you use
lsp-metals

OS
Linux

Error callstack
Warning (lsp-mode): Unknown method: metals/executeClientCommand

@colin4124
Copy link
Author

The lsp-mode version I used: lsp-mode-20190810.1732

The metals version I used: scalameta/metals@98d4302

@yyoncho
Copy link
Member

yyoncho commented Aug 15, 2019

@dsyzling @kurnevsky would you take a look? Is this a metals bug because currently we do not support that method?

@kurnevsky
Copy link
Member

That's weird. We do support this method:

:notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command)
and it was added about moth ago: #936

@colin4124 could you check that this handler is present in your local copy of lsp-metals.el?

@dsyzling
Copy link
Member

I've just tried refreshing on Windows to lsp-mode 20190813.451 and running Metals latest snapshot 0.7.0+78-98d43026-SNAPSHOT. This version of the snapshot when downloaded with -Dmetals.client=emacs now does appear to turn on -Dmetals.execute-client-command=on by default so running M-x lsp-metals-doctor-run does bring up the new in Emacs html rendered view rather than launching a browser page.

Therefore I can't replicate the issue - it seems to be running metals/executeClientCommand just fine. I can re-test on Linux tonight but I'm not sure there should be any difference in platforms.

I would definitely check the lsp-metals source and look for the notification handler. I'd also check to make sure the version of lsp-mode you are running is the version you think you are loading just in case it's being loaded from another directory.

@yyoncho
Copy link
Member

yyoncho commented Aug 15, 2019

Thank you @kurnevsky and @dsyzling . I am closing the issue based on your comments. @colin4124 can you try deleting the lsp-mode folder in the elpa dir to force downloading the latest lsp-mode version. If the issue is still there please reopen the issue.

@yyoncho yyoncho closed this as completed Aug 15, 2019
@colin4124
Copy link
Author

I got it. Thanks very much ^_^

@nloyola
Copy link

nloyola commented Aug 21, 2019

I'm also having this problem even though I'm using a more recent version of the package.

OS: Ubuntu 19.04
Emacs: 26.2.90
lsp-mode: 20190819.520
metals: 0.7.0+78-98d43026-SNAPSHOT

I get this warning message on startup and also when running lsp-metals-doctor-run.

@dsyzling
Copy link
Member

Can you locate the lsp-metals.el file in the lsp-mode package and within the lsp-register-client call does it contain:
:notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command).

Can you also make sure you are loading the lsp-mode version above and not another version due to config?

@jypma
Copy link

jypma commented Aug 21, 2019

Same problem here, on Arch linux.
lsp-mode: 20190819.520 (that's the only installed version)
metals: 0.7.0+78-98d43026-SNAPSHOT
emacs: 26.2

My lsp-metals.el contains the lsp-register-client call just fine. It's quite mysterious :-)

@dsyzling
Copy link
Member

I run Arch on my laptop at home - I may have to try and replicate the issue tonight. I've been running a dev version with my metals treeview changes and the recent upstream changes and haven't seen this at all. Do you have a snippet of your config to configure lsp mode? Sometimes I've seen people customise options whereby features are disabled in lsp-mode and then functionality behaves differently.

Any error messages in lsp log? You see the message The following clients were selected based on priority: (server-id metals, priority -1) and it tells you the metals command path?

Not sure if @colin4124 found the underlying reason for his similar problem?

I might be able to find some time during the day to see if I can replicate again under Windows, but otherwise I'll try checking Arch with the latest lsp-mode packages.

@nloyola
Copy link

nloyola commented Aug 21, 2019

@dsyzling my lsp-metals.el does have the line:

:notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command)

I don't have any other versions of lsp-mode on my computer.

I don't see any errors in *lsp-log*.

From my *lsp-log*:

Command "metals-emacs" is present on the path.
Found the following clients for __filepath__: (server-id scala, priority 0), (server-id metals, priority -1)
The following clients were selected based on priority: (server-id scala, priority 0)

My config can be found here: https://github.com/nloyola/.emacs.d/blob/master/config.org#lsp-mode

I will try setting this up on a fresh virtual machine later today and see if I get the same results.

@jypma
Copy link

jypma commented Aug 21, 2019

@dsyzling
Copy link
Member

@nloyola Are you still using the old lsp-scala package? Can you disable that and use lsp-mode only - you seem to have two scala clients registered - one with priority 0 which it has selected and 1 with a priority of -1 which is the metals one.

@dsyzling
Copy link
Member

@jypma are you also using lsp-scala still in your config?

@jypma
Copy link

jypma commented Aug 21, 2019

Yes I am... dropping it as we speak :-) I guess it must've been an ensime leftover.

@nloyola
Copy link

nloyola commented Aug 21, 2019

Oh! Thanks @dsyzling for catching that. I disabled lsp-scala and no more warning message and lsp-metals-doctor-run works!

@colin4124
Copy link
Author

Sorry about I am a newbie of Emacs and elisp. So I just use start kit spacemacs and https://github.com/zheli/scala-lsp to use lsp-mode and metals . Now I am use the latest version of metals and lsp-mode-20190819.520 which I found in .emacs.d/elpa/26.1/develop

@dsyzling
Copy link
Member

@nloyola @jypma Great ! Glad you're up and working.

@colin4124 no problem at all - we've all been there (newbies that is) - steep learning curve but worth it - plenty of people around to help out.

@colin4124
Copy link
Author

@dsyzling
Copy link
Member

@colin4124 I don't use spacemacs and I'm having difficulty understanding where those functions are called and even what spacemacs layers are. Config wise you need to configure the lsp-mode package to add a scala-mode hook to initialise lsp-mode as is outlined here: https://scalameta.org/metals/docs/editors/emacs.html. However this config approach may not suit spacemacs. You may be better off finding a spacemacs config for lsp-mode that doesn't depend on or use lsp-scala and use that as a minimal base going forward. You can always add additional elements which may have been added in the zheli config you've pointed to - such as scala indent alignment etc. at a later date.

My fear is this configuration is adding hooks to lsp-mode to configure lsp-ui-mode and this should be done by lsp-ui-mode package itself. These packages should evaluate themselves in the order that's required to initialise, you shouldn't need to specify this externally - the lsp-mode author is careful to make sure you can combine them and each of them will work within their dependencies.

@dsyzling
Copy link
Member

Another approach would be to head over to the lsp-mode gitter channel and see if there are any spacemacs users or may be the author of lsp-mode has a better handle on spacemacs than I do.

@colin4124
Copy link
Author

@dsyzling Thanks so much, I got it. ^_^

@cactail
Copy link

cactail commented Aug 27, 2019

Hi everyone! Question for spacemacs users: Do I need to add the scala layer to start using metals? Or maybe I need to disable ensime someway?
If you can share your configuration for scala using lsp it would be awesome! Thanks in advance.

@colin4124
Copy link
Author

@cactail This PR syl20bnr/spacemacs#12234 is merge into develop branch, so you can read this README

https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Blang/scala

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

No branches or pull requests

7 participants