Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRAMP support #30

Open
MagicRB opened this issue Oct 12, 2020 · 1 comment
Open

TRAMP support #30

MagicRB opened this issue Oct 12, 2020 · 1 comment

Comments

@MagicRB
Copy link

MagicRB commented Oct 12, 2020

Describe the bug
lsp-metals doesn't work with projects over TRAMP

To Reproduce
open a .scala file over TRAMP and eval this lisp code

(lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-metals--server-command)
		    :major-modes '(scala-mode)
		    :priority -1
		    :initialization-options '((decorationProvider . t)
					      (didFocusProvider . t)
					      (executeClientCommandProvider . t)
					      (doctorProvider . "html")
					      (statusBarProvider . "on")
					      (debuggingProvider . t)
					      (treeViewProvider . t))
		    :notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command)
					       ("metals/publishDecorations" #'lsp-metals--publish-decorations)
					       ("metals/treeViewDidChange" #'lsp-metals-treeview--did-change)
					       ("metals-model-refresh" #'lsp-metals--model-refresh)
					       ("metals/status" #'lsp-metals--status-string))
		    :action-handlers (ht ("metals-debug-session-start" (-partial #'lsp-metals--debug-start :json-false))
					 ("metals-run-session-start" (-partial #'lsp-metals--debug-start t)))
		    :server-id 'metals
		    :remote? ;; This is what i added
		    :initialized-fn (lambda (workspace)
				      (lsp-metals--add-focus-hooks)
				      (with-lsp-workspace workspace
					(lsp--set-configuration
					 (lsp-configuration-section "metals"))))
		    :after-open-fn (lambda ()
				     (add-hook 'lsp-on-idle-hook #'lsp-metals--did-focus nil t))
		    :completion-in-comments? t))

Expected behavior
lsp-metals should work as if it was running on a local buffer.

Logs

Tramp: Opening connection for [email protected] using ssh...
Tramp: Sending command ‘exec ssh -l main  -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none example.org’
Tramp: Waiting for prompts from remote shell...
Tramp: Sending password
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on 'example.rog’
Tramp: Opening connection for [email protected] using ssh...done
Tramp: Inserting ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’...
Tramp: Encoding remote file ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’ with ‘(env GZIP= gzip <%s | base64)’...done
Tramp: Decoding local file ‘/tmp/tramp.ANFeAZ.scala’ with ‘(lambda (beg end) (base64-decode-region beg end) (let ((coding-system-for-write 'binary) (coding-system-for-read 'binary)) (apply #'tramp-call-process-region '(tramp-file-name ssh main nil example.org nil /home/main/.../AppEntry.scala nil) (point-min) (point-max) (car (split-string env GZIP= gzip -d)) t t nil (cdr (split-string env GZIP= gzip -d)))))’...done
Tramp: Inserting ‘/ssh:[email protected]:/home/main/.../AppEntry.scala’...done
File mode specification error: (wrong-type-argument hash-table-p nil)

Tramp: Checking ‘vc-registered’ for /ssh:[email protected]:/home/main/.../AppEntry.scala...done
File mode specification error: (wrong-type-argument hash-table-p nil)

This log was captured after a initial tramp connection was already established, but after resetting i got just more of the same

Note
I'm sure lsp-metals worked on the remote computer as i just transformed it into a headless workstation

@MagicRB
Copy link
Author

MagicRB commented Nov 3, 2020

I now understand lisp better and with this bit of lisp, TRAMP is fully functional if a bit slow

(lsp-register-client
   (make-lsp-client :new-connection (lsp-tramp-connection 'lsp-metals--server-command)
		    :major-modes '(scala-mode)
		    :priority -1
		    :initialization-options '((decorationProvider . t)
					      (didFocusProvider . t)
					      (executeClientCommandProvider . t)
					      (doctorProvider . "html")
					      (statusBarProvider . "on")
					      (debuggingProvider . t)
					      (treeViewProvider . t))
		    :notification-handlers (ht ("metals/executeClientCommand" #'lsp-metals--execute-client-command)
					       ("metals/publishDecorations" #'lsp-metals--publish-decorations)
					       ("metals/treeViewDidChange" #'lsp-metals-treeview--did-change)
					       ("metals-model-refresh" #'lsp-metals--model-refresh)
					       ("metals/status" #'lsp-metals--status-string))
		    :action-handlers (ht ("metals-debug-session-start" (-partial #'lsp-metals--debug-start :json-false))
					 ("metals-run-session-start" (-partial #'lsp-metals--debug-start t)))
		    :server-id 'metals
		    :remote? t
		    :initialized-fn (lambda (workspace)
				      (lsp-metals--add-focus-hooks)
				      (with-lsp-workspace workspace
					(lsp--set-configuration
					 (lsp-configuration-section "metals"))))
		    :after-open-fn (lambda ()
				     (add-hook 'lsp-on-idle-hook #'lsp-metals--did-focus nil t))
		    :completion-in-comments? t))```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant