Code Monkey home page Code Monkey logo

lsp-metals's Introduction

title description root_file
LSP Mode - Language Server Protocol support for Emacs
Language Server Protocol support with multiples languages support for Emacs
README.md

CI

Language Server Protocol Support for Emacs

LSP mode


homepageinstallationlanguagessettingstutorialstroubleshootingscreenshotsFAQ


Why?

  • ❤️ Community Driven
  • 💎 Fully featured - supports all features in Language Server Protocol v3.14.
  • 🚀 Fast - see performance section.
  • 🌟 Flexible - choose between full-blown IDE with flashy UI or minimal distraction free.
  • ⚙️ Easy to configure - works out of the box and automatically upgrades if additional packages are present.

Overview

Client for Language Server Protocol (v3.14). lsp-mode aims to provide IDE-like experience by providing optional integration with the most popular Emacs packages like company, flycheck and projectile.

  • Non-blocking asynchronous calls
  • Real-time Diagnostics/linting via flycheck (recommended) or flymake when Emacs > 26 (requires flymake>=1.0.5)
  • Code completion - company-capf / completion-at-point (note that company-lsp is no longer supported).
  • Hovers - using lsp-ui
  • Code actions - via lsp-execute-code-action, modeline (recommended) or lsp-ui sideline.
  • Code outline - using builtin imenu or helm-imenu
  • Code navigation - using builtin xref, lsp-treemacs tree views or lsp-ui peek functions.
  • Code lens
  • Symbol highlights
  • Formatting
  • Project errors on modeline
  • Debugger - dap-mode
  • Breadcrumb on headerline
  • Helm integration - helm-lsp
  • Ivy integration - lsp-ivy
  • Consult integration - consult-lsp
  • Treemacs integration - lsp-treemacs
  • Semantic tokens as defined by LSP 3.16 (compatible language servers include recent development builds of clangd and rust-analyzer)
  • which-key integration for better discovery
  • iedit
  • dired
  • ido

Presentations/demos

See also

  • lsp-docker - provide docker image with preconfigured language servers with corresponding emacs configuration.
  • company-box - company frontend with icons.
  • dap-mode - Debugger integration for lsp-mode.
  • eglot - An alternative minimal LSP implementation.
  • which-key - Emacs package that displays available keybindings in popup
  • projectile - Project Interaction Library for Emacs
  • emacs-tree-sitter - Faster, fine-grained code highlighting via tree-sitter.
  • gccemacs - modified Emacs capable of compiling and running Emacs Lisp as native code.

Contributions

Contributions are very much welcome!

NOTE Documentation for clients is generated from doc comments in the clients themselves (see lsp-doc.el) and some metadata (see lsp-clients.json) so please submit corrections accordingly.

Support the project

The emacs-lsp organization has more than 20,000 lines of code, to keep all of this working, we need to implement new features and help the community on a lot of issues.

You can help us keep going and improving it by supporting the project

Members

Here it is a list of the current lsp-mode members and what they are primary working on/responsible for.

kurnevsky
kurnevsky

Scala | Rust
seagle0128
seagle0128

Go | Python MS
sebastiansturm
sebastiansturm

lsp-mode core | C++
vibhavp
vibhavp

lsp-mode core
yyoncho
yyoncho

lsp-mode core | Java
ericdallo
ericdallo

Dart/Flutter | Clojure
danielmartin
danielmartin

C++ | Swift
kiennq
kiennq

completions | pwsh
nbfalcon
nbfalcon

lsp-mode core | iedit
psibi
psibi

Terraform | Nix
razzmatazz
razzmatazz

C# | F#
jcs090218
jcs090218

lsp-mode core

lsp-metals's People

Contributors

bbenchen avatar contagnas avatar coreyoconnor avatar dangerousben avatar dsyzling avatar ericdallo avatar gagbo avatar jakdar avatar jakeng-grabtaxi avatar jcazevedo avatar jcs090218 avatar kurnevsky avatar laurencewarne avatar pismute avatar rreckel avatar syohex avatar tgodzik avatar yyoncho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp-metals's Issues

Run/Debug leads to Wrong type argument: stringp, nil

Describe the bug
When using lens actions (run or debug) leads to error Wrong type argument: stringp, nil and run/debug doesn't start.

To Reproduce

  1. Update all packages to the latest version.
  2. Install latest release of metals-emacs.
  3. Open any project with the following scala code.
  4. Enable lsp-lens-mode.
  5. Click on 'run'.
object LensTest extends App {
  println("hello world")
}
(use-package scala-mode
  :hook
  (scala-mode . subword-mode)
  (scala-mode . lsp))

(use-package lsp-metals
  :after scala-mode)

(use-package lsp-ui
  :defer t
  :commands lsp-ui-mode)

(use-package lsp-mode
  :defines (lsp-session-file)
  :init
  (setq lsp-auto-guess-root t))

Expected behavior
The application should run 😸

Screenshots
Screen Recording 2020-06-24 at 17 44 10

Logs
Stack trace is not useful for me. Not sure how to better debug the problem.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  intern(nil)
  #f(compiled-function () (interactive nil) #<bytecode -0x2ef46e78e656b28>)()
  funcall-interactively(#f(compiled-function () (interactive nil) #<bytecode -0x2ef46e78e656b28>))
  call-interactively(#f(compiled-function () (interactive nil) #<bytecode -0x2ef46e78e656b28>) nil nil)
  command-execute(#f(compiled-function () (interactive nil) #<bytecode -0x2ef46e78e656b28>))

Autosave leads to workspace/willRenameFiles being triggered

Describe the bug
After enabling moving the autosave files to a separate directory:
(setq backup-directory-alist `(("." . "~/.emacs-backups")))

When editing a file that is autosaved the workspace/willRenameFiles is being triggered
with the original file as the oldUri and the backup location as the newUri.
With recent changes to lsp renaming this also messes up the imports for all files where the modified file is used and removes the package 😱.

A clear and concise description of what the bug is.

To Reproduce
Enable backup, (setq backup-directory-alist (("." . "~/.emacs-backups")))`
Enable lsp bsp trace. (create the
Create a file in with package in the package directory.
Modify the file. Save. Verify that the willRenameFiles message is sent.

Expected behavior
No willRenameFiles should be sent for backup.

Screenshots
grafik

Logs

Related to scalameta/metals#4888
lsp-metals version: 20221102.1628
lsp-mode version: 20230122.1747

Poor contrast in treeview in light mode

Describe the bug
With frame-background-mode set to light and a light theme (e.g. tango), metals uses white icons on white background in lsp-metals-treeview, even with lsp-metals-treeview-theme set to Metals-dark.

Screenshots

Screenshot from 2023-06-11 12-51-57

Screenshot from 2023-06-11 12-53-00

Treeview wrong type argument symbolp

default emacs config / default doom config the same story.

Emacs 27.1(9.0) OSX

calling M-x lsp-metals-treeview
error:

execute-command: Wrong type argument: symbolp, #s(hash-table size 4 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("viewId" "metalsPackages" "nodeUri" "projects:" "label" "Projects (15)" "collapseState" "collapsed"))

dap-debub templates fails with error Expected BEGIN_ARRAY but w as BEGIN_OBJECT at path $.environmentVariables

On a scala project, if you have modules in the SBT, when you do a dap-debug it fail with the following error in emacs:

lsp-workspace-command-execute: ‘workspace/executeCommand’ with ‘debug-adapter-start’ failed.

(error "The connected server(s) does not support method workspace/executeCommand.

If I look into .metals/metals.log I find this error

dic. 06, 2021 1:22:28 P. M. org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
GRAVE: Internal error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but w
as BEGIN_OBJECT at path $.environmentVariables
java.util.concurrent.CompletionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expecte
d BEGIN_ARRAY but was BEGIN_OBJECT at path $.environmentVariables
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
        at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:704)
        at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
        at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:29)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:26)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
        at scala.concurrent.BatchingExecutor$Batch.processBatch$1(BatchingExecutor.scala:67)
        at scala.concurrent.BatchingExecutor$Batch.$anonfun$run$1(BatchingExecutor.scala:82)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
        at scala.concurrent.BatchingExecutor$Batch.run(BatchingExecutor.scala:59)
        at scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:875)
        at scala.concurrent.BatchingExecutor.execute(BatchingExecutor.scala:110)
        at scala.concurrent.BatchingExecutor.execute$(BatchingExecutor.scala:107)
        at scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:873)
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:72)
        at scala.concurrent.impl.Promise$KeptPromise$Kept.onComplete(Promise.scala:372)
        at scala.concurrent.impl.Promise$KeptPromise$Kept.onComplete$(Promise.scala:371)
        at scala.concurrent.impl.Promise$KeptPromise$Failed.onComplete(Promise.scala:387)
        at scala.concurrent.Promise.tryCompleteWith(Promise.scala:75)
        at scala.concurrent.Promise.tryCompleteWith$(Promise.scala:73)
        at scala.concurrent.impl.Promise$DefaultPromise.tryCompleteWith(Promise.scala:187)
        at scala.concurrent.Promise.completeWith(Promise.scala:67)
        at scala.concurrent.Promise.completeWith$(Promise.scala:67)
        at scala.concurrent.impl.Promise$DefaultPromise.completeWith(Promise.scala:187)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:44)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJ
