/emacs-config

My emacs config :3

Primary LanguageEmacs Lisp

Emacs Avoc

This is my Emacs configuration file. I’ve started a long time ago and I still making it changes from time to time. There are some things that work well, and others that don’t even work (sorry :P). But, the main idea of this file is to have a working, configured Emacs by just cloning the repository and let the init.el do its work. No extra configuration or package download is required to make it work (or, at least, that’s the objective).

This configuration only supports the version of Emacs I typically use, which in this case is Emacs 29.

Table of Contents

Installing

Just clone the repository and its submodules into the .emacs.d config folder. Make sure that this folder does not previously exist or it’s empty:

git clone --recursive https://github.com/devcexx/emacs-config ~/.emacs.d

Are you on Windows?

Well, that’s your problem.

macOS support

I daily use a macOS laptop for work, so macOS support is provided.

Features

Platform support

The configuration supports windowed and tty-based Emacs. Emacs client is not supported.

Run modes

This configuration allows to enable and disable emacs features based on its purpose. If you are gonna use it as main editor, you may start Emacs normally. However, if you’re gonna use it for editing a single file or in a remote server, the modes “spot” and “light” are provided. These modes enables or disables features so Emacs can run on a more lightweight way based on what you’re gonna do with it. The run mode can be set by setting the environment variable EMACS_RUN_MODE.

Open In Emacs

This feature is only supported in Linux and it requires dbus to be operative. It allows you to run a command to open a file directly in the already opened Emacs instance, so you can navigate through your filesystem and open files in a same Emacs instance (since Emacsclient is not supported). For using it, put the bin/ folder of this repository into your PATH and execute the command oie in your terminal with the path to the file to open.

Terminal Clip

This feature provides clipboard support to Emacs when running from terminal. Since when Emacs starts from the terminal completely disables X support, it also disables clipboard integration, which can be painful if you typically use Emacs from the terminal. Support for clipboard is provided through terminal-clip.el library. Integration in this config file allows to automatically build the native libraries required.

Theme

The theme chosen is Doom-Iosvkem.

Modeline

The modeline used is powered by doom-modeline.

Line numbers

Line number support is provided by the display-line-numbers-mode feature. Some extra tweaks have been done for preventing glitches on the width of the line number width.

Programming languages

Syntax highlighting is supported through Tree-Sitter. The configuration will automatically clone and compile all the tree-sitter modules required for syntax highlighting.

LSP support is provided through Eglot. Additionally, error highlighting is provided by FlyMake and completion by Company. Automatic initialization of Eglot is disabled, so you’ll need to type M-x eglot for starting it. This is intended for preventing starting a heavy LSP application for performing spot changes on files not included in any project.

The following languages are supported out-of-the-box (although you’ll need to set up their own LSPs in your system before using them):

  • C
  • C++
  • CMake
  • Toml
  • CSS
  • HTML
  • JavaScript
  • JSON
  • LaTeX
  • Python
  • Ruby
  • Rust
  • Shell Scripts
  • SQL
  • TypeScript / TSX

Git

Git support is provided through Magit and Git-Gutter.

Projects

Project support is provided through Projectile and Treemacs.

Discord integration

Integration with discord is provided through Elcord, that will allow to show Emacs in your current Discord status.

Minibuffer lock

Minibuffer lock is a global minor mode that allows you to focus on the minibuffer when it is opened for typing. It prevents that the minibuffer focus is lost if it is still waiting for an input, and emits acoustic and visual effects for grabbing your attention to it.

Icons

All The Icons and Nerd Icons are supported. The configuration will automatically download and install the fonts if it detects they’re missing from the system.

Cheatsheet

Basics

ActionKeybindingCommandNotes
Select left windowS-<left>windmove-left
Select right windowS-<right>windmove-right
Select window aboveS-<up>windmove-up
Select window belowS-<down>windmove-down
Swap left windowC-S-<left>buf-move-leftSwap the position of the current selected window with the window on the left
Swap right windowC-S-<right>buf-move-rightSwap the position of the current selected window with the window on the right
Swap window aboveC-S-<up>buf-move-upSwap the position of the current selected window with the window above
Swap window belowC-S-<down>buf-move-downSwap the position of the current selected window with the window below

