Connect emacs to a remote ensime server
Asked Answered
I

1

10

How can I connect to an ensime server on a remote host? My netbook is a bit slow for that kind of stuff. I copied the data over and use tramp to edit the files remotely. I ran bin/server to create the server and an ssh forwarding to be able to connect to it. I use ensime-connect to connect to the port on localhost. The ensime server on the remote server answers with Got connection, creating handler..., but that's about it. Ensime is in [ENSIME: wtf] mode in the emacs status line. How do I fix this?

Inclinatory answered 17/11, 2012 at 23:7 Comment(4)
Do you have the source files in the same directory on the client and on the server?Cons
Not in terms of absolute path, but the same one relative to $HOME.Inclinatory
don't think that will help youCons
The .ensime had absolute paths. I changed them, but I don't know how to point ensime on the remote server to the new conf.Inclinatory
E
3

The problem is the ensime can not find "config" of the connection (made through ensime-connect).

and then following line will throws error:

(if (and loose (ensime-file-in-directory-p file project-root))

because project-root is nil.

By setting the connection to ensime-buffer-connection, the problem can be fixed. try adding following function to your ensime.el

and using the ensime-stackoverflow-connect to connect.

(defun ensime-stackoverflow-connect (host port)
  (interactive (list
        (read-from-minibuffer "Host: " ensime-default-server-host)
        (read-from-minibuffer "Port: " (format "%d" ensime-default-port)
                      nil t)))
  (let ((c (ensime-connect host port))
    (config (ensime-config-load "/Users/whunmr/lab/scala/.ensime")))
    (ensime-set-config c config)
    (setq ensime-buffer-connection c))
  )

remember to change the config path in the code: "/Users/whunmr/lab/scala/.ensime"

EDIT1: the ".ensime" file was created by M-x ensime command, in your scala project folder. actually, by just hardcode the config, you can ignore the file.

(defun ensime-my-connection (host port)
      (interactive (list
            (read-from-minibuffer "Host: " ensime-default-server-host)
            (read-from-minibuffer "Port: " (format "%d" ensime-default-port)
                          nil t)))
      (let ((c (ensime-connect host port))
        (config '(:project-name "test" :project-package "com.whunmr" :sources ("./src") :compile-jars ("./" "../../apps/scala/lib/") :target "./bin" :root-dir "/Users/twer/lab/scala/")))
        (ensime-set-config c config)
        (setq ensime-buffer-connection c))
      )
Eponymy answered 4/12, 2012 at 17:15 Comment(6)
How do I generate the config file / what goes in there?Inclinatory
hi @Tass, see the EDIT1 for your question.Eponymy
Wouldn't it be possible to partially read the config from e.g. the tramp connection?Inclinatory
I think it can be read through tramp connection. just specify your .ensime url like "<name>@<ip>:/Users/...<path>.../.ensime"Eponymy
try first open the .ensime file through tramp mode. then connect. to see if it will read properly. if it not works, i think, need hard code the config.Eponymy
let us continue this discussion in chatInclinatory

© 2022 - 2024 — McMap. All rights reserved.