syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

Using LSP with TRAMP starts multiple language servers instances #13925

Closed exzombie closed 5 months ago

exzombie commented 4 years ago

Description :octocat:

Spacemacs has issues using LSP via TRAMP that are not present in vanilla emacs. In particular, it opens many SSH connections, spawning a clangd (or ccls; I tested C++ only) for each source file related to the opened one. I've no idea how to debug this, I hope others will be able to reproduce this. It may be related to #11514.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart:

I have observed many other weird issues trying to use LSP remotely, but I'm not sure which are related and which are not, so I'm just focusing on the multiple language server instances issue for now. It's the most important, I think, because even in the best case, having too many connections opened causes things to freeze at some point (where "things" means both emacs and SSH itself, depending on SSH server configuration).

Expected behaviour: :heart: :smile: Spacemacs should only start one clangd instance for the project, same as vanilla emacs.

System Info :computer:

Test file

Modify the remote file paths.

lsp-tramp-test.el

(require 'package)

(setq debug-on-error t)

(let* ((package-archives '(("melpa" . "https://melpa.org/packages/")
                           ("gnu" . "https://elpa.gnu.org/packages/")))
       (no-byte-compile t)
       (package-user-dir (expand-file-name (make-temp-name "lsp-tmp-elpa")
                                           user-emacs-directory))
       (custom-file (expand-file-name "custom.el" package-user-dir))
       (pkg-list '(lsp-mode lsp-ui helm-lsp lsp-treemacs company flycheck)))

  (package-initialize)
  (package-refresh-contents)

  (mapcar (lambda (pkg)
            (unless (package-installed-p pkg)
              (package-install pkg))
            (require pkg))
          pkg-list)

  (add-hook 'prog-mode-hook 'lsp)
  (add-hook 'kill-emacs-hook `(lambda ()
                                (delete-directory ,package-user-dir t))))

(require 'lsp)
(with-eval-after-load 'lsp-mode
 (lsp-register-client
  (make-lsp-client
   :remote? t
   :new-connection (lsp-tramp-connection "clangd")
   :major-modes '(c-mode c++-mode)
   :server-id 'clangd-remote)))

(find-file "/ssh:user@server:~/src/testproject/file1.cpp")
(find-file "/ssh:user@server:~/src/testproject/file2.cpp")
github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!