File navigation / basic edition

ActionKeybindingCommandNotes
Go to the end of fileM->; C-x ]; <home>beginning-of-buffer
Go to the beginning of fileM-<; C-x [; <end>end-of-buffer
Go to the beginning of the current sexpC-c [sp-beginning-of-sexp
Activate / Deactivate markC-SPCset-mark-command
Activate and deactivate mark, at onceC-S-Lset-mark-command; set-mark-command
Pop markC-u C-SPC
Pop global markC-x C-SPCpop-global-mark
Delete lineC-kavoc-text-utils-delete-current-lineThis command differs from kill-line in that the line is not copied into the kill ring.
Kill lineM-kkill-line
Kill previous wordM-<backspace>backward-kill-word
Kill wordM-<delete>kill-word
Duplicate lineC-c navoc-text-utils-duplicate-lineUniversal argument can be used to determine number of times the line will be copied. Key n can be pressed more times after the command for keeping duplicating the line

Coding

ActionKeybindingCommandNotes
LSP: RenameC-c e r ]eglot-rename
LSP: Apply code actionsC-c e aeglot-code-actions
Show Eldoc bufferC-c e deldoc-doc-buffer
Open MagitC-x v vmagit-status
Open auto completeC-c SPC; C-c C-SPCcompany-complete
Comment lineM-;comment-line
Comment dwimC-x ;comment-dwim
Comment set columnC-x M-;comment-set-column
Flymake goto next errorC-c f nflymake-goto-next-error
Flymake goto previous errorC-c f pflymake-goto-previous-error
Goto next TODOC-c C-t nhl-todo-nextSupported keywords: TODO, FIXME, DEBUG, GOTCHA, STUB
Goto previous TODOC-c C-t phl-todo-previousSupported keywords: TODO, FIXME, DEBUG, GOTCHA, STUB
List all the TODO keywordsC-c C-t ohl-todo-occurSupported keywords: TODO, FIXME, DEBUG, GOTCHA, STUB
Insert TODO keywordC-c C-t ihl-todo-insertSupported keywords: TODO, FIXME, DEBUG, GOTCHA, STUB
Find referencesM-.xref-find-references
XRef go backM-,xref-go-back
Goto next git modified hunkC-x v ngit-gutter:next-hunk
Goto previous git modified hunkC-x v pgit-gutter:previous-hunk
Go to the end of the current sexpC-c ]sp-end-of-sexp
Go to the beginning of the next sexpC-c {sp-beginning-of-next-sexp
Go to the beginning of the previous sexpC-c }sp-beginning-of-previous-sexp
Unwrap current sexpC-c M-{sp-unwrap-sexp
Unwrap previous sexpC-c M-}sp-backward-unwrap-sexp

Project management

ActionKeybindingCommandNotes
Add project to Treemacs current worksplaceC-x p atreemacs-add-project
Open project fileC-x p phelm-projectile
Switch projectC-x p Phelm-projectile-switch-project
Kill non-project buffersC-x p M-kprojectile-kill-non-project-buffers
Toggle Treemacs open<f8>treemacs
Find current file in TreemacsC-c t ltreemacs-find-file
[Treemacs] Remove project from worksplaceC-c C-p dtreemacs-remove-project-from-worksplace
[Treemacs] New filec ftreemacs-create-file
[Treemacs] New folderc dtreemacs-create-dir
[Treemacs] Rename fileRtreemacs-rename-file
[Treemacs] Expand/Collapse nodeTABtreemacs-TAB-action
[Treemacs] Open file with vertical splito vtreemacs-visit-node-vertical-split
[Treemacs] Open file with horizontal splito htreemacs-visit-node-horizontal-split

Misc

ActionKeybindingCommandNotes
Kill all buffersC-x C-kclean-buffers
Profiler startC-x & ,profiler-start
Profiler stop & reportC-x & .profiler-stop; profiler-report
Open terminalC-x tmulti-term-dedicated-open