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

Created on 14 Aug 2019  路  24Comments  路  Source: emacs-lsp/lsp-mode

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

Most helpful comment

@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.

All 24 comments

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

The metals version I used: https://github.com/scalameta/metals/commit/98d43026a1f20ec839cb2117396d52148a0f27bf

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

That's weird. We do support this method: https://github.com/emacs-lsp/lsp-mode/blob/e4efbab6704e6b1241cccfa0992dbcc4ba08cdcb/lsp-metals.el#L160 and it was added about moth ago: https://github.com/emacs-lsp/lsp-mode/pull/936

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

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.

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.

I got it. Thanks very much ^_^

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.

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?

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 :-)

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.

@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.

@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.

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

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

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

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

@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.

@dsyzling This config use lsp-scala:

https://github.com/zheli/scala-lsp/blob/master/packages.el#L15
and
https://github.com/zheli/scala-lsp/blob/0407679097b3f020f7322cfa0d72a9f340aeb3f6/packages.el#L109-L111

Just delete lsp-scala only, how to remove in this code ?

@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.

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.

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

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.

Was this page helpful?
0 / 5 - 0 ratings