-
Notifications
You must be signed in to change notification settings - Fork 889
Added Emacs Tips Documentation #3247
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3bddcf2
docs: added emacs notes
Mainstay-Noah-Huppert a0e965a
docs: revised emacs tramp docs
Mainstay-Noah-Huppert 7b917e8
docs: typo
Mainstay-Noah-Huppert c72ebeb
add to manifest
bpmct c28a743
docs: Updated Emacs tips with code review
Mainstay-Noah-Huppert 338cf1c
Merge branch 'main' of github.com:Mainstay-Noah-Huppert/coder into main
Mainstay-Noah-Huppert 5ffd98d
docs: described lsp-mode configuration
46dd088
docs: typo
1366275
docs: updated emacs docs with lsp server-id
d7b18bc
docs: fixed emacs lsp mode server id
bcdd06f
docs: updated emacs tramp lsp
a2fda46
patch
4b2770a
Merge branch 'main' into main
Mainstay-Noah-Huppert 57ad949
Update docs/ides.md
ammario File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# 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.<name>`. | ||
|
||
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. | ||
|
||
### 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.<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. | ||
|
||
## 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 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 | ||
} | ||
} | ||
``` | ||
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" | ||
} | ||
|
||
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. | ||
|
||
### `eshell` | ||
The `eshell` mode will perform directory tracking by default, no additional configuration is needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.