You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ides/configuring-emacs-tramp.md
+34-3Lines changed: 34 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ To connect to your workspace first run:
8
8
coder config-ssh
9
9
```
10
10
11
-
Then you can connect to your workspace by its name in the format: `coder.<name>`.
11
+
Then you can connect to your workspace by its name in the format: `coder.<WORKSPACE NAME>`.
12
12
13
-
In Emacs type `C-x d` and then input: `/-:coder.<name>:` and hit enter. This will open up Dired on the workspace's home directory.
13
+
In Emacs type `C-x d` and then input: `/-:coder.<WORKSPACE NAME>:` and hit enter. This will open up Dired on the workspace's home directory.
14
14
15
15
### Using SSH
16
16
By default Emacs TRAMP is setup to use SCP to access files on the Coder workspace instance. However you might want to use SSH if you have a jumpbox or some other complex network setup.
@@ -21,7 +21,7 @@ To do so set the following in your Emacs `init.el` file:
21
21
(setq tramp-default-method "ssh")
22
22
```
23
23
24
-
Then when you access the workspace instance via `/-:coder.<name>` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking.
24
+
Then when you access the workspace instance via `/-:coder.<WORKSPACE NAME>` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking.
25
25
26
26
## Directory Tracking
27
27
### `ansi-term`
@@ -72,3 +72,34 @@ To fix this:
72
72
73
73
### `eshell`
74
74
The `eshell` mode will perform directory tracking by default, no additional configuration is needed.
75
+
76
+
## Language Servers (Code Completion)
77
+
If you use [`lsp-mode`](https://emacs-lsp.github.io/lsp-mode) for code intelligence and completion some additional configuration is required.
78
+
79
+
In your Emacs `init.el` file you must register a LSP client and tell `lsp-mode` how to find it on the remote machine using the `lsp-register-client` function. For each LSP server you want to use in your workspace add the following:
80
+
81
+
```lisp
82
+
(lsp-register-client (make-lsp-client :new-connection (lsp-tramp-connection "<LSP SERVER BINARY>")
83
+
:major-modes '(<LANGUAGE MODE>)
84
+
:remote? t
85
+
:server-id 'coder.<WORKSPACE NAME>))
86
+
```
87
+
88
+
This tells `lsp-mode` to look for a language server binary named `<LSP SERVER BINARY>` for use in `<LANGUAGE MODE>` on a machine named `coder.<WORKSPACE NAME>`. Be sure to replace the values between angle brackets:
89
+
90
+
-`<LSP SERVER BINARY>` : The name of the language server binary, without any path components. For example to use the Deno Javascript language server use the value `deno`.
91
+
-`<LANGUAGE MODE>`: The name of the Emacs major mode for which the language server should be used. For example to enable the language server for Javascript development use the value `web-mode`.
92
+
-`<WORKSPACE NAME>`: The name of your coder workspace.
93
+
94
+
Calling the `lsp-register-client` function will tell `lsp-mode` the name of the LSP server binary. However this binary must be accessible via the path. If the language server binary is not in the path you must modify `tramp-remote-path` so that `lsp-mode` knows in what directories to look for the LSP server. To do this use TRAMP's connection profiles functionality. These connection profiles let you customize variables depending on what machine you are connected to. Add the following to your `init.el`:
The `connection-local-set-profile-variables` function creates a new connection profile by the name `remote-path-lsp-servers`. The `connection-local-set-profiles` then indicates this `remote-path-lsp-servers` connection profile should be used when connecting to a server named `coder.<WORKSPACE NAME>`. Be sure to replace `<PATH TO ADD>` with the directory in which a LSP server is present.
103
+
104
+
More details on configuring `lsp-mode` for TRAMP can be found [on the `lsp-mode` documentation](https://emacs-lsp.github.io/lsp-mode/page/remote/).
105
+
The [TRAMP `tramp-remote-path` documentation](https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-programs.html#Remote-programs) contains more examples and details of connection profiles).
0 commit comments