From 3bddcf21a7c5f4fab3513074f055e6c1ef46b8b4 Mon Sep 17 00:00:00 2001 From: noah Date: Tue, 26 Jul 2022 20:17:40 +0000 Subject: [PATCH 01/12] docs: added emacs notes --- docs/ides.md | 1 + docs/ides/configuring-emacs-tramp.md | 55 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/ides/configuring-emacs-tramp.md diff --git a/docs/ides.md b/docs/ides.md index e835aa804a4a0..716306b01bbc6 100644 --- a/docs/ides.md +++ b/docs/ides.md @@ -18,6 +18,7 @@ support should work: - WebStorm - Web IDEs (code-server, JupyterLab, Jetbrains Projector) - Note: These are [configured in the template](./ides/configuring-web-ides.md) +- Emacs (with [TRAMP](./ides/configuring-emacs-tramp.md)) ## SSH configuration diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md new file mode 100644 index 0000000000000..6a56a93525eaa --- /dev/null +++ b/docs/ides/configuring-emacs-tramp.md @@ -0,0 +1,55 @@ +# Configuring Emacs TRAMP +[Emacs TRAMP](https://www.emacswiki.org/emacs/TrampMode) is a method of running editing operations on a remote server. + +## Connecting To A Workspace +To connect to your workspace first run: + +``` +coder config-ssh +``` + +Then you can connect to your workspace by its name in the format: `coder.`. + +In Emacs type `C-x d` and then input: `/ssh:coder.:` and hit enter. This will open up Dired on the workspace's home directory. + +## Directory Tracking +### `ansi-term` +If you run your terminal in Emacs via `ansi-term` then you might run into a problem where while SSH-ed into a workspace Emacs will not change its `default-directory` to open files in the directory your shell is in. + +To fix this: + +1. In your Emacs `init.el` file add: + ```lisp + (setq tramp-default-method "ssh") + ``` +2. Be sure to set the hostname on the workspace to the `coder.` format: + ```bash + hostname coder. + ``` +3. Next in the shell profile file on the workspace (ex., `~/.bashrc`) add the following: + ```bash + ansi_term_announce_host() { + printf '\033AnSiTh %s\n' "$(hostname)" + } + + ansi_term_announce_user() { + printf '\033AnSiTu %s\n' "$USER" + } + + ansi_term_announce_pwd() { + printf '\033AnSiTc %s\n' "$PWD" + } + + ansi_term_announce() { + ansi_term_announce_host + ansi_term_announce_user + ansi_term_announce_pwd + } + + cd() { command cd "$@"; ansi_term_announce_pwd; } + pushd() { command pushd "$@"; ansi_term_announce_pwd; } + popd() { command popd "$@"; ansi_term_announce_pwd; } + + ansi_term_announce + ``` + Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. From a0e965a2816844ff18a92ea09b6f19253ca956a5 Mon Sep 17 00:00:00 2001 From: noah Date: Wed, 27 Jul 2022 13:14:14 +0000 Subject: [PATCH 02/12] docs: revised emacs tramp docs --- docs/ides/configuring-emacs-tramp.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index 6a56a93525eaa..142611cde422b 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -22,10 +22,11 @@ To fix this: ```lisp (setq tramp-default-method "ssh") ``` -2. Be sure to set the hostname on the workspace to the `coder.` format: +2. Then on your Coder workspace instance be sure to set the hostname to the `coder.` format: ```bash hostname coder. ``` + This can also be done in the workspace Terraform template by setting workspace isntance's hostname to the data `coder_workspace.name` attribute. How this is done depends on how the instance is provisioned. 3. Next in the shell profile file on the workspace (ex., `~/.bashrc`) add the following: ```bash ansi_term_announce_host() { @@ -52,4 +53,4 @@ To fix this: ansi_term_announce ``` - Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. + Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. The expression in step 1 lets Emacs know that you are accessing the hostname these escape codes announce via SSH. From 7b917e831e352737daf45b2e58f90f9e6858701c Mon Sep 17 00:00:00 2001 From: noah Date: Wed, 27 Jul 2022 13:21:04 +0000 Subject: [PATCH 03/12] docs: typo --- docs/ides/configuring-emacs-tramp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index 142611cde422b..90f3b09a1439b 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -26,7 +26,7 @@ To fix this: ```bash hostname coder. ``` - This can also be done in the workspace Terraform template by setting workspace isntance's hostname to the data `coder_workspace.name` attribute. How this is done depends on how the instance is provisioned. + This can also be done in the workspace Terraform template by setting workspace instance's hostname to the data `coder_workspace.name` attribute. How this is done depends on how the instance is provisioned. 3. Next in the shell profile file on the workspace (ex., `~/.bashrc`) add the following: ```bash ansi_term_announce_host() { From c72ebeb2f4a7f548c6ddc37aad62e1246ce778f5 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 27 Jul 2022 13:57:00 +0000 Subject: [PATCH 04/12] add to manifest --- docs/manifest.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/manifest.json b/docs/manifest.json index a9f4ee7bed44b..f3441af5c90ab 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -32,7 +32,7 @@ "title": "GitHub OAuth", "description": "Learn how to set up OAuth using your GitHub organization.", "path": "./install/oauth.md" - } + } ] }, { @@ -84,6 +84,11 @@ "title": "Configuring Web IDEs", "description": "Learn how to configure web IDEs in your templates", "path": "./ides/configuring-web-ides.md" + }, + { + "title": "Configuring Emacs (with TRAMP)", + "description": "Learn how to configure Emacs in Coder", + "path": "./ides/configuring-emacs-tramp.md" } ] }, From c28a743cea659d8c7d9767df791ebd790561ffdd Mon Sep 17 00:00:00 2001 From: noah Date: Thu, 28 Jul 2022 16:12:00 +0000 Subject: [PATCH 05/12] docs: Updated Emacs tips with code review --- docs/ides/configuring-emacs-tramp.md | 42 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index 90f3b09a1439b..b4bfae7134529 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -10,7 +10,18 @@ coder config-ssh Then you can connect to your workspace by its name in the format: `coder.`. -In Emacs type `C-x d` and then input: `/ssh:coder.:` and hit enter. This will open up Dired on the workspace's home directory. +In Emacs type `C-x d` and then input: `/-:coder.:` and hit enter. This will open up Dired on the workspace's home directory. + +### Using SSH +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. + +To do so set the following in your Emacs `init.el` file: + +```lisp +(setq tramp-default-method "ssh") +``` + +Then when you access the workspace instance via `/-:coder.` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking. ## Directory Tracking ### `ansi-term` @@ -18,19 +29,23 @@ If you run your terminal in Emacs via `ansi-term` then you might run into a prob To fix this: -1. In your Emacs `init.el` file add: - ```lisp - (setq tramp-default-method "ssh") - ``` -2. Then on your Coder workspace instance be sure to set the hostname to the `coder.` format: - ```bash - hostname coder. +1. In your workspace Terraform template be sure to add the following: + ```hcl + data "coder_workspace" "me" { + } + + resource "coder_agent" "main" { + # ... + env { + name = "CODER_WORKSPACE_NAME" + value = data.coder_workspace.me.name + } + } ``` - This can also be done in the workspace Terraform template by setting workspace instance's hostname to the data `coder_workspace.name` attribute. How this is done depends on how the instance is provisioned. -3. Next in the shell profile file on the workspace (ex., `~/.bashrc`) add the following: +2. Next in the shell profile file on the workspace (ex., `~/.bashrc` for Bash and `~/.zshrc` for Zsh) add the following: ```bash ansi_term_announce_host() { - printf '\033AnSiTh %s\n' "$(hostname)" + printf '\033AnSiTh %s\n' "coder.$CODER_WORKSPACE_NAME" } ansi_term_announce_user() { @@ -53,4 +68,7 @@ To fix this: ansi_term_announce ``` - Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. The expression in step 1 lets Emacs know that you are accessing the hostname these escape codes announce via SSH. + Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. + +### `eshell` +The `eshell` mode will perform directory tracking by default, no additional configuration is needed. From 5ffd98df72d8c540aa1b3cc1b2bcfffd737b55a4 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 28 Jul 2022 20:51:48 +0000 Subject: [PATCH 06/12] docs: described lsp-mode configuration --- docs/ides/configuring-emacs-tramp.md | 37 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index b4bfae7134529..ce2c67eb14389 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -8,9 +8,9 @@ To connect to your workspace first run: coder config-ssh ``` -Then you can connect to your workspace by its name in the format: `coder.`. +Then you can connect to your workspace by its name in the format: `coder.`. -In Emacs type `C-x d` and then input: `/-:coder.:` and hit enter. This will open up Dired on the workspace's home directory. +In Emacs type `C-x d` and then input: `/-:coder.:` and hit enter. This will open up Dired on the workspace's home directory. ### Using SSH 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: (setq tramp-default-method "ssh") ``` -Then when you access the workspace instance via `/-:coder.` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking. +Then when you access the workspace instance via `/-:coder.` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking. ## Directory Tracking ### `ansi-term` @@ -72,3 +72,34 @@ To fix this: ### `eshell` The `eshell` mode will perform directory tracking by default, no additional configuration is needed. + +## Language Servers (Code Completion) +If you use [`lsp-mode`](https://emacs-lsp.github.io/lsp-mode) for code intelligence and completion some additional configuration is required. + +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: + +```lisp +(lsp-register-client (make-lsp-client :new-connection (lsp-tramp-connection "") + :major-modes '() + :remote? t + :server-id 'coder.)) +``` + +This tells `lsp-mode` to look for a language server binary named `` for use in `` on a machine named `coder.`. Be sure to replace the values between angle brackets: + +- `` : The name of the language server binary, without any path components. For example to use the Deno Javascript language server use the value `deno`. +- ``: 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`. +- ``: The name of your coder workspace. + +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`: + +```lisp +(connection-local-set-profile-variables 'remote-path-lsp-servers + '((tramp-remote-path . ("" tramp-default-remote-path)))) +(connection-local-set-profiles '(:machine "coder.") 'remote-path-lsp-servers) +``` + +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.`. Be sure to replace `` with the directory in which a LSP server is present. + +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/). +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). From 46dd08828d5165b962fc7f3de324cbc48dcee279 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 28 Jul 2022 23:09:22 +0000 Subject: [PATCH 07/12] docs: typo --- docs/ides/configuring-emacs-tramp.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index ce2c67eb14389..360024ca4b6c6 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -101,5 +101,5 @@ Calling the `lsp-register-client` function will tell `lsp-mode` the name of the 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.`. Be sure to replace `` with the directory in which a LSP server is present. -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/). -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). +More details on configuring `lsp-mode` for TRAMP can be found [in the `lsp-mode` documentation](https://emacs-lsp.github.io/lsp-mode/page/remote/). +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. From 1366275b90c4c611fb279df4d5b746bbebfe5656 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 29 Jul 2022 17:45:04 +0000 Subject: [PATCH 08/12] docs: updated emacs docs with lsp server-id --- docs/ides/configuring-emacs-tramp.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index 360024ca4b6c6..0b973d914cb9e 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -82,14 +82,14 @@ In your Emacs `init.el` file you must register a LSP client and tell `lsp-mode` (lsp-register-client (make-lsp-client :new-connection (lsp-tramp-connection "") :major-modes '() :remote? t - :server-id 'coder.)) + :server-id ')) ``` This tells `lsp-mode` to look for a language server binary named `` for use in `` on a machine named `coder.`. Be sure to replace the values between angle brackets: - `` : The name of the language server binary, without any path components. For example to use the Deno Javascript language server use the value `deno`. - ``: 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`. -- ``: The name of your coder workspace. +- ``: The ID that `lsp-mode` uses to identify the language server, often this is the name of the language server binary, but not always. A good way to find this ID is to find variables starting with `lsp-clients-`. For each language server `lsp-mode` knows about there will be a series of variables like `lsp-clients--server`, `lsp-clients--server-args`, ect. To find these variables use the variable help function built into Emacs via `C-h v` and start typing `lsp-clients-` and then hit `TAB`. Emacs will autocomplete with the available variables. Start typing in the name of the language server binary and see if there are any variables which match. If you can't find any results also try the name of the language and its abbreviation. Sometimes the [`lsp-mode` languages docs](https://emacs-lsp.github.io/lsp-mode/page/languages/) page for a specific language server will also list the ID or at least the variables discussed earlier. It is important that you do not make this language server ID up, as `lsp-mode` might have specific configuration it needs to access by this ID in order to run the language server properly. 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`: From d7b18bc4eb24274e35246598f9d3b4a9bb1beeb9 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 29 Jul 2022 17:58:41 +0000 Subject: [PATCH 09/12] docs: fixed emacs lsp mode server id --- docs/ides/configuring-emacs-tramp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index 0b973d914cb9e..a3d0ea2b4bdeb 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -89,7 +89,7 @@ This tells `lsp-mode` to look for a language server binary named `` : The name of the language server binary, without any path components. For example to use the Deno Javascript language server use the value `deno`. - ``: 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`. -- ``: The ID that `lsp-mode` uses to identify the language server, often this is the name of the language server binary, but not always. A good way to find this ID is to find variables starting with `lsp-clients-`. For each language server `lsp-mode` knows about there will be a series of variables like `lsp-clients--server`, `lsp-clients--server-args`, ect. To find these variables use the variable help function built into Emacs via `C-h v` and start typing `lsp-clients-` and then hit `TAB`. Emacs will autocomplete with the available variables. Start typing in the name of the language server binary and see if there are any variables which match. If you can't find any results also try the name of the language and its abbreviation. Sometimes the [`lsp-mode` languages docs](https://emacs-lsp.github.io/lsp-mode/page/languages/) page for a specific language server will also list the ID or at least the variables discussed earlier. It is important that you do not make this language server ID up, as `lsp-mode` might have specific configuration it needs to access by this ID in order to run the language server properly. +- ``: This is just the name that `lsp-mode` will use to refer to this language server. If you are ever looking for output buffers or files they may have this name in them. 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`: From bcdd06f40af4beb656af071129c32f66c8ed5f3d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 29 Jul 2022 18:26:03 +0000 Subject: [PATCH 10/12] docs: updated emacs tramp lsp --- docs/ides/configuring-emacs-tramp.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index a3d0ea2b4bdeb..c57d3efbe8464 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -101,5 +101,7 @@ Calling the `lsp-register-client` function will tell `lsp-mode` the name of the 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.`. Be sure to replace `` with the directory in which a LSP server is present. +TRAMP and `lsp-mode` are fickle friends, sometimes there is weird behavior. If you find that language servers are hanging in the `starting` state then [it might be helpful](https://github.com/emacs-lsp/lsp-mode/issues/2709#issuecomment-800868919) to set the `lsp-log-io` variable to `t`. + More details on configuring `lsp-mode` for TRAMP can be found [in the `lsp-mode` documentation](https://emacs-lsp.github.io/lsp-mode/page/remote/). 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. From a2fda46f2a35daae6886ac2edf42416aefb59cbb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 1 Aug 2022 19:24:51 +0000 Subject: [PATCH 11/12] patch --- docs/ides.md | 7 +++---- docs/ides/configuring-emacs-tramp.md | 15 +++++++++++++-- docs/manifest.json | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/ides.md b/docs/ides.md index 716306b01bbc6..db7f43298da31 100644 --- a/docs/ides.md +++ b/docs/ides.md @@ -17,8 +17,8 @@ support should work: - RubyMine - WebStorm - Web IDEs (code-server, JupyterLab, Jetbrains Projector) - - Note: These are [configured in the template](./ides/configuring-web-ides.md) -- Emacs (with [TRAMP](./ides/configuring-emacs-tramp.md)) + - Note: These are [configured in the template](./ides/configuring-web-ides.md) +- [Emacs](./ides/configuring-emacs-tramp.md) ## SSH configuration @@ -90,12 +90,11 @@ After installing Gateway on your local system, you may connect to a Coder worksp 8. Click "Download and Start IDE" to connect. | Version | Status | Notes | -|-----------|-------------|------------------------------------------------------------| +| --------- | ----------- | ---------------------------------------------------------- | | 2021.3.2 | Working | | | 2022.1.1 | Working | Windows clients are unable to connect to Linux workspace | | 2022.2 RC | Not working | [GitHub Issue](https://github.com/coder/coder/issues/3125) | - ## Web IDEs (Jupyter, code-server, Jetbrains Projector) Web IDEs (code-server, JetBrains Projector, VNC, etc.) are defined in the template. See [configuring IDEs](./ides/configuring-web-ides.md). diff --git a/docs/ides/configuring-emacs-tramp.md b/docs/ides/configuring-emacs-tramp.md index c57d3efbe8464..7264765ba8430 100644 --- a/docs/ides/configuring-emacs-tramp.md +++ b/docs/ides/configuring-emacs-tramp.md @@ -1,7 +1,9 @@ # Configuring Emacs TRAMP + [Emacs TRAMP](https://www.emacswiki.org/emacs/TrampMode) is a method of running editing operations on a remote server. ## Connecting To A Workspace + To connect to your workspace first run: ``` @@ -13,6 +15,7 @@ Then you can connect to your workspace by its name in the format: `coder.:` and hit enter. This will open up Dired on the workspace's home directory. ### Using SSH + 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. To do so set the following in your Emacs `init.el` file: @@ -24,12 +27,15 @@ To do so set the following in your Emacs `init.el` file: Then when you access the workspace instance via `/-:coder.` Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term` mode the correct way to access the remote when directory tracking. ## Directory Tracking -### `ansi-term` + +### ansi-term + If you run your terminal in Emacs via `ansi-term` then you might run into a problem where while SSH-ed into a workspace Emacs will not change its `default-directory` to open files in the directory your shell is in. To fix this: 1. In your workspace Terraform template be sure to add the following: + ```hcl data "coder_workspace" "me" { } @@ -42,7 +48,9 @@ To fix this: } } ``` + 2. Next in the shell profile file on the workspace (ex., `~/.bashrc` for Bash and `~/.zshrc` for Zsh) add the following: + ```bash ansi_term_announce_host() { printf '\033AnSiTh %s\n' "coder.$CODER_WORKSPACE_NAME" @@ -68,12 +76,15 @@ To fix this: ansi_term_announce ``` + Ansi Term expects the terminal running inside of it to send escape codes to inform Emacs of the hostname, user, and working directory. The above code sends these escape codes and associated data whenever the terminal logs in and whenever the directory changes. -### `eshell` +### eshell + The `eshell` mode will perform directory tracking by default, no additional configuration is needed. ## Language Servers (Code Completion) + If you use [`lsp-mode`](https://emacs-lsp.github.io/lsp-mode) for code intelligence and completion some additional configuration is required. 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: diff --git a/docs/manifest.json b/docs/manifest.json index f3441af5c90ab..5cde6f16f5e7a 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -86,8 +86,8 @@ "path": "./ides/configuring-web-ides.md" }, { - "title": "Configuring Emacs (with TRAMP)", - "description": "Learn how to configure Emacs in Coder", + "title": "Configuring Emacs", + "description": "Learn how to configure Emacs with TRAMP in Coder", "path": "./ides/configuring-emacs-tramp.md" } ] From 57ad949f049331665947f6c53f328e5d388cc701 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Mon, 1 Aug 2022 15:55:02 -0500 Subject: [PATCH 12/12] Update docs/ides.md --- docs/ides.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ides.md b/docs/ides.md index e4a2ffbc131a5..9fd570db940be 100644 --- a/docs/ides.md +++ b/docs/ides.md @@ -12,7 +12,7 @@ support should work: - Rider - RubyMine - WebStorm -- Web IDEs (code-server, JupyterLab, Jetbrains Projector) +- Web IDEs (code-server, JupyterLab, JetBrains Projector) - Note: These are [configured in the template](./ides/configuring-web-ides.md) - [Emacs](./ides/configuring-emacs-tramp.md)