简体   繁体   中英

How do I configure emacs lsp-mode with clangd over TRAMP?

I'm trying to configure lsp-mode to work on remote files opened via TRAMP. The documentation doesn't really talk about this at all but from what I've gathered from various searches, I've cobbled together this:

(use-package lsp-mode
  :commands lsp
  :straight t
  :config
  (progn
    (add-hook 'prog-mode-hook #'lsp)
    (lsp-register-client
     (make-lsp-client :new-connection (lsp-tramp-connection
                                       "/path/to/clangd")
                      :major-modes '(c-mode c++-mode)
                      :remote? t
                      :server-id 'clangd-remote))))

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

(use-package company-lsp
  :commands company-lsp
  :straight t)

But upon opening a file, lsp-mode reports that clangd exited:

LSP :: clangd-remote has exited (exited abnormally with code 127)
Server clangd-remote:32027 status:starting exited with status exit. Do 
you want to restart it? (y or n) n

I'm guessing clangd isn't ever actually started but I don't know what's wrong. Is my config generally correct or not? Does lsp-mode have any debug output I could enable?

this is my configuration and it looks like it works (I'm moving my first steps too)

(use-package lsp-mode
  :hook ((prog-mode . lsp-deferred))
  :commands (lsp lsp-deferred)
  :config
  (progn
    (lsp-register-client
     (make-lsp-client :new-connection (lsp-tramp-connection "clangd")
                      :major-modes '(c-mode c++-mode)
                      :remote? t
                      :server-id 'clangd-remote))))

The idea is to register emacs as a client againt the LSP. I connect via TRAMP to a WSL2 on which I've installed clangd.

My true aim is to setup a LSP to edit PHP code, availing to Serenata or whatever. But I still I've not figured out how to register multiple clients at the same time, so any suggestion will be appreciated.

And yes, the documentation should definitely be improved, or at least they should add a forum where to leave some questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM