svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
487 stars 31 forks source link

How to Switch Projects and Update Filepaths Simultaneously in =dape= #135

Closed LuciusChen closed 2 months ago

LuciusChen commented 2 months ago

Hello,

I am currently using the =dape= package and have encountered an issue when switching projects. Despite changing the project, the =filepath= does not update accordingly. Here is a snippet of my configuration:

(defun jdtls-command-contact (&optional interactive)
  (let* ((jdtls-cache-dir (file-name-concat user-emacs-directory "cache" "lsp-cache"))
         (project-dir (file-name-nondirectory (directory-file-name (project-root (project-current)))))
         (data-dir (expand-file-name (file-name-concat jdtls-cache-dir (md5 project-dir))))
         (jvm-args `(,(concat "-javaagent:" (expand-file-name "~/.m2/repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar"))
                     "-Xmx8G"
                     ;; "-XX:+UseG1GC"
                     "-XX:+UseZGC"
                     "-XX:+UseStringDeduplication"
                     ;; "-XX:FreqInlineSize=325"
                     ;; "-XX:MaxInlineLevel=9"
                     "-XX:+UseCompressedOops"))
         (jvm-args (mapcar (lambda (arg) (concat "--jvm-arg=" arg)) jvm-args))
         ;; tell jdtls the data directory and jvm args
         (contact (append '("jdtls")
                          jvm-args
                          `("-data" ,data-dir)
                          `(:initializationOptions
                            (:bundles
                             [,(file-truename "~/.m2/repository/com/microsoft/java/com.microsoft.java.debug.plugin/0.53.0/com.microsoft.java.debug.plugin-0.53.0.jar")])))))
    contact))
LuciusChen commented 2 months ago

I am using the built-in =project= package in Emacs.

svaante commented 2 months ago

Hi. I am not sure if I follow. Would it be possible for you to illustrate your issue with an screenshot?

LuciusChen commented 2 months ago
image

When I started dape in the demo project and then switched to the sky project to start dape again, the filepatch as well as :mainClass and :projectName still had the information from the demo project. I had to manually modify them to use dape for debugging in the sky project.

svaante commented 2 months ago

Dape tries to be ergonomic and displays the last "dape" command.

Delete everything except the adapter name jdtls which forces dapeto re-do lookup for :filePath, :mainClassand :projectName.

There is actually an undocumented keybind C-c C-k (in the minibuffer) which accomplishes this.

Nice looking Emacs btw!