Skip to content

daviskirk/.doom.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doom Emacs Configuration

Introduction

Welcome to my Doom Emacs configuration. Feel free to look around and copy whatever looks interesting to you.

  • The current file is rendered out to config.el when running `doom sync` (or `doom/reload` inside email)
  • Activated modules can bee seen in init.el
  • Any additional packages that are needed can be seen in packages.el.

Configuration

Personal Information

Used for a number of things, particularly for GPG configuration, some email clients, file templates and snippets.

(setq user-full-name "Davis Kirkendall"
      user-mail-address "davis.e.kirkendall@gmail.com")

Appearance

Doom exposes five (optional) variables for controlling fonts in Doom. Here are the three important ones:

  • `doom-font’
  • `doom-variable-pitch-font’
  • `doom-big-font’ – used for `doom-big-font-mode’

They all accept either a font-spec, font string (“Input Mono-12”), or xlfd font string. You generally only need these two:

(setq doom-font (font-spec :family "Fira Code" :size 16))

There are two ways to load a theme. Both assume the theme is installed and available. You can either set `doom-theme’ or manually load a theme with the `load-theme’ function. These are the defaults.

(setq doom-theme 'doom-one)

Set default org directory

(setq org-directory "~/org/")

If you want to change the style of line numbers, change this to `relative’ or `nil’ to disable it:

(setq display-line-numbers-type t)

We want emacs to start in full screen mode so we change that here:

(add-to-list 'default-frame-alist '(fullscreen . maximized))

Navigation

When we want to split a window, it’s more intuitive when the new window is on the bottom (if horizontal) and on the right (if vertical). This is how every other editor works so we’d like Emacs to do the same.

(setq evil-split-window-below t
      evil-vsplit-window-right t)

By default, an “undo” undoes everything in an insert-mode session. potentially that can be a lot of stuff. Instead we want to undo step by step (like in normal Emacs).

; (setq evil-want-fine-undo t)

Interacting with shell

Guake is a dropdown terminal and switching to guake from emacs in the current directory is pretty helpful if you don’t want to use the shells in Emacs.

(defun sd ()
  "Switch to current directory by creating new window in guake."
  (interactive)
  ;; (concat "echo " "'" (file-name-directory (buffer-file-name)) "' > ~/.ld" )
  (shell-command (concat "echo " "'" default-directory "' > ~/.ld" ))
  (shell-command (concat "guake --new-tab=" default-directory))
  (shell-command (concat "guake -r " (file-name-nondirectory
                                      (directory-file-name default-directory))))
  (shell-command "guake --show")
  )

Interacting with files

Revert files automatically when they’ve changed on disk. This is especially useful if you’re editing the file in a different editor at the same time (yes, there are other editors), or running scripts that change/format the file.

(global-auto-revert-mode 1)
(setq auto-revert-verbose nil)

Autosaving is standard in most other environments nowadays so it’s best not to have this different here as we might forget to save sometimes.

(use-package super-save
  :config
  (add-to-list 'super-save-hook-triggers 'find-file-hook)
  (setq super-save-remote-files nil)
  (setq super-save-exclude '(".gpg", ".pyc", ".elc"))
  (setq super-save-auto-save-when-idle t)
  (setq auto-save-default nil)
  (super-save-mode +1))

Delete trailing whitespace on save.

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Python

I use the conda package manager a lot, so we need to configure dooms builtin conda support.

(after! conda
  (setq conda-anaconda-home "~/anaconda")
  (conda-env-autoactivate-mode t)
  (setq-default conda-project-env-name nil))

Using dooms builtin support doesn’t activate the current conda environment correctly, so we do it ourselves (+lsp option turned of in python module). Note that the Microsoft language server might be faster, but does not support custom flake8/mypy linting so we use the python language server instead.

(after! python
  (add-hook 'python-mode-local-vars-hook (lambda ()
                                           (conda-env-activate-for-buffer)
                                           (lsp!)))
  (setq lsp-pyls-plugins-flake8-enabled t)
  (setq lsp-pyls-plugins-pylint-enabled nil)
  (setq lsp-pyls-plugins-pycodestyle-enabled nil)
  (setq lsp-pyls-plugins-pyflakes-enabled nil))

In order for this to work we need to install a bunch of stuff in the conda environment so I added a custom function for that as well in case I’m ever in a new environment and they haven’t been installed yet.

(after! conda
  (defun dek/install-lsp ()
    "Install conda packages needed for lsp/linting/completion support."
    (interactive)
    (if conda-env-current-name
      (async-shell-command
       "conda install python-language-server mypy black isort flake8 pytest ipython && pip install pyls-black pyls-isort pyls-mypy")
    (message "no conda env set so skipping server installation"))))

Jinja2 templating is used all over the place so we configure the package.

(use-package jinja2-mode
  :defer
  :commands jinja2-mode
  :mode (("\\.jinja2$" . jinja2-mode)
         ("\\.j2$" . jinja2-mode)
         ("\\.j2.html$" . jinja2-mode)))

Kubernetes

Kubernetes mode provides an interactive interface to Kubernetes from emacs. Since it’s related, we want to have the shortcut in a similar place as Dockers so we add a shortcut (`[Space] o K`) in a similar place as Dockers.

(use-package kubernetes
  :defer
  :commands (kubernetes-overview))
(use-package kubernetes-evil
  :defer
  :after kubernetes)
(map! :leader
      (:prefix "o"
        :desc "Kubernetes" "K" 'kubernetes-overview))

About

Doom Emacs configurations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published