What’s going on here?
I start several workspaces at the same time and need to switch back and forth between them. When I first start the project, lsp-mode
works fine, but when I switch to another workspace and then back to the current workspace, lsp-mode
does not work. I tried restarting the lsp server with lsp-workspace-restart
, but it says that the lsp server is not started in the current workspaceand I checked with list-process that this lsp servr process exists.
Invalidated Projectile cache for /home/xxx/zzzzzzzzz.
Cleaning up the recentf list...done (0 removed)
Killed all dired buffers
(No changes need to be saved)
Killed all dired buffers
SPC TAB SPC is undefined
LSP :: Shutdown boot-ls:4082930 since folder /home/xxx/xxxxxxx is removed...
LSP :: Shutdown jdtls:4082896 since folder /home/xxx/xxxxxx is removed...
(No changes need to be saved)
evil-scroll-down: End of buffer
Invalidated Projectile cache for /home/xxx/yyyyyyyyy.
Cleaning up the recentf list...done (0 removed)
evil-line-move: End of buffer [6 times]
evil-line-move: Beginning of buffer [8 times]
Quit [2 times]
lsp--read-workspace: No workspaces associated with the current buffer
Q
I had to use the lsp!
command to start a new lsp server, and it ended up starting many lsp servers in the background.
I am not sure if this is the normal case, if it is the normal case what kind of workflow is correct in multiple workspace mode?
What do you expect to happen?
I want switching between workspaces to automatically reconnect to the lsp-server where the project was first started.
Steps to reproduce
-
SPC p p
Open a project, operating… - Open another new project and operate.
- Use
[ w
to switch back to the previous project
System information
doom info
generated Mar 31, 2023 00:48:59
system "Manjaro Linux" Linux 5.15.102-1-MANJARO x86_64 x
emacs 28.2 ~/doom-emacs/
doom 3.0.0-pre PROFILE=_@0 HEAD -> master 4e105a95a 2023-03-22 18:29:38 -0400
~/doom-config/
shell /bin/zsh
features ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11
XDBE XIM XPM GTK3 ZLIB
traits gui daemon server-running chemacs-2.0 envvar-file custom-file
custom warning-suppress-types warning-suppress-log-types sql-connection-alist
screenshot-line-numbers-p safe-local-variable-values elfeed-feeds
modules :config use-package :input (chinese +rime) :completion company (vertico
+icons) :ui doom doom-dashboard doom-quit hl-todo hydra indent-guides
(ligatures +extra) (modeline +light) nav-flash ophints (popup +all
+defaults) (treemacs +lsp) unicode (vc-gutter +pretty) (window-select
+ace-window) workspaces zen :editor (evil +everywhere) file-templates fold
(format +onsave) multiple-cursors rotate-text snippets word-wrap :emacs
(dired +icons) electric (ibuffer +icons) (undo +tree) vc :term vterm
:checkers syntax (spell +everywhere +aspell) grammar :tools (debugger +lsp)
direnv (docker +lsp) ein (eval +overlay) (lookup +dictionary +offline
+docsets) lsp magit make pdf prodigy rgb tree-sitter taskrunner upload
(&user translate) (&user calibre) :lang (cc +lsp) data emacs-lisp (go +lsp
+tree-sitter) (json +lsp) (java +lsp) javascript (latex +lsp) lua (markdown
+grip) (org +pretty +contacts +journal +dragndrop +pomodoro +hugo +noter
+gnuplot +jupyter +pandoc +roam2 +present) plantuml (python +lsp +pyright
+tree-sitter +cython +poetry) rest (rust +lsp) (sh +lsp) web (yaml +lsp)
:email (mu4e +gmail +org) :app everywhere irc (rss +org) :os (tty +osc)
:config literate (default +bindings +smartparens)
packages (ecws :recipe (:host github :repo kanglmf/emacs-chinese-word-segmentation
:pre-build (make) :files (cnws *.el cppjieba/dict))) (org-alert :pin
c039d0121d21e4558c0f5433135c839679b556d7) (org-ol-tree :recipe (:host
github :repo Townk/org-ol-tree)) (lorem-ipsum :pin
da75c155da327c7a7aedb80f5cfe409984787049) (password-generator)
(command-log-mode :pin af600e6b4129c8115f464af576505ea8e789db27) (vlf)
(info-colors :pin 47ee73cc19b1049eef32c9f3e264ea7ef2aaf8a5) (screenshot
:recipe (:host github :repo tecosaur/screenshot :build (:not compile)))
(blamer) (quickrun :pin 7a89313c07a21eae9cd69a1a98e2a134d559e04f) (es-mode)
(mvn) (mvn-enhance :recipe (:local-repo lisp/mvn-enhance)) (sqlformat :pin
3fa86085de8a4e70954d4b3346fb228016b5bbb9)
Config (I have no code related to configuring the workspace)
;; Increase the amount of data which Emacs reads from the process#
;; Again the emacs default is too low 4k considering that the some of the
;; language server responses are in 800k - 3M range.
(setq read-process-output-max (* 1024 1024)
lsp-use-plists t)
(after! lsp-mode
(setq lsp-signature-auto-activate t
lsp-signature-doc-lines 1)
(lsp-treemacs-sync-mode t))
(after! lsp-java
(setq! lsp-java-java-path "/usr/lib/jvm/java-11-openjdk/bin/java" ;; java 可执行文件路径
lsp-java-save-actions-organize-imports t ;; 保存文件时自动导入
lsp-java-maven-download-sources t
;; Preferred content provider (a 3rd party decompiler id, usually). We support https://github.com/dgileadi/vscode-java-decompiler.
lsp-java-content-provider-preferred "fernflower"
lsp-java-format-settings-profile "GoogleStyle"
;; 将 Java 执行环境映射到本地 JDK
lsp-java-configuration-runtimes '[(:name "JavaSE-1.8"
:path "/usr/lib/jvm/java-8-openjdk/"
:default t)
(:name "JavaSE-11"
:path "/usr/lib/jvm/java-11-openjdk/")
(:name "JavaSE-17"
:path "/usr/lib/jvm/java-17-openjdk/")])
(when lsp-java-format-settings-profile
(let ((profile lsp-java-format-settings-profile)
url
name)
(cond ((string-equal profile "GoogleStyle")
(setq url "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
name "java-google-style.xml"))
((string-equal profile "Spring")
(setq url "https://raw.githubusercontent.com/ndimiduk/spring-framework/master/eclipse-code-formatter.xml"
name "java-spring-style.xml"))
(t (message "不支持的代码格式化配置")
(setq lsp-java-format-settings-profile nil)))
(when (and url name)
(let ((style-path (concat doom-user-dir "formatter/" name)))
(unless (file-exists-p style-path)
(url-copy-file url style-path))
(setq lsp-java-format-settings-url (concat "file://" style-path))))))
;; spring boot 支持
(require 'lsp-java-boot)
;; current VSCode defaults
(advice-add 'lsp :before (lambda (&rest _args) (eval '(setf (lsp-session-server-id->folders (lsp-session)) (ht)))))
;; 启用 Spring format
(add-hook! 'java-mode-hook (setq c-basic-offset 4))
;; 当打开 xml 文件时自动启动 lsp
(add-hook! 'nxml-mode-hook #'lsp))
(after! lsp-java
;; lombok 库的路径
(setq lombok-library-path (concat doom-etc-dir "lombok.jar"))
(unless (file-exists-p lombok-library-path)
(url-copy-file "https://projectlombok.org/downloads/lombok.jar" lombok-library-path))
;; 设置 lsp jvm参数
(setq lsp-java-vmargs
`("-noverify"
"-Xmx1G"
"-Xms200m"
"-XX:+UseG1GC"
"-XX:+UseStringDeduplication"
;; 配置 lombok 支持
,(concat "-javaagent:" lombok-library-path)
;; 会导致 lsp-diagnosis 失效
;; ,(concat "-Xbootclasspath/a:" lombok-library-path)
)))