Install Doom Emacs as explained in the readme.
Alongside it, you’ll want to install ripgrep and fd for better
search integration, and possibly ttf-font-awesome for better icons.
Configuration Link to heading
Instead of the default ~/emacs.d/ and ~/doom.d/ config directories,
you can also use ~/.config/emacs/ and ~/.config/doom/.
init.el Link to heading
My init.el is mostly default, and enables the languages I regularly
use, with LSP support where possible:
| |
Note that some of these need additional programs to be installed, like
clangd for C++, black for Python formatting, and prettier for more
formatting.
I use the treemacs project drawer, and (ivy +icons +prescient) for
searching. Add +fuzzy for fuzzy searching. (I found it too fuzzy for
my taste.)
For git integration, magit is great.
To install additional packages from MELPA, add them to packages.el:
| |
config.el Link to heading
Some highlights from my config.el. (Remember, SPC f p quickly opens
files in your emacs config directory.)
Always keep 10 lines of buffer above/below the cursor:
(setq scroll-margin 10)Save buffer and exit insert mode on focus loss
1 2 3 4;; Auto save buffers on focus lost (add-function :after after-focus-change-function (lambda () (save-some-buffers t))) ;; Exit insert mode on focus loss (add-function :after after-focus-change-function (lambda () (evil-normal-state)))Improve default C++ indenting to be more in line with the LSP/clang-format auto formatting
1 2 3 4 5; Better default indent style (setq c-default-style "user") ; disable indenting namespaces ; https://brrian.tumblr.com/post/9018043954/emacs-fu-dont-indent-inside-of-c-namespaces (c-set-offset 'innamespace 0)There is a bug currently where LSP provided formatting does not work. This is the workaround.
1 2 3; Use clang-format instead of the lsp provided formatter, which doesn't appear to work. ; https://github.com/hlissner/doom-emacs/issues/1652 (setq +format-with-lsp nil)Unlike Vim, Emacs treats
_as a word separator. To still be able to quickly jump over them, we can rebind the word-based motions to be symbol-based motions instead:1 2; https://github.com/syl20bnr/spacemacs/issues/9740 (with-eval-after-load 'evil (defalias #'forward-evil-word #'forward-evil-symbol))
Running as server and client Link to heading
Emacs can run in server client mode by using a systemd unit. The ArchWiki explains how.
Note that when changing the configuration, doom/reload is not always
sufficient. Restarting the server using systemctl --user restart emacs
is usually necessary.
Wayland Link to heading
I’m using the
emacs-gcc-wayland-devel-bin
AUR package, based on
this git
repo. After installing this, set the GDK_BACKEND=wayland environment
variable and you should be good to go.
Useful commands Link to heading
SPC p pto switch projectSPC SPCto switch file within projectSPC :search and execute a command (alternative forM-x) Whenever you are looking for some functionality, this is a great way to discover it. It also shows which keys are already bound to the command, if any.SPC f popen emacs config fileSPC g gto open Magit?show keybindingssstage filesc ccommitC-c C-cconfirm commitC-c C-kabort commit
SPC TAB 1-9switch workspaceSPC TAB .switch workspace by nameSPC o ptoggle treemacs?show keybindingsC-?show more keybindings- create file/dir:
c fc d - rename:
R