Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect emacs to a remote ensime server

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?

like image 517
Reactormonk Avatar asked Nov 17 '12 23:11

Reactormonk


1 Answers

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))
      )
like image 184
whunmr Avatar answered Sep 29 '22 05:09

whunmr