ECT at path $.environmentVariables
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:22
6)
        at com.google.gson.Gson.fromJson(Gson.java:963)
        at com.google.gson.Gson.fromJson(Gson.java:1034)
        at com.google.gson.Gson.fromJson(Gson.java:1006)
        at scala.meta.internal.metals.JsonParser$XtensionSerializedAsJson.$anonfun$as$1(JsonParser.scala:33)
        at scala.util.Try$.apply(Try.scala:213)
        at scala.meta.internal.metals.JsonParser$XtensionSerializedAsJson.as(JsonParser.scala:33)
        at scala.meta.internal.metals.debug.DebugProvider.parseSessionName(DebugProvider.scala:504)
        at scala.meta.internal.metals.debug.DebugProvider.start(DebugProvider.scala:88)
        at scala.meta.internal.metals.MetalsLanguageServer.$anonfun$executeCommand$14(MetalsLanguageServer.scala:1742)
        at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
        ... 4 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $.environmentVariables
        at com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:163)
        at com.google.gson.internal.bind.JsonTreeReader.beginArray(JsonTreeReader.java:72)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80
)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61
)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:22
2)
        ... 15 more

I have tried both launch.json templates and elisp templates. I have tried templates with and without the environment variables section.

Company completion not working

Describe the bug
I am using Doom Emacs, and company completion does not work for me when editing Scala code.
Other functionalities like goto definition, type inference, etc. seem to work fine.

To Reproduce
This happens with multiple projects. I have attached a toy project too.
awesome-zio-bak.zip

Expected behavior
The company completion should work in Scala projects.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.

Upon the installation, issues with connecting to server/debug messages on opening .scala files first time pers session

My current emacs version is 27.2, OS is Ubuntu 20.04,Java version is 11.0.11.

I was following the official guide of installing metals on emacs, did a little change from the course at the start (I first installed required packages/dependencies through M-x package-list-packages and only then did what was going on on the guide, but from my understanding, it shouldn't matter. My current init.el file contains the code related to lsp-mode:

;; Install use-package if not already installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)

