reddit / emacs
tramp + lsp + gopls = :(
shishkabeb · 2022-06-21 17:22
has anybody been able to make this work? i just lost a whole evening and morning to this. right now i'm at the point where i can get gopls to run and then exit (1) with nothing on stderr :( :(
i will (semi-)seriously pay $20 for a working tramp + lsp + gopls implementation
FrozenOnPluto · 2022-06-21 19:38
You should mention what you've tried, show snippets, etc.
Never tried gopls but I use pyright (python LSP server) over tramp every day; the trick I think there is just installing the LSP server on the remote.. you've done that?
I have a fair amount of lsp config for my pyright setup, but doesn't look like any magic in there. (no weird tricks like using tramp notation to find the pyright executable etc. Just works more or less as if local, though slower of course.) Its common the first time I open a file on the remote it hangs for awhile so I C-g it and then revisit the file and it all fires up a treat.
Also make sure you're on melpa and update to all the latest packates.
Is there a pacckage for lsp and gopls? ie: I'm using lsp-mode plus also lsp-whatever-pyright iirc packages, for example.
\*shrug\*
shishkabeb · 2022-06-21 19:45
lsp-go using gopls is included in lsp-mode, latest lsp & lsp-ui, etc
I'm just feeling so burnt out at this point that I seriously doubt that anyone has this working at all.
i followed the advice here https://emacs-lsp.github.io/lsp-mode/page/remote/ and it got me to where i am now, which is with gopls crashing with no error message or stderr on remote only.
fwiw:
(lsp-register-custom-settings
'(("gopls-remote.usePlaceholders" lsp-go-use-placeholders t)
("gopls-remote.hoverKind" lsp-go-hover-kind)
("gopls-remote.buildFlags" lsp-go-build-flags)
("gopls-remote.env" lsp-go-env)
("gopls-remote.linkTarget" lsp-go-link-target)
("gopls-remote.codelenses" lsp-go-codelenses)
("gopls-remote.linksInHover" lsp-go-links-in-hover t)
("gopls-remote.gofumpt" lsp-go-use-gofumpt t)
("gopls-remote.local" lsp-go-goimports-local)
("gopls-remote.directoryFilters" lsp-go-directory-filters)
("gopls-remote.analyses" lsp-go-analyses)
("gopls-remote.importShortcut" lsp-go-import-shortcut)
("gopls-remote.symbolMatcher" lsp-go-symbol-matcher)
("gopls-remote.symbolStyle" lsp-go-symbol-style)))
(lsp-register-client
(make-lsp-client :new-connection (lsp-tramp-connection
(lambda () (cons "gopls" lsp-go-gopls-server-args)))
:major-modes '(go-mode go-dot-mod-mode)
:language-id "go"
:priority 0
:server-id 'gopls-remote
:completion-in-comments? t
:library-folders-fn #'lsp-go--library-default-directories
:after-open-fn (lambda ()
;; https://github.com/golang/tools/commit/b2d8b0336
(setq-local lsp-completion-filter-on-incomplete nil))
:remote? t
))
[deleted] · 2022-06-21 20:48
[deleted]
Faerryn · 2022-06-21 21:15
try using eglot instead of lsp-mode. I hear that it works better over tramp.
shishkabeb · 2022-06-21 21:55
i'll try that ty
shishkabeb · 2022-06-21 21:56
i did pull latest lsp-* and delete the old versions first. i definitely did need to delete elpa to fix one problem lol
but alas, it wasnt enough to get all the way there
ndpian · 2022-06-21 22:10
On the contrary, I quite never got lsp -> tramp -> pyright working, even when my pyright is in the path of my remote server (`executable-find` gets the tramp pyright installation) . The LSP client starts and then exits with a unhelpful message: "pyright-remote has exited (exited abnormally with code 1)". The LSP docs say the stderr is written in /tmp, and I do find a file in /tmp of my server, but it is always blank.
I have mostly given up the dream of using lsp to write my code on the server. Instead, I now rely on dumb-jump for quick navigation.
404cn · 2022-06-23 11:09
I use eglot + tramp + gopls on work everyday, it just works like local.
shishkabeb · 2022-06-23 13:48
I just tried eglot gopls over tramp, and while there was no error, nothing actually happened. the eglot log showed request being made but only timed-outs, no responses. it is a big repo... but it works with lsp locally. have you seen this?
chrisxsa · 2022-07-18 20:21
Can you maby share your setup? I can't get this working sadly (pyls works for me for some strange reason tho)..
FrozenOnPluto · 2022-07-19 14:36
Bit of a mess, and we'll see if reddit markdown can handle big block of code..
```
(when (skeez/enabled? skeez/feature_lsp_stuff)
;; taking snippets from https://ianyepan.github.io/posts/emacs-ide/
;; LSP itself (with many features disabled to increase performance) ---------------------------
(use-package lsp-mode
:hook ((c-mode ; clangd
c++-mode ; clangd
c-or-c++-mode ; clangd
java-mode ; eclipse-jdtls
js-mode ; ts-ls (tsserver wrapper)
js-jsx-mode ; ts-ls (tsserver wrapper)
typescript-mode ; ts-ls (tsserver wrapper)
python-mode ; pyright
web-mode ; ts-ls/HTML/CSS
) . lsp-deferred)
:commands lsp
:config
(setq lsp-auto-guess-root t)
(setq lsp-log-io t)
(setq lsp-restart 'ignore) ; 'interactive auto-restart ignore
(setq lsp-enable-symbol-highlighting t)
(setq lsp-enable-on-type-formatting nil)
(setq lsp-signature-auto-activate nil)
(setq lsp-signature-render-documentation nil)
(setq lsp-eldoc-hook nil)
(setq lsp-modeline-code-actions-enable nil)
(setq lsp-modeline-diagnostics-enable nil)
(setq lsp-headerline-breadcrumb-enable nil)
(setq lsp-semantic-tokens-enable t)
(setq lsp-enable-folding nil)
(setq lsp-enable-imenu nil) ; when t, works with lsp-ui-imenu, consult-imenu, etc .. just not super useful in my workflow
(setq lsp-enable-snippet t)
(setq read-process-output-max (* 1024 1024)) ;; 1MB
(setq lsp-idle-delay 0.5)
(setq lsp-enable-file-watchers nil) ;; disable watching files all over the workspace - see https://emacs-lsp.github.io/lsp-mode/page/file-watchers/
(setq lsp-enable-suggest-server-download nil) ;; don't offer to download servers all the time
)
;; LSP servers ---------------------------
(use-package lsp-pyright
:hook (python-mode . (lambda () (require 'lsp-pyright)))
:init (when (executable-find "python3")
(setq lsp-pyright-python-executable-cmd "python3")))
;; LSP tramp remotes ---------------------------
(lsp-register-client
(make-lsp-client
:new-connection (lsp-tramp-connection (lambda ()
(cons "pyright-langserver"
lsp-pyright-langserver-command-args)))
:major-modes '(python-mode)
:remote? t
:server-id 'pyright-remote
:multi-root t
:priority 3
:initialization-options (lambda () (ht-merge (lsp-configuration-section "pyright")
(lsp-configuration-section "python")))
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration
(ht-merge (lsp-configuration-section "pyright")
(lsp-configuration-section "python")))))
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'pyright callback error-callback))
:notification-handlers (lsp-ht ("pyright/beginProgress" 'lsp-pyright--begin-progress-callback)
("pyright/reportProgress" 'lsp-pyright--report-progress-callback)
("pyright/endProgress" 'lsp-pyright--end-progress-callback))))
)
```
chrisxsa · 2022-07-19 19:43
Thank you very much for the fast reply, looking forward to trying this out!
chrisxsa · 2022-07-20 15:17
If anyone stumbeles over this in the future: For me, the problem was an outdated nodejs on the remote. The stderr from pyright indicated that for me. I fixed it with: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version