;; Enable defer and ensure by default for use-package
;; Keep auto-save/backup files separate from source code:  https://github.com/scalameta/metals/issues/1027
(setq use-package-always-defer t
      use-package-always-ensure t
      backup-directory-alist `((".*" . ,temporary-file-directory))
      auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))

;; Enable scala-mode for highlighting, indentation and motion commands
(use-package scala-mode
  :interpreter
    ("scala" . scala-mode))

;; Enable sbt mode for executing sbt commands
(use-package sbt-mode
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map)
   ;; sbt-supershell kills sbt-mode:  https://github.com/hvesalai/emacs-sbt-mode/issues/152
   (setq sbt:program-options '("-Dsbt.supershell=false"))
)

;; Enable nice rendering of diagnostics like compile errors.
(use-package flycheck
  :init (global-flycheck-mode))

(use-package lsp-mode
  ;; Optional - enable lsp-mode automatically in scala files
  :hook  (scala-mode . lsp)
         (lsp-mode . lsp-lens-mode)
  :config
  ;; Uncomment following section if you would like to tune lsp-mode performance according to
  ;; https://emacs-lsp.github.io/lsp-mode/page/performance/
  ;;       (setq gc-cons-threshold 100000000) ;; 100mb
  ;;       (setq read-process-output-max (* 1024 1024)) ;; 1mb
  ;;       (setq lsp-idle-delay 0.500)
  ;;       (setq lsp-log-io nil)
  ;;       (setq lsp-completion-provider :capf)
  (setq lsp-prefer-flymake nil))

;; Add metals backend for lsp-mode
(use-package lsp-metals)

;; Enable nice rendering of documentation on hover
;;   Warning: on some systems this package can reduce your emacs responsiveness significally.
;;   (See: https://emacs-lsp.github.io/lsp-mode/page/performance/)
;;   In that case you have to not only disable this but also remove from the packages since
;;   lsp-mode can activate it automatically.
(use-package lsp-ui)

;; lsp-mode supports snippets, but in order for them to work you need to use yasnippet
;; If you don't want to use snippets set lsp-enable-snippet to nil in your lsp-mode settings
;;   to avoid odd behavior with snippets and indentation
(use-package yasnippet)

;; Use company-capf as a completion provider.
;;
;; To Company-lsp users:
;;   Company-lsp is no longer maintained and has been removed from MELPA.
;;   Please migrate to company-capf.
(use-package company
  :hook (scala-mode . company-mode)
  :config
  (setq lsp-completion-provider :capf))

;; Use the Debug Adapter Protocol for running tests and debugging
(use-package posframe
  ;; Posframe is a pop-up tool that must be manually installed for dap-mode
  )
(use-package dap-mode
  :hook
  (lsp-mode . dap-mode)
  (lsp-mode . dap-ui-mode)
  )

without the first part of adding melpa, since I got it added already. After doing everything and restarting the Emacs, I proceeded with opening .scala file and on open I get a debug message:

Debugger entered--Lisp error: (void-function -compose)                                                                                                                                                     
  -compose(lsp--client-path->uri-fn lsp--workspace-client)                                                                                                                                                 
  lsp--path-to-uri("pathtoemacs/.emacs.d/index.sqlite")                                                                                                                                            
  #f(compiled-function () #<bytecode 0x15566aea7e91>)()                                                                                                                                                    
  funcall(#f(compiled-function () #<bytecode 0x15566aea7e91>))                                                                                                                                             
  eval((funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)))                                                                                                                                    
  custom-initialize-reset(lsp-serenata-index-database-uri (funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)))                                                                                 
  custom-declare-variable(lsp-serenata-index-database-uri (funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)) "The location to store the index database.\nNote tha..." :group lsp-serenata :ty$
  byte-code("\301\302\303\304 \305\306\307!\310\311\312\313&\10!\210\314\315\316\317\320\321\322\323\324\325&\11\210\326\327\330\331\332DD\333\334\335\320\315\324\336&\11\210\326\337\330..." [lsp-intele$
  require(lsp-php nil t)                                                                                                                                                                                   
  #f(compiled-function (package) #<bytecode 0x15566ad2cc81>)(lsp-php)                                                                                                                                      
  mapc(#f(compiled-function (package) #<bytecode 0x15566ad2cc81>) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-d $
  seq-do(#f(compiled-function (package) #<bytecode 0x15566ad2cc81>) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-$
  lsp--require-packages()                                                                                                                                                                                  
  lsp()                                                                                                                                                                                                    
  run-hooks(change-major-mode-after-body-hook prog-mode-hook scala-mode-hook)                                                                                                                              
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook scala-mode-hook))                                                                                                                      
  run-mode-hooks(scala-mode-hook)                                                                                                                                                                          
  scala-mode()                                                                                                                                                                                             
  set-auto-mode-0(scala-mode nil)                                                                                                                                                                          
  set-auto-mode()                                                                                                                                                                                          
  normal-mode(t)                                                                                                                                                                                           
  after-find-file(nil t)                                                                                                                                                                                   
  find-file-noselect-1(#<buffer test.scala> "~/Scala/test.scala" nil nil "~/Python_rofli/Scala/test.scala" (5288230 2065))                                                                    
  find-file-noselect("~/Scala/test.scala" nil nil)                                                                                                                          
  ido-file-internal(raise-frame)                                                                                                                                                                           
  ido-find-file()                                                                                                                                                                                          
  funcall-interactively(ido-find-file)                                                                                                                                                                     
  call-interactively(ido-find-file nil nil)                                                                                                                                                                
  command-execute(ido-find-file)   

I can try to open the .scala file again and it will be opened, but upon trying to activate lsp-mode, it will tell [Disabled] and a bunch of other errors about not having a connection to the server. And according to the debug message, I am supposed to have some kind of index.sqlite inside my .emacs.d folder, but I don't have one, and creating one didn't help. I also followed the alternative LSP server listed there, the "Eglot", and it worked fine, but upon switching back to lsp-mode variant, it was still giving the same error. Any idea how to start debugging this mess? I tried to manually install metals, tried shenanigans with a "coursier", nothing helped.

QuickPick Provider feature

Specs for LSP for initialization message:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize

When sending ClientCapabilities client can add experimental section that is custom for different client/server settings.

Metals supports parameter quickPickProvider that is boolean and can be set to true/false.

If this setting is set to true metals will assume this request can be handled by client:

  /**
   * Opens an menu to ask the user to pick one of the suggested options.
   *
   * @return the user provided pick.
   */
  @JsonRequest("metals/quickPick")
  def metalsQuickPick(
      params: MetalsQuickPickParams
  ): MetalsQuickPickResult

Method parameter(serialized to json):

case class MetalsQuickPickParams(
    items: java.util.List[MetalsQuickPickItem],
    @Nullable placeHolder: String = null
)
case class MetalsQuickPickItem(
    id: String,
    // A human readable string which is rendered prominent.
    label: String
)

And expected response:

case class MetalsQuickPickResult(
    // value=null when cancelled=true
    @Nullable itemId: String = null,
    @Nullable cancelled: java.lang.Boolean = null
)

I will try to add later a link to scala repository with description how it could be checked it works.

lsp-metals-doctor-run is not working

Describe the bug
lsp-metals-doctor-run command is not working.

To Reproduce
Run lsp-metals-doctor-run in a scala project. It shows a warning instead of a doctor table.

Logs

Warning (lsp-mode): Unknown notification: metals/executeClientCommand

Hovering over output in worksheet not working

Describe the bug
According to this page I should be able to hover over the comment-output generated in a worksheet to see the complete output. This works in other editors, such as IntelliJ and Code. In emacs, however, nothing happens.

To Reproduce

create a worksheet named foo.worksheet.sc anywhere.
add a line:
val longString = "thisisalongstring" * 10
save the file.

Expected behavior
hovering over the comment should reveal the complete string. but nothing shows up.

Screenshots
Here's the test output. No new output appears in the *lsp-log* buffer during hover.
Screen Shot 2022-05-09 at 10 12 02 AM

Debug via attach is supported in metals but not working in lsp-metals.

Describe the bug
Scala in emacs can be debugged via -java-debug option.

Using codelens we can debug a Runnable scala file.

I have a sbt project, where I run sbt -java-debug 1234. From Intellij I can connect to this remote debugger easily. I am unable to attach to this debugger via emacs.

To Reproduce
run
sbt new playframework/play-scala-seed.g8

start remote debugger
sbt -java-debug 1234 (might have to change the port`.

Next step (which is missing). - attach the remote debugger to emacs.

Expected behavior
I would like to use remote debugger via emacs. This entire process is supported by metals. I have successfully attached this in intellij.

the following functions are not known to be defined: -compose, -rpartial, -andfn, -not

Describe the bug

Warning (bytecomp): the following functions are not known to be defined: -compose,
    -rpartial, -andfn, -not

To Reproduce
lsp-metals with use-package like this

(use-package lsp-metals
  :ensure t
  :custom
  ;; Metals claims to support range formatting by default but it supports range
  ;; formatting of multiline strings only. You might want to disable it so that
  ;; emacs can use indentation provided by scala-mode.
  (lsp-metals-server-args '("-J-Dmetals.allow-multiline-string-formatting=off"))
  :hook (scala-mode . lsp))

Expected behavior
lsp-metals to install and run without errors. Also when I try to
M-x lsp-install-server the same error about -compose appears.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.

Question : lsp hint faces ?

Hello,

Sorry for the dumb question (I don't think there's a gitter specifically for lsp-metals, but I've been wrong before), but I'm using the lsp-metals-show-inferred-type variables, and I thought that the hints would use the lsp-details-face but instead I think I have a face that resembles comment.

Do you know which face is actually used for those inline hints ? How should I find out about these in general ?

Thanks for the package,

Gerry

(wrong-number-of-arguments (1 . 1) 2)

Here is backstrace:

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 2)
lsp-metals--model-refresh(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 18/18 0x1ff84c028bcd> :registered-server-capabilities (#s(lsp--registered-capability :id "1" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1ff84c02a88d>)) :root "/Users/aaron/work/bike-guard" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff84badd11d>) :test? #f(compiled-function () #<bytecode 0x1ff84badd135>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 5/65 0x1ff84badd141> :request-handlers #<hash-table equal 0/65 0x1ff84badd3d1> :response-handlers #<hash-table eql 0/65 0x1ff84badda35> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff84baddd2d> :action-handlers #<hash-table equal 2/65 0x1ff84badd371> :major-modes (scala-mode) :activation-fn nil :priority -1 :server-id metals :multi-root nil :initialization-options ((decorationProvider . t) (didFocusProvider . t) (executeClientCommandProvider . t) (doctorProvider . "html") (statusBarProvider . "on") (debuggingProvider . t) (treeViewProvider . t)) :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x1ff84badd069>) :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode 0x1ff84badd081>) :async-request-handlers #<hash-table equal 0/65 0x1ff84baddf5d> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 1/65 0x1ff84bf62855> :watches #<hash-table equal 0/65 0x1ff84bf62b2d> :workspace-folders nil :last-id 0 :status-string #("Compiling root " 0 17 (help-echo nil local-map nil)) :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff84bf62b4d> :work-done-tokens #<hash-table equal 0/65 0x1ff84bf62f41>) nil)
apply(lsp-metals--model-refresh (#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 18/18 0x1ff84c028bcd> :registered-server-capabilities (#s(lsp--registered-capability :id "1" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1ff84c02a88d>)) :root "/Users/aaron/work/bike-guard" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff84badd11d>) :test? #f(compiled-function () #<bytecode 0x1ff84badd135>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 5/65 0x1ff84badd141> :request-handlers #<hash-table equal 0/65 0x1ff84badd3d1> :response-handlers #<hash-table eql 0/65 0x1ff84badda35> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff84baddd2d> :action-handlers #<hash-table equal 2/65 0x1ff84badd371> :major-modes (scala-mode) :activation-fn nil :priority -1 :server-id metals :multi-root nil :initialization-options ((decorationProvider . t) (didFocusProvider . t) (executeClientCommandProvider . t) (doctorProvider . "html") (statusBarProvider . "on") (debuggingProvider . t) (treeViewProvider . t)) :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x1ff84badd069>) :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode 0x1ff84badd081>) :async-request-handlers #<hash-table equal 0/65 0x1ff84baddf5d> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 1/65 0x1ff84bf62855> :watches #<hash-table equal 0/65 0x1ff84bf62b2d> :workspace-folders nil :last-id 0 :status-string #("Compiling root " 0 17 (help-echo nil local-map nil)) :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff84bf62b4d> :work-done-tokens #<hash-table equal 0/65 0x1ff84bf62f41>) nil))
lsp-metals--execute-client-command(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 18/18 0x1ff84c028bcd> :registered-server-capabilities (#s(lsp--registered-capability :id "1" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1ff84c02a88d>)) :root "/Users/aaron/work/bike-guard" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff84badd11d>) :test? #f(compiled-function () #<bytecode 0x1ff84badd135>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 5/65 0x1ff84badd141> :request-handlers #<hash-table equal 0/65 0x1ff84badd3d1> :response-handlers #<hash-table eql 0/65 0x1ff84badda35> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff84baddd2d> :action-handlers #<hash-table equal 2/65 0x1ff84badd371> :major-modes (scala-mode) :activation-fn nil :priority -1 :server-id metals :multi-root nil :initialization-options ((decorationProvider . t) (didFocusProvider . t) (executeClientCommandProvider . t) (doctorProvider . "html") (statusBarProvider . "on") (debuggingProvider . t) (treeViewProvider . t)) :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x1ff84badd069>) :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode 0x1ff84badd081>) :async-request-handlers #<hash-table equal 0/65 0x1ff84baddf5d> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 1/65 0x1ff84bf62855> :watches #<hash-table equal 0/65 0x1ff84bf62b2d> :workspace-folders nil :last-id 0 :status-string #("Compiling root " 0 17 (help-echo nil local-map nil)) :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff84bf62b4d> :work-done-tokens #<hash-table equal 0/65 0x1ff84bf62f41>) #<hash-table equal 2/2 0x1ff84bfcd6ed>)
lsp--on-notification(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 18/18 0x1ff84c028bcd> :registered-server-capabilities (#s(lsp--registered-capability :id "1" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1ff84c02a88d>)) :root "/Users/aaron/work/bike-guard" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff84badd11d>) :test? #f(compiled-function () #<bytecode 0x1ff84badd135>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 5/65 0x1ff84badd141> :request-handlers #<hash-table equal 0/65 0x1ff84badd3d1> :response-handlers #<hash-table eql 0/65 0x1ff84badda35> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff84baddd2d> :action-handlers #<hash-table equal 2/65 0x1ff84badd371> :major-modes (scala-mode) :activation-fn nil :priority -1 :server-id metals :multi-root nil :initialization-options ((decorationProvider . t) (didFocusProvider . t) (executeClientCommandProvider . t) (doctorProvider . "html") (statusBarProvider . "on") (debuggingProvider . t) (treeViewProvider . t)) :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x1ff84badd069>) :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode 0x1ff84badd081>) :async-request-handlers #<hash-table equal 0/65 0x1ff84baddf5d> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 1/65 0x1ff84bf62855> :watches #<hash-table equal 0/65 0x1ff84bf62b2d> :workspace-folders nil :last-id 0 :status-string #("Compiling root " 0 17 (help-echo nil local-map nil)) :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff84bf62b4d> :work-done-tokens #<hash-table equal 0/65 0x1ff84bf62f41>) #<hash-table equal 3/3 0x1ff84bfcd695>)
lsp--parser-on-message(#<hash-table equal 3/3 0x1ff84bfcd695> #s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 18/18 0x1ff84c028bcd> :registered-server-capabilities (#s(lsp--registered-capability :id "1" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1ff84c02a88d>)) :root "/Users/aaron/work/bike-guard" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff84badd11d>) :test? #f(compiled-function () #<bytecode 0x1ff84badd135>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 5/65 0x1ff84badd141> :request-handlers #<hash-table equal 0/65 0x1ff84badd3d1> :response-handlers #<hash-table eql 0/65 0x1ff84badda35> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff84baddd2d> :action-handlers #<hash-table equal 2/65 0x1ff84badd371> :major-modes (scala-mode) :activation-fn nil :priority -1 :server-id metals :multi-root nil :initialization-options ((decorationProvider . t) (didFocusProvider . t) (executeClientCommandProvider . t) (doctorProvider . "html") (statusBarProvider . "on") (debuggingProvider . t) (treeViewProvider . t)) :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x1ff84badd069>) :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode 0x1ff84badd081>) :async-request-handlers #<hash-table equal 0/65 0x1ff84baddf5d> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 1/65 0x1ff84bf62855> :watches #<hash-table equal 0/65 0x1ff84bf62b2d> :workspace-folders nil :last-id 0 :status-string #("Compiling root " 0 17 (help-echo nil local-map nil)) :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff84bf62b4d> :work-done-tokens #<hash-table equal 0/65 0x1ff84bf62f41>))
#f(compiled-function (proc input) #<bytecode 0x1ff84bf63371>)(# "Content-Length: 120\15\n\15\n{"jsonrpc":"2.0","method":"...")

Starting a debug session with the ui

When I try start a debug session using the ui menu instead of the lens I get the following error:
Error running timer: (wrong-type-argument stringp nil)

I suspect that the problem is related with my template:

(dap-register-debug-template
  "Analyzer"
  (list :type "scala"
        :request "debug"
        :name "Analyzer"
        :projectName "Analyzer"
        :mainClass "analyzer.Main"
        :args "blah bl;ah"
        :vmArgs ""))

Is there anything wrong with the template? Where can I find a template that works? I can't find any.

Scala version on independent worksheet files

What is the preferred way of changing scala version for independent .worksheet.sc files? I updated everything lsp related and now I seem to be stuck on scala version 3 while I need scala 2.13. Ammonite does not seem to have a way to define this inside a file and my ammonite is on the correct scala version. I wasn't quite sure what is the system responsible of the version so sorry if this is the wrong place to ask.

lsp-metals always guesses the wrong project root.

Describe the bug

l open the file ~/code/functional_scala/recfun/build.sbt (downloaded from http://alaska.epfl.ch/~dockermoocs/handouts-coursera-2.13/recfun.zip). The project root is (obviously?) ~/code/functional_scala/recfun/. Still, lsp-metals guesses the root is ~/code/functional_scala.

LSP :: Guessed project root is ~/code/functional_scala

To Reproduce

See above.

wget http://alaska.epfl.ch/~dockermoocs/handouts-coursera-2.13/recfun.zip
unzip recfun.zip

Now open the file build.sbt in the recfun folder in emacs.

Expected behavior

LSP :: Guessed project root is ~/code/functional_scala/recfun/

Screenshots
If applicable, add screenshots to help explain your problem.

Logs

;; M-x lsp-metals-doctor-run
Metals Doctor

These are the installed build targets for this workspace. One build target corresponds to one classpath. For example, normally one sbt project maps to two build targets: main
and test.

⚠️ No build targets were detected in this workspace so most functionality won't work.

* Make sure the workspace directory '/Users/endrebakkenstovner/code/functional_scala' matches the root of your build.
* Try removing the directories .metals/ and .bloop/, then restart metals And import the build again.

I have tried to remove the .metals directory. .bloop was never created.

add command to reset settings choices

Right now everytime you change build.sbt you get prompted to import build or not import anymore.
If you decide not to import anymore you cannot go back from your decision and you have to wipe .metals directory.

With (scalameta/metals#1897) you can execute command metals.reset-choice that would allow you to reset decision to never import a build on change.

It should potentially be a matter of adding?

(defun lsp-metals-reset-choice)
  "Walk all files in the workspace and index where symbols are defined."
  (interactive)
  (lsp-send-execute-command "reset-choice" ()))

For details if you execute this command without any parameters it will prompt you what setting do you want to reset.
But you can also explicitly say what you want to reset. Then you can call it with e.g. "build import".
Having it work in interactive mode would be already awesome 👍

EDIT:
PR is merged

In OpenBSD installing `lsp::metals` results in Linux binary being installed [solution]

Context: I run OpenBSD.

When I install lsp::metals in DoomEmacs, it doesn't work. The installation log (comint) for lsp::metals shows a message saying more or less "coursier : invalid format"

Indeed, when I go to .emacs.d/.local/etc/lsp/metals/ the installed coursier file is a Linux ELF binary.

SOLUTION: When you go to coursier's installation instructions page there is an entry "Any (needs JVM)" which work perfectly under OpenBSD. Installing this version (for everyone or for *BSDs only) would solve the problem

Steps to reproduce

  • Run OpenBSD
  • Start DoomEmacs
  • M-x lsp-install-server
  • Select metals
  • check binary type of the installed coursier file:
    $ file "~/.emacs.d/.local/etc/lsp/metals/coursier"
    ~/.emacs.d/.local/etc/lsp/metals/coursier: ELF 64-bit LSB pie executable, x86-64 ...

Scala 2.13.3 does not work with lsp-metals

Describe the bug
Scala 2.13.3 does not work with lsp-metals. Project with scalaVersion := "2.13.3" in build.sbt file fails the import step.

To Reproduce

  1. Install Courier & run cs setup. You should have scala 2.13.3 installed
  2. run sbt new scala/hello-world.g8 to create the hello world sample project
  3. In Emacs, open the hello-world-template directory you created above
  4. When asked to import the project, select import build
  5. After a few seconds, Metals Doctor would spit out errors recommending you to upgrade (downgrade) to 2.12.9 to make code navigation work. The exact error is Upgrade to Scala 2.12.9 and run 'Build import' to enable code navigation.

Expected behavior
Expect code navigation to work for project with scala version 2.13.3

Screenshots
MetalsError

Logs
lsp-log buffer in emacs

Command "metals-emacs" is present on the path.
Command "metals-emacs" is present on the path.
Found the following clients for /Users/chris/git/scala/hello-world-template/src/main/scala/Main.scala: (server-id metals, priority -1)
The following clients were selected based on priority: (server-id metals, priority -1)
logging to file /Users/chris/git/scala/hello-world-template/.metals/metals.log
time: initialize in 1.13s
Creating watch for /Users/chris/git/scala/hello-world-template
Creating watch for /Users/chris/git/scala/hello-world-template/project
Creating watch for /Users/chris/git/scala/hello-world-template/src
Creating watch for /Users/chris/git/scala/hello-world-template/src/main
Creating watch for /Users/chris/git/scala/hello-world-template/src/main/scala
Creating watch for /Users/chris/git/scala/hello-world-template/src/test
running installed 'bloop bsp --protocol local --socket /var/folders/zj/qfh19vp902g5h7yc54x5v4zh0000gn/T/bsp4914067188148031495/19etob21zi0ri.socket'
skipping build import with status 'Installed'
tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/chris/Library/Caches/org.scalameta.metals/bsp.trace.json
no build target: /Users/chris/git/scala/hello-world-template/src/main/scala/Main.scala
time: connected to build server in 0.48s
Creating watch for /Users/chris/git/scala/hello-world-template/src/main/scala-2.13
Creating watch for /Users/chris/git/scala/hello-world-template/src/main/java
Creating watch for /Users/chris/git/scala/hello-world-template/src/test/scala-2.13
Creating watch for /Users/chris/git/scala/hello-world-template/src/test/scala
Creating watch for /Users/chris/git/scala/hello-world-template/src/test/java
time: indexed workspace in 1.71s
unsupported Scala 2.13.3
unsupported Scala 2.13.3

TRAMP support

Describe the bug
lsp-metals doesn't work with projects over TRAMP

To Reproduce
open a .scala file over TRAMP and eval this lisp code

(lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-metals--server-command)
		    :major-modes '(scala-mode)
		    :priority -1
		    :initialization-options '((decorationProvider . t)
					      (didFocusProvider . t)
					      (executeClientCommandProvider . t)
					      (doctorProvider . "html")
					      (statusBarProvider . "on")
					      (debuggingProvider . t)
					      (treeViewProvider . t))
		    :notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command)
					       ("metals/publishDecorations" #'lsp-metals--publish-decorations)
					       ("metals/treeViewDidChange" #'lsp-metals-treeview--did-change)
					       ("metals-model-refresh" #'lsp-metals--model-refresh)
					       ("metals/status" #'lsp-metals--status-string))
		    :action-handlers (ht ("metals-debug-session-start" (-partial #'lsp-metals--debug-start :json-false))
					 ("metals-run-session-start" (-partial #'lsp-metals--debug-start t)))
		    :server-id 'metals
		    :remote? ;; This is what i added
		    :initialized-fn (lambda (workspace)
				      (lsp-metals--add-focus-hooks)
				      (with-lsp-workspace workspace
					(lsp--set-configuration
					 (lsp-configuration-section "metals"))))
		    :after-open-fn (lambda ()
				     (add-hook 'lsp-on-idle-hook #'lsp-metals--did-focus nil t))
		    :completion-in-comments? t))

Expected behavior
lsp-metals should work as if it was running on a local buffer.

Logs

Tramp: Opening connection for [email protected] using ssh...
Tramp: Sending command ‘exec ssh -l main  -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none example.org’
Tramp: Waiting for prompts from remote shell...
Tramp: Sending password
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on 'example.rog’
Tramp: Opening connection for [email protected] using ssh...done
Tramp: Inserting ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’...
Tramp: Encoding remote file ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’ with ‘(env GZIP= gzip <%s | base64)’...done
Tramp: Decoding local file ‘/tmp/tramp.ANFeAZ.scala’ with ‘(lambda (beg end) (base64-decode-region beg end) (let ((coding-system-for-write 'binary) (coding-system-for-read 'binary)) (apply #'tramp-call-process-region '(tramp-file-name ssh main nil example.org nil /home/main/.../AppEntry.scala nil) (point-min) (point-max) (car (split-string env GZIP= gzip -d)) t t nil (cdr (split-string env GZIP= gzip -d)))))’...done
Tramp: Inserting ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’...done
File mode specification error: (wrong-type-argument hash-table-p nil)

Tramp: Checking ‘vc-registered’ for /ssh:[email protected]:/home/main/.../AppEntry.scala...done
File mode specification error: (wrong-type-argument hash-table-p nil)

This log was captured after a initial tramp connection was already established, but after resetting i got just more of the same

Note
I'm sure lsp-metals worked on the remote computer as i just transformed it into a headless workstation

Tab does not indent

Describe the bug
I attempted to use the configuration at https://scalameta.org/metals/docs/editors/emacs as the full contents of my .emacs. When I open a scala file, it asked my which server I wanted to import, and I said to use metals. I imported the project from the root of the project. If I have code like

     val rootActor = foo()
^

with the cursor at the ^ and type TAB, the cursor remains at the same place and does not indent.

If I then edit the file to contain

     val rootActor = foo()
^rootActor

The cursor is again at ^. Pressing TAB does not indent. I also get a message in *Messages*: yas-next-field: Wrong type argument: overlayp, nil
To Reproduce

# Clean up anything previous.  Start in project root.
rm -r .metals ~/.emacs.d/.cask/var/lsp/server/metals/
emacs build.sbt

Emacs asks how to import the project. Type . (Import project at current directory, which is the directory with build.sbt.)

Emacs asks if it should import the build in the new workspace. Type Import build RET

Open (using C-x C-f) Main.scala.

Go to the blank line at the bottom of the file, with the cursor at the start of the line. Press TAB.
Type rootActor C-a to enter text and go back to the beginning of the line.
Press TAB

Expected behavior
Pressing TAB should indent the line appropriately

Files
~/.emacs

;; Hack to work around errors about svg files
(when (= emacs-major-version 28)
         (add-to-list 'image-types 'svg))

(require 'package)

;; Add melpa to your packages repositories
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

(package-initialize)

;; Install use-package if not already installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)

;; Enable defer and ensure by default for use-package
;; Keep auto-save/backup files separate from source code:  https://github.com/scalameta/metals/issues/1027
(setq use-package-always-defer t
      use-package-always-ensure t
      backup-directory-alist `((".*" . ,temporary-file-directory))
      auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))

;; Enable scala-mode for highlighting, indentation and motion commands
(use-package scala-mode
  :interpreter ("scala" . scala-mode))

;; Enable sbt mode for executing sbt commands
(use-package sbt-mode
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map)
   ;; sbt-supershell kills sbt-mode:  https://github.com/hvesalai/emacs-sbt-mode/issues/152
   (setq sbt:program-options '("-Dsbt.supershell=false")))

;; Enable nice rendering of diagnostics like compile errors.
(use-package flycheck
  :init (global-flycheck-mode))

(use-package lsp-mode
  ;; Optional - enable lsp-mode automatically in scala files
  ;; You could also swap out lsp for lsp-deffered in order to defer loading
  :hook  (scala-mode . lsp)
         (lsp-mode . lsp-lens-mode)
  :config
  ;; Uncomment following section if you would like to tune lsp-mode performance according to
  ;; https://emacs-lsp.github.io/lsp-mode/page/performance/
  ;; (setq gc-cons-threshold 100000000) ;; 100mb
  ;; (setq read-process-output-max (* 1024 1024)) ;; 1mb
  ;; (setq lsp-idle-delay 0.500)
  ;; (setq lsp-log-io nil)
  ;; (setq lsp-completion-provider :capf)
  (setq lsp-prefer-flymake nil)
  ;; Makes LSP shutdown the metals server when all buffers in the project are closed.
  ;; https://emacs-lsp.github.io/lsp-mode/page/settings/mode/#lsp-keep-workspace-alive
  (setq lsp-keep-workspace-alive nil))

;; Add metals backend for lsp-mode
(use-package lsp-metals)

;; Enable nice rendering of documentation on hover
;;   Warning: on some systems this package can reduce your emacs responsiveness significally.
;;   (See: https://emacs-lsp.github.io/lsp-mode/page/performance/)
;;   In that case you have to not only disable this but also remove from the packages since
;;   lsp-mode can activate it automatically.
(use-package lsp-ui)

;; lsp-mode supports snippets, but in order for them to work you need to use yasnippet
;; If you don't want to use snippets set lsp-enable-snippet to nil in your lsp-mode settings
;; to avoid odd behavior with snippets and indentation
(use-package yasnippet)

;; Use company-capf as a completion provider.
;;
;; To Company-lsp users:
;;   Company-lsp is no longer maintained and has been removed from MELPA.
;;   Please migrate to company-capf.
(use-package company
  :hook (scala-mode . company-mode)
  :config
  (setq lsp-completion-provider :capf))

;; Posframe is a pop-up tool that must be manually installed for dap-mode
(use-package posframe)

;; Use the Debug Adapter Protocol for running tests and debugging
(use-package dap-mode
  :hook
  (lsp-mode . dap-mode)
  (lsp-mode . dap-ui-mode))

build.sbt

// Project Config Values
val ProjectName    = "lsp-metals-bug-example"
val ProjectVersion = "2.14.0-SNAPSHOT"
val Scala3Version  = "3.3.1"

// Other Dependency Values
val AkkaCoreVersion         = "2.6.21" // Keep at 2.6.x


ThisBuild / scalaVersion := Scala3Version
ThisBuild / organization := "com.example.lsp.metals"
Compile / run / fork     := true
Compile / unmanagedResourceDirectories += baseDirectory.value / "conf"
Test / parallelExecution := false

scalacOptions ++= Seq(
  "-unchecked",      // Warn on unchecked assumption
  "-deprecation",    // Warn on deprecated method use
  "-feature",        // Warn on features that should be imported explicitly
  "-Xfatal-warnings" // Flag warnings as fatal errors (including above)
)
scalacOptions ++= Seq("-java-output-version", "17") // Compile to Java 17


lazy val root = project
  .in(file("."))
  .settings(
    name                                 := ProjectName,
    version                              := ProjectVersion,
    // Project Dependencies
    libraryDependencies ++= Seq(
      "com.typesafe.akka"             %% "akka-actor-typed"                  % AkkaCoreVersion,
      "com.typesafe.akka"             %% "akka-actor-testkit-typed"          % AkkaCoreVersion,
    ),
    // Some libraries have incompatible transitive dependencies, especially when cross-compiling Scala 2.13 and 3
    // Exclude incompatible libaries below
    excludeDependencies ++= Seq(
      "com.typesafe.akka"            % "akka-actor_2.13",
      "org.scala-lang.modules"       % "scala-java8-compat_2.13",
      "com.fasterxml.jackson.module" % "jackson-module-scala_2.13"
    ),
  )

src/main/scala/com/example/lsp/metals/Main.scala

package com.example.lsp.metals

import akka.actor.typed.ActorSystem
import akka.japi.pf.UnitMatch

class RootActor:
  def buildBehavior: Int =
    val x = 3
    x * 2
     
object Main:

  def run(args: List[String]): Unit =
    val rootActor = new RootActor()


Screenshots

Logs
Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.

*Backtrace with debug-on-error set to t after pressing TAB at the start of the line

Debugger entered--Lisp error: (wrong-type-argument overlayp nil)
  overlay-get(nil yas--field)
  yas-next-field()
  yas-next-field-or-maybe-expand()
  funcall-interactively(yas-next-field-or-maybe-expand)
  call-interactively(yas-next-field-or-maybe-expand nil nil)
  command-execute(yas-next-field-or-maybe-expand)

*Messages*

For information about GNU Emacs and the GNU system, type C-h C-a.
LSP :: Connected to [metals:47650/starting /Users/me/test/lsp-metals].
LSP :: metals:47650 initialized successfully in folders: (/Users/me/test/lsp-metals)
LSP :: Connected to [metals:47650 /Users/me/test/lsp-metals].
<Messages about saving Main.scala>
yas-next-field: Wrong type argument: overlayp, nil [2 times]

Version: GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2023-02-22

*lsp-log*

Command "/Users/me/.emacs.d/.cache/lsp/metals/metals" is present on the path.
Command "semgrep lsp" is not present on the path.
Command "/Users/me/.emacs.d/.cache/lsp/metals/metals" is present on the path.
Command "semgrep lsp" is not present on the path.
Found the following clients for /Users/me/test/lsp-metals/build.sbt: (server-id metals, priority -1)
The following clients were selected based on priority: (server-id metals, priority -1)
2023.10.10 12:03:49 INFO  logging to files /Users/me/test/lsp-metals/.metals/metals.log
2023.10.10 12:03:49 INFO  Started: Metals version 1.0.1 in folders '/Users/me/test/lsp-metals' for client emacs GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 of 2023-02-22.
2023.10.10 12:03:50 INFO  time: initialize in 0.55s
Creating watchers for following 12 folders:
  /Users/me/test/lsp-metals
  /Users/me/test/lsp-metals/.bsp
  /Users/me/test/lsp-metals/project
  /Users/me/test/lsp-metals/project/project
  /Users/me/test/lsp-metals/project/project/project
  /Users/me/test/lsp-metals/src
  /Users/me/test/lsp-metals/src/main
  /Users/me/test/lsp-metals/src/main/scala
  /Users/me/test/lsp-metals/src/main/scala/com
  /Users/me/test/lsp-metals/src/main/scala/com/example
  /Users/me/test/lsp-metals/src/main/scala/com/example/lsp
  /Users/me/test/lsp-metals/src/main/scala/com/example/lsp/metals
2023.10.10 12:03:52 INFO  no build target found for /Users/me/test/lsp-metals/build.sbt. Using presentation compiler with project's scala-library version: 3.2.0
2023.10.10 12:03:53 INFO  Attempting to connect to the build server...
2023.10.10 12:03:53 INFO  Bloop uses /Users/me/.jenv/versions/17.0 defined at /Users/me/.bloop/bloop.json
2023.10.10 12:03:53 INFO  skipping build import with status 'Installed'
2023.10.10 12:03:53 INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/me/test/lsp-metals/.metals/bsp.trace.json or /Users/me/Library/Caches/org.scalameta.metals/bsp.trace.json
2023.10.10 12:03:53 INFO  Attempting to connect to the build server...
2023.10.10 12:03:53 INFO  Bloop uses /Users/me/.jenv/versions/17.0 defined at /Users/me/.bloop/bloop.json
2023.10.10 12:03:53 INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/me/test/lsp-metals/project/.metals/bsp.trace.json or /Users/me/Library/Caches/org.scalameta.metals/bsp.trace.json
2023.10.10 12:03:53 INFO  time: Connected to build server in 0.82s
2023.10.10 12:03:53 INFO  Connected to Build server: Bloop v1.5.8
2023.10.10 12:03:54 INFO  time: code lens generation in 3.85s
2023.10.10 12:03:55 INFO  no build target found for /Users/me/test/lsp-metals/build.sbt. Using presentation compiler with project's scala-library version: 3.2.0
2023.10.10 12:03:55 INFO  time: code lens generation in 2.91s
2023.10.10 12:03:55 INFO  time: code lens generation in 5.56s
2023.10.10 12:03:55 INFO  time: code lens generation in 2.91s
2023.10.10 12:03:56 INFO  time: indexed workspace in 2.75s
Command "/Users/me/.emacs.d/.cache/lsp/metals/metals" is present on the path.
Command "semgrep lsp" is not present on the path.
Command "/Users/me/.emacs.d/.cache/lsp/metals/metals" is present on the path.
Command "semgrep lsp" is not present on the path.
Found the following clients for /Users/me/test/lsp-metals/src/main/scala/com/example/lsp/metals/Main.scala: (server-id metals, priority -1)
The following clients were selected based on priority: (server-id metals, priority -1)
2023.10.10 12:04:02 INFO  compiling root (1 scala source)
2023.10.10 12:04:02 INFO  time: compiled root in 0.23s
2023.10.10 12:04:07 ERROR Error encountered during file watching
java.nio.file.NoSuchFileException: /Users/me/test/lsp-metals/src/main/scala/com/example/lsp/metals/.#Main.scala
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at sun.nio.fs.UnixPath.toRealPath(UnixPath.java:825)
	at com.swoval.files.SymlinkWatcher.addSymlink(SymlinkWatcher.java:194)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:48)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:36)
	at com.swoval.files.Observers.onNext(Observers.java:31)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:287)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:261)
	at com.swoval.files.apple.FileEventMonitorImpl$WrappedConsumer$1.run(FileEventMonitors.java:178)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:833)

2023.10.10 12:04:11 INFO  compiling root (1 scala source)
2023.10.10 12:04:11 INFO  time: compiled root in 0.7s
2023.10.10 12:04:38 ERROR Error encountered during file watching
java.nio.file.NoSuchFileException: /Users/me/test/lsp-metals/src/main/scala/com/example/lsp/metals/.#Main.scala
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at sun.nio.fs.UnixPath.toRealPath(UnixPath.java:825)
	at com.swoval.files.SymlinkWatcher.addSymlink(SymlinkWatcher.java:194)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:48)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:36)
	at com.swoval.files.Observers.onNext(Observers.java:31)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:287)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:261)
	at com.swoval.files.apple.FileEventMonitorImpl$WrappedConsumer$1.run(FileEventMonitors.java:178)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:833)

Cancelling textDocument/codeAction(104) in hook after-change-functions
Cancelling textDocument/codeLens(108) in hook after-change-functions
Cancelling textDocument/codeAction(107) in hook after-change-functions
2023.10.10 12:07:10 ERROR Error encountered during file watching
java.nio.file.NoSuchFileException: /Users/me/test/lsp-metals/src/main/scala/com/example/lsp/metals/.#Main.scala
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at sun.nio.fs.UnixPath.toRealPath(UnixPath.java:825)
	at com.swoval.files.SymlinkWatcher.addSymlink(SymlinkWatcher.java:194)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:48)
	at com.swoval.files.SymlinkFollowingPathWatcher$1.onNext(SymlinkFollowingPathWatcher.java:36)
	at com.swoval.files.Observers.onNext(Observers.java:31)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:287)
	at com.swoval.files.ApplePathWatcher$1.accept(ApplePathWatcher.java:261)
	at com.swoval.files.apple.FileEventMonitorImpl$WrappedConsumer$1.run(FileEventMonitors.java:178)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:833)

Cancelling textDocument/codeAction(210) in hook post-command-hook

LSP metals won't load, stops configuration of SemanticDB in 2.13.10 projects

I originally posted in scalameta/metals but given the comments there, I wonder if maybe there's an issue with lsp-metals?

I've tried the instructions from the scalameta page as well as the (much) smaller instructions from the lsp-metals readme but I always get the following:

LSP :: Stopped configuration of Scala SemanticDB in 2.13.10 projects: Error downloading org.scalameta:semanticdb-scalac_2.13.10:4.4.32
not found: /Users/arigold/.ivy2/local/org.scalameta/semanticdb-scalac_2.13.10/4.4.32/ivys/ivy.xml
not found: https://repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.13.10/4.4.32/semanticdb-scalac_2.13.10-4.4.32.pom

As per the instructions on the scalameta page, I installed the server with coursier install metals and, fwiw, I installed coursier with brew coursier.

To be honest, I've done so many installs and reinstalls that I'm not sure how /usr/local/bin/metals-emacs got there :-/

I was able to run lsp-metals-doctor-run and something seems off because I see

Scala 2.13.10 is not yet supported, please downgrade to Scala 2.13.8.

even tho 2.13.10 is said to be supported.

The doctor command also shows

Build server currently being used is Bloop v1.4.12.

Any ideas? Happy to update documentation once this gets resolved :)

Symbol’s function definition is void: treemacs-define-leaf-node

Describe the bug
I use straight.el on emacs 28.2, so I'm running the latest master version of metals. I'm getting the following error on start up of emacs:

Error (use-package): lsp-metals/:catch: Symbol’s function definition is void: treemacs-define-leaf-node

And a similar error when metals tries to start (when I open a Scala file):

Error running timer: (void-function treemacs-define-leaf-node)

This might be related to #81, because I see the following error just before:
Eager macro-expansion failure: (wrong-number-of-arguments (1 . 1) 0)

To Reproduce
I will attempt to come up with a simple series of steps, but my configuration and, specifically, the lsp start up module is here.

I get the same error on emacs start if I strip absolutely everything else from my init-lsp.el except:

(use-package lsp-metals)

With that configuration, I just have to start emacs or try to start metals on any scala file to reproduce.

Expected behavior
lsp-metals to compile and start.

Treeview Never Gets Information

Treeview never launches, if I manually launch treeview I see "Waiting for Metals Treeview information...".

The tab not launching until it gets information seems to be WAI but I'm not sure why it never get's information. I set lsp-metals-treeview-logging but don't see anything in lsp-log that appears relevant to me.

How do I figure out what's going on?

using lsp-metals under guix with coursier linux binary launcher

Describe the bug
Currently metals gets bootstraped with coursier binary. However precompiled binaries provided by coursier are not running under Guix due to the nature of distribution and how it deals with linux ld loader.

When (lsp-install-server t 'metals) is executed on such environemnt, *Messages* will have:

LSP :: Download metals started.
(:download :url "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" :store-path "/home/muradm/.local/share/emacs/var/lsp/server/metals/coursier" :decompress :gzip :set-executable? t)
LSP :: Starting to download https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz to /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
Contacting host: github.com:443
Wrote /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz
LSP :: Finished downloading /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
LSP :: Decompressing /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
(Shell command succeeded with no output)
LSP :: Decompressed /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier...
LSP :: Server metals install process failed with the following error message: (file-missing Doing vfork No such file or directory).
Check `*lsp-install*' and `*lsp-log*' buffer.

Below sequence of commands illustrating the issue with downloaded non-working launcher and working ls command as example.

$ wget https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz
$ gunzip cs-x86_64-pc-linux.gz
$ chmod a+x cs-x86_64-pc-linux
$ file cs-x86_64-pc-linux
cs-x86_64-pc-linux: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ba800144eff305fab792b58743c6e5b9aaa50a46, for GNU/Linux 3.2.0, with debug_info, not stripped
$ ./cs-x86_64-pc-linux
bash: ./cs-x86_64-pc-linux: No such file or directory
$ ls -la /lib64/ld-linux-x86-64.so.2
ls: cannot access '/lib64/ld-linux-x86-64.so.2': No such file or directory
$ file $(readlink $(which ls))
/gnu/store/8fpk2cja3f07xls48jfnpgrzrljpqivr-coreutils-8.32/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
$ ls -la /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 10 Jan  1  1970 /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2 -> ld-2.33.so

To Reproduce
Setup Guix, emacs for your liking and try (lsp-install-server t 'metals).

Expected behavior
Should be possible to use lsp-metals out-of-the-box.

In order to solve this issue, it could be better to use jar version of coursier launcher. It requires only java to be present in the system, which should be available any way. It will also simplify things for multiple platforms, as it should be running on any platform having java preinstalled.

Workaround
Dig lsp-metals to identify how coursier is used. Find emacs lsp server install path. Do the lsp-install-server work manually. For instance:

# for me lsp server install path is below
$ cd ~/.local/share/emacs/var/lsp/server/metals
$ wget https://github.com/coursier/launchers/raw/master/coursier.jar
$ java -jar coursier.jar bootstrap --java-opt -Xss4m --java-opt -Xms100m org.scalameta:metals_2.12:latest.release -r bintray:scalacenter/releases -r sonatype:snapshots -o metals

Eager macro-expansion failure

When I open a Scala file and lsp-metals-treeview initialises I get an Emacs error:
"Eager macro-expansion failure: %S" (wrong-number-of-arguments (1 . 1) 0

I'm using Emacs 29. Backtrace:

Debugger entered--Lisp error: (error "Eager macro-expansion failure: (wrong-number-of-ar...")
  error("Eager macro-expansion failure: %S" (wrong-number-of-arguments (1 . 1) 0))
  internal-macroexpand-for-load((defalias 'lsp-metals-treeview--show-view #'(lambda (workspace view-id position) "Show or create the side window and treeview.\nThe w..." (let ((buffer-name (lsp-metals-treeview--buffer-name workspace ...))) (-if-let (buffer (get-buffer buffer-name)) (with-selected-window (display-buffer-in-side-window buffer position) (lsp-metals-treeview--log "Refreshing tree %s" view-id) (treemacs-update-node ... t) (set-window-dedicated-p ... t) (set-window-parameter ... ... t)) (let* (... ...) (with-lsp-workspace workspace ...)))))) t)
  load-with-code-conversion("/Users/thoradam/.emacs.d/elpa/lsp-metals-20220715...." "/Users/thoradam/.emacs.d/elpa/lsp-metals-20220715...." nil t)
  require(lsp-metals-treeview)
  load-with-code-conversion("/Users/thoradam/.emacs.d/elpa/lsp-metals-20220715...." "/Users/thoradam/.emacs.d/elpa/lsp-metals-20220715...." t t)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_340>(lsp-metals)
  mapc(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_340> (ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile lsp-elm lsp-elixir lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-gleam lsp-graphql lsp-hack lsp-grammarly lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mint lsp-nginx lsp-nim lsp-nix lsp-magik lsp-metals ...))
  seq-do(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_340> (ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile lsp-elm lsp-elixir lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-gleam lsp-graphql lsp-hack lsp-grammarly lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mint lsp-nginx lsp-nim lsp-nix lsp-magik lsp-metals ...))
  lsp--require-packages()
  lsp()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook scala-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook scala-mode-hook))
  run-mode-hooks(scala-mode-hook)
  scala-mode()
  set-auto-mode-0(scala-mode nil)
  set-auto-mode--apply-alist((("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode) ("\\.\\(scala\\|sbt\\|worksheet\\.sc\\)\\'" . scala-mode) ("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file) ("\\.elc\\'" . elisp-byte-code-mode) ("\\.zst\\'" nil jka-compr) ("\\.dz\\'" nil jka-compr) ("\\.xz\\'" nil jka-compr) ("\\.lzma\\'" nil jka-compr) ("\\.lz\\'" nil jka-compr) ("\\.g?z\\'" nil jka-compr) ("\\.bz2\\'" nil jka-compr) ("\\.Z\\'" nil jka-compr) ("\\.vr[hi]?\\'" . vera-mode) ("\\(?:\\.\\(?:rbw?\\|ru\\|rake\\|thor\\|jbuilder\\|rabl\\|ge..." . ruby-mode) ("\\.re?st\\'" . rst-mode) ("\\.py[iw]?\\'" . python-mode) ("\\.m\\'" . octave-maybe-mode) ("\\.less\\'" . less-css-mode) ("\\.scss\\'" . scss-mode) ("\\.awk\\'" . awk-mode) ("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode) ("\\.idl\\'" . idl-mode) ("\\.java\\'" . java-mode) ("\\.m\\'" . objc-mode) ("\\.ii\\'" . c++-mode) ("\\.i\\'" . c-mode) ("\\.lex\\'" . c-mode) ("\\.y\\(acc\\)?\\'" . c-mode) ("\\.h\\'" . c-or-c++-mode) ("\\.c\\'" . c-mode) ("\\.\\(CC?\\|HH?\\)\\'" . c++-mode) ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) ("\\.\\(cc\\|hh\\)\\'" . c++-mode) ("\\.\\(bat\\|cmd\\)\\'" . bat-mode) ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode) ("\\.svgz?\\'" . image-mode) ("\\.svgz?\\'" . xml-mode) ("\\.x[bp]m\\'" . image-mode) ("\\.x[bp]m\\'" . c-mode) ("\\.p[bpgn]m\\'" . image-mode) ("\\.tiff?\\'" . image-mode) ("\\.gif\\'" . image-mode) ("\\.png\\'" . image-mode) ("\\.jpe?g\\'" . image-mode) ("\\.webp\\'" . image-mode) ("\\.te?xt\\'" . text-mode) ("\\.[tT]e[xX]\\'" . tex-mode) ("\\.ins\\'" . tex-mode) ("\\.ltx\\'" . latex-mode) ("\\.dtx\\'" . doctex-mode) ...) nil nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer PubsubPublisher.scala> "~/Developer/indo/monorepodir/monorepo/src/main/sca..." nil nil "~/Developer/indo/monorepodir/monorepo/src/main/sca..." (341228 16777229))
  find-file-noselect("~/Developer/indo/monorepodir/monorepo/src/main/sca..." nil nil t)
  find-file("~/Developer/indo/monorepodir/monorepo/src/main/sca..." t)
  funcall-interactively(find-file "~/Developer/indo/monorepodir/monorepo/src/main/sca..." t)
  command-execute(find-file)

Fully switch to configuration via initializationOptions

As of 0.9.2 of Metals it's now fully possible to use Metals without needing to set the client property when bootstrapping Metals. Ultimately the hope is that this will provide a smoother experience for users since they are able to just install Metals, and then let the client take care of setting the correct initializationOptions. We are going to update the docs soon to recommend installing Metals via cs install metals rather than using bootstrap (scalameta/metals#1884). For the time being there is a metals-emacs app in coursier/apps, but there will also soon be a plain metals (coursier/apps#59). Once this happens, you would be able to update the initializationOptions and the lsp-metals-server-command and you should be able to use it. Looking at the server, the only things the client=emacs changes is the following:

executeClientCommandProvider set to true (which you already have), and compilerInitializationOptions.snippetAutoIndent set to false (if that still applies). So in theory you should just have to add that last setting and you should be good to go.

You can read more about the configuration changes here on the site.

dap-ui-repl just returns the message `an implementation is missing`

Describe the bug
When I start a dap-ui-repl and want to evalutate an expression in the REPL I get the message an implementation is missing.

To Reproduce
Steps to reproduce the behavior(sample project + file which can be used to reproduce the issue with.)

Create a simple Main object that extends app. Set a breakpoint. Start the debugging. Call M-x dap-ui-repl. Type 1.

Expected behavior
Should evaluate to 1 instead of showing an implementation is missing

Screenshots
If applicable, add screenshots to help explain your problem.

Review default configuration for emacs-metals

Hi,

we have a default configuration on our site for emacs (https://scalameta.org/metals/docs/editors/emacs.html)

Today issue was raised that it is no longer valid because now you have to additionally require lsp-metals in addition to lsp-mode. As I understand it is related to moving to separate repo?

I also noticed that lsp-metals-treeview-enable is no longer valid. Can this be safely removed?

Could you just take a look if anything else should be adjusted?

Imenu provides too detailed leafs

After latest lsp update, Imenu provides too deep/detailed leafs.
E.g. for the following Scala class I expect b and b2 as Imenu contents (classes and functions list, not function contents), but c and c2 actually appears.

class A {
    def b: Unit = {
        val c: Int = 0
    }

    def b2: Unit = {
        val c2: Int = 0
    }
}

image

How can I fix it?

Symbol’s function definition is void: treemacs-define-doubleclick-action

Describe the bug
After updating to the latest versions of package I get the following error when I start Emacs or try to open a Scala project.
Symbol’s function definition is void: treemacs-define-doubleclick-action

I think the problem was caused by a recent change to treemacs. As a hack I added (require 'treemacs-mouse-interface) to lsp-metals-treeview.el and the problem went away.

To Reproduce
Use the most recent packages from elpa and start emacs.

Expected behavior
Start without errors.

InputBox Provider feature

Specs for LSP for initialization message:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize

When sending ClientCapabilities client can add experimental section that is custom for different client/server settings.

Metals supports parameter inputBoxProvider that is boolean and can be set to true/false.

If this setting is set to true metals will assume this request can be handled by client:

  /**
   * Opens an input box to ask the user for input.
   *
   * @return the user provided input.
   */
  @JsonRequest("metals/inputBox")
  def metalsInputBox(
      params: MetalsInputBoxParams
  ): MetalsInputBoxResult

Command name will be: metals/inputBox
Request will contain this parameter(it is as with all other requets serialized to json)

case class MetalsInputBoxParams(
    // The value to prefill in the input box
    @Nullable value: String = null,
    // The text to display underneath the input box.
    @Nullable prompt: String = null
)

response:

case class MetalsInputBoxResult(
    // value=null when cancelled=true
    @Nullable value: String = null,
    @Nullable cancelled: java.lang.Boolean = null
)

Metals Not Loading Correctly for Project

Describe the bug
Today Metals is having problems trying to connect to a local project.

I created a brand new Scala 2.13 project and Metals is failing to load the project. I posted below errors.

It seems it doesn't produce a bloop file. I tried using VS Code with Metals and it does work for the same project so I believe its an Emacs issue.

This started happening today.

To Reproduce
Create a brand new Scala 2.13 and try to build import. Emacs 28.1.

Expected behavior
The Metals should produce a bloop file and load the project.

Logs

2023.04.06 14:28:50 ERROR Empty build targets. Expected at least one build target identifier.
2023.04.06 14:28:50 ERROR Empty build targets. Expected at least one build target identifier.
2023.04.06 14:28:50 ERROR Empty build targets. Expected at least one build target identifier.
2023.04.06 14:28:50 ERROR Empty build targets. Expected at least one build target identifier.
2023.04.06 14:28:52 INFO  time: indexed workspace in 1.37s
2023.04.06 14:28:52 WARN  no build target for: /Users/shane.drafahl/test123/src/main/scala/example/Hello.scala
2023.04.06 14:28:52 WARN  no build target for: /Users/shane.drafahl/test123/src/main/scala/example/Hello.scala

LSP/Emacs hangs while updating metals server

Describe the bug
I tried to upgrade to Metals 0.11.10 from within Emacs by running lsp-update-server. The Emacs echo area then showed "Contacting host github.com:443 ..." and then hanged. (Emacs wouldn't respond to any further input and had to be killed.) The same happened when I tried lsp-install-server, and when I tried again after lsp-uninstall-server. That last command deleted ~/.emacs.d/.cache/lsp/metals/metals which was previously an executable file.

Finally, I quit Emacs and installed Metals via cs install metals. Then, I symlinked ~/.emacs.d/.cache/lsp/metals/metals to the coursier-installed Metals. Then, I restarted Emacs and opened a Scala project, and LSP started my new, manually installed version of Metals without issue.

To Reproduce
Versions of software:

  • Emacs 28.1
  • lsp-mode 20230206.1806
  • lsp-metals 20221102.1628
  • Coursier 2.1.0-M6-28-gbad85693f
  • Metals 0.11.9 (or could have been 0.11.8)
  • Ubuntu 22.04 LTS

From Emacs, run M-x lsp-update-server RET metals RET.

Expected behavior
The Metals server that LSP had previously automatically installed under ~/.emacs.d/.cache/lsp/metals/ should be updated. If there is genuinely a network connectivity issue (which I highly doubt there was in my case), the update should fail instead of hanging on "contacting host".

Happy to provide additional information if needed. But replicating might be tricky now because I manually upgraded to Metals 0.11.10 as described above.

lsp-metals treeview interferes with commands when refreshing

[Edited for clarity after further testing]

Describe the bug
While code is compiling and the lsp-metals treeview is refreshing with compile progress for the modules in a project, it messes with the ability to execute commands: for example, if I do a /-search (I'm in evil mode), if a refresh happens while I'm typing the query, it might shunt me into insert mode or suddenly delete the whole buffer. After this happens, commands don't work properly either, e.g., d (again in Evil normal mode) immediately deletes a whole line as if I executed dd. This may have to do with interactions with Evil mode but I'm not sure. It's hard for me to tell what the underlying problem is because it seems unpredictable. But altogether the this prevents me from doing basically anything while code is compiling.

To Reproduce
Open a scala project which takes a non-trivial amount of time to compile. Edit and save a file to trigger a compile. Then try inserting some text, executing a search within file, etc.—each refresh messes things up.

In case it matters, I'm using Spacemacs (develop) in Evil mode. So that might affect something related to the cursor movement. Idk.

Expected behavior
I expect the treeview buffer to refresh itself silently, without interfering with commands or getting the editor into weird states.

Can't install server (signature expired)

M-x lsp-install-server on Emacs 27.2 gives the following error:

LSP :: Server metals install process failed with the following error message: (error Failed to verify GPG signature: Signature made by expired key CD1B9D8DC84ECA56 Alexandre Archambault (Travis CI coursier) <[email protected]>).

Could you please check what's happening?

Running unit test

Describe the bug
Not a bug, I just can't find a way to run a method of a unit test. I have the run test/debug test on the class, but nothing on each unit test method. Is it at all possible or missing currently ?

Installing/Updating behind proxy

Describe the bug
A clear and concise description of what the bug is.

I'm behind a proxy, opening a .scala file leads to lsp + metals trying to install/update, which results in error (buffer *metals::stderr*):

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Error while downloading https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.7/gson-2.8.7.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/ch/epfl/scala/bsp4j/2.0.0-M13/bsp4j-2.0.0-M13.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/ch/epfl/scala/scalafix-interfaces/0.9.27/scalafix-interfaces-0.9.27.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/com/geirsson/metaconfig-core_2.12/0.9.11/metaconfig-core_2.12-0.9.11.jar: Connection timed out (Connection timed out), ignoring it

Process metals stderr finished

Seems that the proxy configuration is not taken into account (I've tried with env vars *_proxy and in emacs config)

To Reproduce
Steps to reproduce the behavior(sample project + file which can be used to reproduce the issue with.)

  • Be behind a proxy
  • Try to install/upgrade metals

Expected behavior
A clear and concise description of what you expected to happen.

All Emacs connexions (included lsp/lsp-* upgrades) should pass through proxy when it is configured

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.
cf above

EDIT: I've also tried C-u M-x lsp-install-server metals, which seems to have worked (*messages* buffer)

Wrote /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc
LSP :: Finished downloading /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc...
LSP :: Verifying signature /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc...
LSP :: Server metals downloaded, auto-starting in 0 buffers.

But without success

EDIT2: I'm discovered metals is installed in /home/user/.emacs.d/.cache/lsp/metals/metals... I've tried to run/update it manually by running the command in a terminal... Seems to ignore the proxy too....

can't find java.

Describe the bug
When starting lsp sever the message buffer shows: LSP :: Error from the Language Server: Internal error. (Internal Error)
And the output of lsp-log shows:

2023.10.22 20:40:58 ERROR Running process '/Users/madper/source/zring/@@HOMEBREW_JAVA@@/bin/java -version' failed
java.io.IOException: Cannot run program "/Users/madper/source/zring/@@HOMEBREW_JAVA@@/bin/java" (in directory "/Users/madper/source/zring/@@HOMEBREW_JAVA@@"): error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
	at scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:45)
	at scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:154)
	at scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:214)
	at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:205)
	at scala.Option.orElse(Option.scala:477)
	at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$1(JavaInteractiveSemanticdb.scala:205)
	at scala.Option.flatMap(Option.scala:283)
	at scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:203)
	at scala.meta.internal.metals.MetalsLspService.<init>(MetalsLspService.scala:204)
	at scala.meta.internal.metals.WorkspaceLspService.createService(WorkspaceLspService.scala:170)
	at scala.meta.internal.metals.WorkspaceLspService.$anonfun$workspaceFolders$1(WorkspaceLspService.scala:177)
	at scala.meta.internal.metals.WorkspaceFolders.$anonfun$folderServices$2(WorkspaceFolders.scala:25)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.meta.internal.metals.WorkspaceFolders.<init>(WorkspaceFolders.scala:25)
	at scala.meta.internal.metals.WorkspaceLspService.<init>(WorkspaceLspService.scala:175)
	at scala.meta.metals.MetalsLanguageServer.createService(MetalsLanguageServer.scala:231)
	at scala.meta.metals.MetalsLanguageServer.initialize(MetalsLanguageServer.scala:170)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:840)
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
	at java.lang.ProcessImpl.start(ProcessImpl.java:244)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
	at scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:45)
	at scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:154)
	at scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:214)
	at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:205)
	at scala.Option.orElse(Option.scala:477)
	at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$1(JavaInteractiveSemanticdb.scala:205)
	at scala.Option.flatMap(Option.scala:283)
	at scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:203)
	at scala.meta.internal.metals.MetalsLspService.<init>(MetalsLspService.scala:204)
	at scala.meta.internal.metals.WorkspaceLspService.createService(WorkspaceLspService.scala:170)
	at scala.meta.internal.metals.WorkspaceLspService.$anonfun$workspaceFolders$1(WorkspaceLspService.scala:177)
	at scala.meta.internal.metals.WorkspaceFolders.$anonfun$folderServices$2(WorkspaceFolders.scala:25)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.meta.internal.metals.WorkspaceFolders.<init>(WorkspaceFolders.scala:25)
	at scala.meta.internal.metals.WorkspaceLspService.<init>(WorkspaceLspService.scala:175)
	at scala.meta.metals.MetalsLanguageServer.createService(MetalsLanguageServer.scala:231)
	at scala.meta.metals.MetalsLanguageServer.initialize(MetalsLanguageServer.scala:170)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:840)

Do I need a copy of java in the source dir? As I'm sure that I have openjdk@21 on my mac as java --version shows 21 already.

To Reproduce
Steps to reproduce the behavior(sample project + file which can be used to reproduce the issue with.)

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.

dap-debug not working in gradle project

Describe the bug
Unable to run gradle project via dap-debug, while lsp-lens functions well.

To Reproduce
A minimal project to reproduce the issue:
scala3gradle.zip

Logs

LSP :: `workspace/executeCommand' with `debug-adapter-start' failed.

(error "Internal error.")
lsp-metals-populate-config: Wrong type argument: hash-table-p, #("LSP :: `workspace/executeCommand' with `debug-adapter-start' failed.

Cannot install Metals 0.11.3+

Describe the bug

lsp-install-server installs Metals 0.11.2, even though the current version is 0.11.4 (or 0.11.5 if you go by Maven Central)

To Reproduce

lsp-install-server, choose metals, wait until the end of the installation. Run path/to/metals --version, and observe that it's 0.11.2.

Expected behavior

lsp-install-server should install the latest released Metals version.

Analysis

The issue seems to be that Metals has switched to Scala 2.13, whereas this project has 2.12 hardcoded.

Treeview clobbers/competes with Treemacs file tree

Describe the bug
When calling lsp-metals-treeview to open the treeview, it replaces the Treemacs file tree and causes it (if already open) to get in a bad state, where multiple copies of the file tree are listed and step over each other. The only way to fix it is to run treemacs-kill-buffer and reopen with treemacs.

Worse, this also seems to happen every time lsp-metals-treeview--refresh is called and the lsp-metals treeview is opened. So the file tree quickly gets duplicated a bunch in a normal workflow.

To Reproduce
Run the following:

:treemacs

Navigate to a file and open a buffer.

:lsp-metals-treeview
:kill-buffer
:treemacs

It might depend on where your file is in the file tree, which seems to determine where the new duplicated project root steps on the previous file tree.

Expected behavior
I certainly don't expect the treemacs file tree to get in a bad state. But more generally it seems like lsp-metals is competing with treemacs for the 0 slot in the tree view window/buffer (not sure of the exact semantics here).

It seems in lsp-metals-treeview.el that it starts at 0 in lsp-metals-treeview--refresh and lsp-metals-treeview--show-window. Changing these to 1 fixed this issue; now the metals treeview opens in a new window under the file tree and doesn't cause any weirdness. This is much preferred, as I'd rather not lose view of the file tree anyway.

Screenshots
After navigating to a file and opening a buffer:
Screen Shot 2020-06-30 at 10 48 13 AM
After killing the lsp-metals-treeview buffer(s), reopening the file tree, and scrolling to the top:
Screen Shot 2020-06-30 at 10 51 14 AM
I can't delete the duplicated root/project node either, since treemacs thinks both are the "last" one. And expanding nodes near where the tree was clobbered produces weird behavior. Obviously it got in a bad state.

I'm using Spacemacs develop with the scala layer plus this package.

metals-treeview weird behaviour

Hi,

I am opening scala project -> M-x lsp-metals-treeview , I can correctly see 3 sections with Packages, Compile and Build.

But clicking on anything doesn't work.
In Packages I have to press TAB to expand, can I configure it?
In Build pressing TAB results in [Treemacs Failure] No TAB action defined for node of type treemacs-metals-leaf-state

I use raw emacs and include lsp-mode, lsp-treemacs and lsp-metals in my config(+evil).

Maybe it is just configuration, in that case could you describe how to configure it properly?
I could also add that to (https://scalameta.org/metals/docs/editors/emacs.html) for others.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.