Skip to content

Instantly share code, notes, and snippets.

@mskorzhinskiy
Created March 4, 2024 20:50
Show Gist options
  • Save mskorzhinskiy/cc7c249154afc08c776d990dfdd61313 to your computer and use it in GitHub Desktop.
Save mskorzhinskiy/cc7c249154afc08c776d990dfdd61313 to your computer and use it in GitHub Desktop.
Doom Emacs Configuration

DOOM Configuration

Description

Literature configuration made for doom emacs.

(setq user-full-name    "Mikhail Skorzhisnkii")

Emacs is built with the following command:

./configure --with-x-toolkit=gtk3 --with-json --with-pgtk

Interface

Fonts

(setq doom-font
      (font-spec :family "IBM Plex Mono" :size 18)
      doom-variable-pitch-font
      (font-spec :family "IBM Plex Sans")
      doom-big-font
      (font-spec :family "IBM Plex Mono" :size 26))

Theme

Most of the time I work on a computer during the day and on a notebook during the evening. So white theme on a computer by default and black on a notebook.

(package! modus-themes
  :recipe (:host github :repo "protesilaos/modus-themes"))
(use-package modus-themes
  :config
  (setq modus-themes-bold-constructs t)
  (setq modus-themes-slanted-constructs t)
  (setq modus-themes-common-palette-overrides
        `((border-mode-line-active unspecified)
          (border-mode-line-inactive unspecified)
          ,@modus-themes-preset-overrides-faint)))
(setq doom-theme 'modus-operandi)
(defvar doom-light-theme 'modus-operandi)
(defvar doom-dark-theme 'modus-vivendi)

Splash screen

(setq fancy-splash-image "~/.local/share/pictures/trancendent-gnu-smoll.png")
(defvar fancy-splash-image-dark "~/.local/share/pictures/black-hole.png")
(defvar fancy-splash-image-light "~/.local/share/pictures/trancendent-gnu-smoll.png")

Setup ivy-posframe

(after! ivy-posframe (setq ivy-posframe-border-width 1))

Disable decorations for emacs windows

(add-to-list 'default-frame-alist
             '(undecorated . t))

Use default size for all of the frames

(add-to-list 'default-frame-alist
             '(width . 120))

Treemacs Theme Fixes

Battling with treemacs and lsp-treemacs shenanigans.

(after! treemacs
  (treemacs-create-theme "MyTheme"
    :icon-directory (treemacs-join-path treemacs-dir "icons/default")
    :config
    (progn
      ;; directory and other icons
      (treemacs-create-icon :file "vsc/root-closed.png"   :extensions (root-closed) :fallback "")
      (treemacs-create-icon :file "vsc/root-open.png"     :extensions (root-open)   :fallback "")
      (treemacs-create-icon :file "vsc/dir-closed.png"    :extensions (dir-closed)  :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-open.png"      :extensions (dir-open)    :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "tags-leaf.png"         :extensions (tag-leaf)    :fallback (propertize "" 'face 'font-lock-constant-face))
      (treemacs-create-icon :file "tags-open.png"         :extensions (tag-open)    :fallback (propertize "" 'face 'font-lock-string-face))
      (treemacs-create-icon :file "tags-closed.png"       :extensions (tag-closed)  :fallback (propertize "" 'face 'font-lock-string-face))
      (treemacs-create-icon :file "error.png"             :extensions (error)       :fallback (propertize "" 'face 'font-lock-string-face))
      (treemacs-create-icon :file "warning.png"           :extensions (warning)     :fallback (propertize "" 'face 'font-lock-string-face))
      (treemacs-create-icon :file "info.png"              :extensions (info)        :fallback (propertize "" 'face 'font-lock-string-face))
      (treemacs-create-icon :file "bookmark.png"          :extensions (bookmark)    :fallback " ")
      (treemacs-create-icon :file "svgrepo/screen.png"    :extensions (screen)      :fallback " ")
      (treemacs-create-icon :file "svgrepo/house.png"     :extensions (house)       :fallback " ")
      (treemacs-create-icon :file "svgrepo/list.png"      :extensions (list)        :fallback " ")
      (treemacs-create-icon :file "svgrepo/repeat.png"    :extensions (repeat)      :fallback " ")
      (treemacs-create-icon :file "svgrepo/suitcase.png"  :extensions (suitcase)    :fallback " ")
      (treemacs-create-icon :file "svgrepo/close.png"     :extensions (close)       :fallback " ")
      (treemacs-create-icon :file "svgrepo/cal.png"       :extensions (calendar)    :fallback " ")
      (treemacs-create-icon :file "svgrepo/briefcase.png" :extensions (briefcase)   :fallback " ")
      (treemacs-create-icon :file "svgrepo/mail.png"      :extensions (mail)        :fallback " ")
      (treemacs-create-icon :file "svgrepo/mail-plus.png" :extensions (mail-plus)   :fallback " ")

      ;; custom dir icons
      (treemacs-create-icon :file "svgrepo/dir-src-closed.png"    :extensions ("src-closed")     :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "svgrepo/dir-src-open.png"      :extensions ("src-open")       :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "svgrepo/dir-test-closed.png"   :extensions ("test-closed")    :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "svgrepo/dir-test-open.png"     :extensions ("test-open")      :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-binary-closed.png"     :extensions ("bin-closed")     :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-binary-open.png"       :extensions ("bin-open")       :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-services-closed.png"   :extensions ("build-closed")   :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-services-open.png"     :extensions ("build-open")     :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "svgrepo/dir-git-closed.png"    :extensions ("git-closed")     :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "svgrepo/dir-git-open.png"      :extensions ("git-open")       :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-github-closed.png"     :extensions ("github-closed")  :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-github-open.png"       :extensions ("github-open")    :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-public-closed.png"     :extensions ("public-closed")  :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-public-open.png"       :extensions ("public-open")    :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-private-closed.png"    :extensions ("private-closed") :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon :file "vsc/dir-private-open.png"      :extensions ("private-open")   :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-temp-closed.png" :extensions ("temp-closed" "tmp-closed")
       :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-temp-open.png" :extensions ("temp-open" "tmp-open")
       :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-docs-closed.png" :extensions ("readme-closed" "docs-closed")
       :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-docs-open.png" :extensions ("readme-open" "docs-open")
       :fallback (propertize "- " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-images-closed.png" :extensions ("screenshots-closed" "icons-closed")
       :fallback (propertize "+ " 'face 'treemacs-term-node-face))
      (treemacs-create-icon
       :file "vsc/dir-images-open.png" :extensions ("screenshots-open" "icons-open")
       :fallback (propertize "- " 'face 'treemacs-term-node-face))

      ;; file icons
      (treemacs-create-icon :file "txt.png"           :extensions (fallback))
      (treemacs-create-icon :file "emacs.png"         :extensions ("el" "elc" "eln"))
      (treemacs-create-icon :file "ledger.png"        :extensions ("ledger" "beancount"))
      (treemacs-create-icon :file "yaml.png"          :extensions ("yml" "yaml" "travis.yml"))
      (treemacs-create-icon
       :file "shell.png"
       :extensions ("sh" "zsh" "zshrc" "zshenv" "fish" "zprofile" "zlogin" "zlogout" "bash"
                    "bash_profile" "bashrc" "bash_login" "profile" "bash_aliases"))
      (treemacs-create-icon :file "pdf.png"           :extensions ("pdf"))
      (treemacs-create-icon :file "c.png"             :extensions ("c" "h"))
      (treemacs-create-icon :file "haskell.png"       :extensions ("hs" "lhs"))
      (treemacs-create-icon :file "cabal.png"         :extensions ("cabal"))
      (treemacs-create-icon :file "lock.png"          :extensions ("lock"))
      (treemacs-create-icon :file "python.png"        :extensions ("py" "pyc"))
      (treemacs-create-icon :file "markdown.png"      :extensions ("md"))
      (treemacs-create-icon :file "asciidoc.png"      :extensions ("adoc" "asciidoc"))
      (treemacs-create-icon :file "rust.png"          :extensions ("rs"))
      (treemacs-create-icon :file "image.png"         :extensions ("jpg" "jpeg" "bmp" "svg" "png" "xpm" "gif"))
      (treemacs-create-icon :file "clojure.png"       :extensions ("clj" "cljs" "cljc" "edn"))
      (treemacs-create-icon :file "ts.png"            :extensions ("ts" "tsx"))
      (treemacs-create-icon :file "vue.png"           :extensions ("vue"))
      (treemacs-create-icon :file "css.png"           :extensions ("css"))
      (treemacs-create-icon :file "conf.png"          :extensions ("properties" "conf" "config" "cfg" "ini" "xdefaults" "xresources" "terminalrc" "ledgerrc"))
      (treemacs-create-icon :file "html.png"          :extensions ("html" "htm"))
      (treemacs-create-icon :file "git.png"           :extensions ("git" "gitignore" "gitconfig" "gitmodules" "gitattributes"))
      (treemacs-create-icon :file "dart.png"          :extensions ("dart"))
      (treemacs-create-icon :file "jar.png"           :extensions ("jar"))
      (treemacs-create-icon :file "kotlin.png"        :extensions ("kt"))
      (treemacs-create-icon :file "scala.png"         :extensions ("scala"))
      (treemacs-create-icon :file "gradle.png"        :extensions ("gradle"))
      (treemacs-create-icon :file "sbt.png"           :extensions ("sbt"))
      (treemacs-create-icon :file "go.png"            :extensions ("go"))
      (treemacs-create-icon :file "systemd.png"       :extensions ("service" "timer"))
      (treemacs-create-icon :file "php.png"           :extensions ("php"))
      (treemacs-create-icon :file "js.png"            :extensions ("js" "jsx"))
      (treemacs-create-icon :file "babel.png"         :extensions ("babel"))
      (treemacs-create-icon :file "hy.png"            :extensions ("hy"))
      (treemacs-create-icon :file "json.png"          :extensions ("json"))
      (treemacs-create-icon :file "julia.png"         :extensions ("jl"))
      (treemacs-create-icon :file "elx.png"           :extensions ("ex"))
      (treemacs-create-icon :file "elx-light.png"     :extensions ("exs" "eex" "leex" "heex"))
      (treemacs-create-icon :file "ocaml.png"         :extensions ("ml" "mli" "merlin" "ocaml"))
      (treemacs-create-icon :file "direnv.png"        :extensions ("envrc"))
      (treemacs-create-icon :file "puppet.png"        :extensions ("pp"))
      (treemacs-create-icon :file "docker.png"        :extensions ("dockerfile" "docker-compose.yml"))
      (treemacs-create-icon :file "vagrant.png"       :extensions ("vagrantfile"))
      (treemacs-create-icon :file "jinja2.png"        :extensions ("j2" "jinja2"))
      (treemacs-create-icon :file "video.png"         :extensions ("webm" "mp4" "avi" "mkv" "flv" "mov" "wmv" "mpg" "mpeg" "mpv"))
      (treemacs-create-icon :file "audio.png"         :extensions ("mp3" "ogg" "oga" "wav" "flac"))
      (treemacs-create-icon :file "tex.png"           :extensions ("tex"))
      (treemacs-create-icon :file "racket.png"        :extensions ("racket" "rkt" "rktl" "rktd" "scrbl" "scribble" "plt"))
      (treemacs-create-icon :file "erlang.png"        :extensions ("erl" "hrl"))
      (treemacs-create-icon :file "purescript.png"    :extensions ("purs"))
      (treemacs-create-icon :file "nix.png"           :extensions ("nix"))
      (treemacs-create-icon :file "project.png"       :extensions ("project"))
      (treemacs-create-icon :file "scons.png"         :extensions ("sconstruct" "sconstript"))
      (treemacs-create-icon :file "vsc/make.png"      :extensions ("makefile"))
      (treemacs-create-icon :file "vsc/license.png"   :extensions ("license"))
      (treemacs-create-icon :file "vsc/zip.png"       :extensions ("zip" "7z" "tar" "gz" "rar" "tar.gz"))
      (treemacs-create-icon :file "vsc/elm.png"       :extensions ("elm"))
      (treemacs-create-icon :file "vsc/xml.png"       :extensions ("xml" "xsl"))
      (treemacs-create-icon :file "vsc/access.png"    :extensions ("accdb" "accdt" "accdt"))
      (treemacs-create-icon :file "vsc/ascript.png"   :extensions ("actionscript"))
      (treemacs-create-icon :file "vsc/ai.png"        :extensions ("ai"))
      (treemacs-create-icon :file "vsc/alaw.png"      :extensions ("al"))
      (treemacs-create-icon :file "vsc/angular.png"   :extensions ("angular-cli.json" "angular.json"))
      (treemacs-create-icon :file "vsc/ansible.png"   :extensions ("ansible"))
      (treemacs-create-icon :file "vsc/antlr.png"     :extensions ("antlr"))
      (treemacs-create-icon :file "vsc/any.png"       :extensions ("anyscript"))
      (treemacs-create-icon :file "vsc/apache.png"    :extensions ("apacheconf"))
      (treemacs-create-icon :file "vsc/apple.png"     :extensions ("applescript"))
      (treemacs-create-icon :file "vsc/appveyor.png"  :extensions ("appveyor.yml"))
      (treemacs-create-icon :file "vsc/arduino.png"   :extensions ("ino" "pde"))
      (treemacs-create-icon :file "vsc/asp.png"       :extensions ("asp"))
      (treemacs-create-icon :file "vsc/asm.png"       :extensions ("asm" "arm"))
      (treemacs-create-icon :file "vsc/autohk.png"    :extensions ("ahk"))
      (treemacs-create-icon :file "vsc/babel.png"     :extensions ("babelrc" "babelignore" "babelrc.js" "babelrc.json" "babel.config.js"))
      (treemacs-create-icon :file "vsc/bat.png"       :extensions ("bat"))
      (treemacs-create-icon :file "vsc/binary.png"    :extensions ("exe" "dll" "obj" "so" "o"))
      (treemacs-create-icon :file "vsc/bazel.png"     :extensions ("bazelrc" "bazel"))
      (treemacs-create-icon :file "vsc/bower.png"     :extensions ("bowerrc" "bower.json"))
      (treemacs-create-icon :file "vsc/bundler.png"   :extensions ("gemfile" "gemfile.lock"))
      (treemacs-create-icon :file "vsc/cargo.png"     :extensions ("cargo.toml" "cargo.lock"))
      (treemacs-create-icon :file "vsc/cert.png"      :extensions ("csr" "crt" "cer" "der" "pfx" "p12" "p7b" "p7r" "src" "crl" "sst" "stl"))
      (treemacs-create-icon :file "vsc/class.png"     :extensions ("class"))
      (treemacs-create-icon :file "vsc/cmake.png"     :extensions ("cmake" "cmake-cache"))
      (treemacs-create-icon :file "vsc/cobol.png"     :extensions ("cobol"))
      (treemacs-create-icon :file "vsc/cfscript.png"  :extensions ("coffeescript"))
      (treemacs-create-icon :file "vsc/cpp.png"       :extensions ("cpp" "cxx" "tpp" "cc"))
      (treemacs-create-icon :file "vsc/cpph.png"      :extensions ("hpp" "hxx" "hh"))
      (treemacs-create-icon :file "vsc/cucumber.png"  :extensions ("feature"))
      (treemacs-create-icon :file "vsc/cython.png"    :extensions ("cython"))
      (treemacs-create-icon :file "vsc/delphi.png"    :extensions ("pascal" "objectpascal"))
      (treemacs-create-icon :file "vsc/django.png"    :extensions ("djt" "django-html" "django-txt"))
      (treemacs-create-icon :file "vsc/dlang.png"     :extensions ("d" "dscript" "dml" "diet"))
      (treemacs-create-icon :file "vsc/diff.png"      :extensions ("diff"))
      (treemacs-create-icon :file "vsc/editorcfg.png" :extensions ("editorconfig"))
      (treemacs-create-icon :file "vsc/erb.png"       :extensions ("erb"))
      (treemacs-create-icon :file "vsc/eslint.png"    :extensions ("eslintrc" "eslintignore" "eslintcache"))
      (treemacs-create-icon :file "vsc/excel.png"     :extensions ("xls" "xlsx" "xlsm" "ods" "fods"))
      (treemacs-create-icon :file "vsc/font.png"      :extensions ("woff" "woff2" "ttf" "otf" "eot" "pfa" "pfb" "sfd"))
      (treemacs-create-icon :file "vsc/fortran.png"   :extensions ("fortran" "fortran-modern" "fortranfreeform"))
      (treemacs-create-icon :file "vsc/fsharp.png"    :extensions ("fsharp"))
      (treemacs-create-icon :file "vsc/fsproj.png"    :extensions ("fsproj"))
      (treemacs-create-icon :file "vsc/godot.png"     :extensions ("gdscript"))
      (treemacs-create-icon :file "vsc/graphql.png"   :extensions ("graphql"))
      (treemacs-create-icon :file "vsc/helm.png"      :extensions ("helm"))
      (treemacs-create-icon :file "vsc/java.png"      :extensions ("java"))
      (treemacs-create-icon :file "vsc/jenkins.png"   :extensions ("jenkins"))
      (treemacs-create-icon :file "vsc/jupyter.png"   :extensions ("ipynb"))
      (treemacs-create-icon :file "vsc/key.png"       :extensions ("key" "pem"))
      (treemacs-create-icon :file "vsc/less.png"      :extensions ("less"))
      (treemacs-create-icon :file "vsc/locale.png"    :extensions ("locale"))
      (treemacs-create-icon :file "vsc/manifest.png"  :extensions ("manifest"))
      (treemacs-create-icon :file "vsc/maven.png"     :extensions ("pom.xml" "maven.config" "extensions.xml" "settings.xml"))
      (treemacs-create-icon :file "vsc/meson.png"     :extensions ("meson" "meson.build"))
      (treemacs-create-icon :file "vsc/nginx.png"     :extensions ("nginx.conf" "nginx"))
      (treemacs-create-icon :file "vsc/npm.png"       :extensions ("npmignore" "npmrc" "package.json" "package-lock.json" "npm-shrinwrap.json"))
      (treemacs-create-icon :file "vsc/wasm.png"      :extensions ("wasm" "wat"))
      (treemacs-create-icon :file "vsc/yarn.png"      :extensions ("yarn.lock" "yarnrc" "yarnclean" "yarn-integrity" "yarn-metadata.json" "yarnignore"))
      (treemacs-create-icon :file "vsc/pkg.png"       :extensions ("pkg"))
      (treemacs-create-icon :file "vsc/patch.png"     :extensions ("patch"))
      (treemacs-create-icon :file "vsc/perl6.png"     :extensions ("perl6"))
      (treemacs-create-icon :file "vsc/pgsql.png"     :extensions ("pgsql"))
      (treemacs-create-icon :file "vsc/phpunit.png"   :extensions ("phpunit" "phpunit.xml"))
      (treemacs-create-icon :file "vsc/pip.png"       :extensions ("pipfile" "pipfile.lock" "pip-requirements"))
      (treemacs-create-icon :file "vsc/plsql.png"     :extensions ("plsql" "orcale"))
      (treemacs-create-icon :file "vsc/pp.png"        :extensions ("pot" "potx" "potm" "pps" "ppsx" "ppsm" "ppt" "pptx" "pptm" "pa" "ppa" "ppam" "sldm" "sldx"))
      (treemacs-create-icon :file "vsc/prettier.png"  :extensions ("prettier.config.js" "prettierrc.js" "prettierrc.json" "prettierrc.yml" "prettierrc.yaml"))
      (treemacs-create-icon :file "vsc/prolog.png"    :extensions ("pro" "prolog"))
      (treemacs-create-icon :file "vsc/protobuf.png"  :extensions ("proto" "proto3"))
      (treemacs-create-icon :file "vsc/rake.png"      :extensions ("rake" "rakefile"))
      (treemacs-create-icon :file "vsc/sqlite.png"    :extensions ("sqlite" "db3" "sqlite3"))
      (treemacs-create-icon :file "vsc/swagger.png"   :extensions ("swagger"))
      (treemacs-create-icon :file "vsc/swift.png"     :extensions ("swift"))
      (treemacs-create-icon :file "vsc/ruby.png"      :extensions ("rb"))
      (treemacs-create-icon :file "vsc/scss.png"      :extensions ("scss"))
      (treemacs-create-icon :file "vsc/lua.png"       :extensions ("lua"))
      (treemacs-create-icon :file "vsc/log.png"       :extensions ("log"))
      (treemacs-create-icon :file "vsc/lisp.png"      :extensions ("lisp"))
      (treemacs-create-icon :file "vsc/sql.png"       :extensions ("sql"))
      (treemacs-create-icon :file "vsc/toml.png"      :extensions ("toml"))
      (treemacs-create-icon :file "vsc/nim.png"       :extensions ("nim"))
      (treemacs-create-icon :file "vsc/org.png"       :extensions ("org" "org_archive"))
      (treemacs-create-icon :file "vsc/perl.png"      :extensions ("pl" "pm" "perl"))
      (treemacs-create-icon :file "vsc/vim.png"       :extensions ("vimrc" "tridactylrc" "vimperatorrc" "ideavimrc" "vrapperrc"))
      (treemacs-create-icon :file "vsc/deps.png"      :extensions ("cask"))
      (treemacs-create-icon :file "vsc/r.png"         :extensions ("r"))
      (treemacs-create-icon :file "vsc/reason.png"    :extensions ("re" "rei")))))
(after! treemacs
  (require 'treemacs-themes)
  (treemacs-load-theme "MyTheme"))

Automatic colour switcher

(defvar init-interfaces-dbus-color-scheme-change-functions nil
  "Special hook run when a color scheme change is detected through D-Bus.
Each function in this hook is called with a single argument, `light'
or `dark', according to the current color scheme.")

(defun modus-switch-color-scheme (scheme)
  (when (equal scheme 'light)
    (setq fancy-splash-image fancy-splash-image-light)
    (load-theme doom-light-theme t))
  (when (equal scheme 'dark)
    (setq fancy-splash-image fancy-splash-image-dark)
    (load-theme doom-dark-theme t)))

(setq init-interfaces-dbus-color-scheme-change-functions 'modus-switch-color-scheme)

(when-let (((require 'dbus nil t))
           (service (car (member "org.freedesktop.portal.Desktop"
                                 (dbus-list-activatable-names :session)))))
  (dbus-register-signal
   :session service
   "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings"
   "SettingChanged"
   (lambda (path var val)
     (and (string= path "org.freedesktop.appearance")
          (string= var "color-scheme")
          (run-hook-with-args
           'init-interfaces-dbus-color-scheme-change-functions
           (pcase (car val) (0 'light) (1 'dark))))))
  (run-hook-with-args
   'init-interfaces-dbus-color-scheme-change-functions
   (pcase (caar (dbus-call-method
                 :session service
                 "/org/freedesktop/portal/desktop"
                 "org.freedesktop.portal.Settings" "Read"
                 "org.freedesktop.appearance" "color-scheme"))
     (0 'light) (1 'dark))))

Editor

Allow saving on Control+S

I don’t really use Control+S anywhere, as I do the Space+f+s usually. But also there are a lot of other programs the do the same. So it is just easier.

(map! :g "C-s" #'save-buffer)

Spell check

(after! flyspell
  (setq ispell-dictionary "en_GB,de_DE,ru_RU")
  (ispell-set-spellchecker-params)
  (ispell-hunspell-add-multi-dic "en_GB,de_DE,ru_RU"))

Prefer split windows horizontally

(setq split-height-threshold 0)
(setq split-width-threshold nil)
(after! magit
  (setq magit-display-buffer-function
        #'magit-display-buffer-same-window-except-diff-v1))

Configure indent guides

(after! highlight-indent-guides
  (setq highlight-indent-guides-method 'bitmap)
  (setq highlight-indent-guides-responsive 'stack)
  (setq highlight-indent-guides-bitmap-function #'highlight-indent-guides--bitmap-line))

Feature: unfill paragraph

(defun unfill-paragraph ()
  "Takes a multi-line paragraph and makes it into a single line of text."
  (interactive)
  (let ((fill-column (point-max)))
    (fill-paragraph nil)))

(map! "M-Q" #'unfill-paragraph)

Configure auto-save mode

This will save the visited file rather then in separate auto-save file.

(auto-save-visited-mode 1)

Enable auto-revert (auto-save)

Enable auto revert on buffers

(global-auto-revert-mode)

Suppress auto-revert messages

(setq auto-revert-verbose nil)

Initial major mode

(setq doom-scratch-initial-major-mode 'org-mode)

Literate calc-mode in org-mode buffers

(package! literate-calc-mode)
(add-hook 'org-mode-hook #'literate-calc-minor-mode)

Enable pixel-precision scrolling

(when (version< "29.0.50" emacs-version)
  (pixel-scroll-precision-mode))

Programming

Disable file-watchers for lsp-mode

Most of my projects a really huge and besides file watching is not that useful for me, I am creating worktrees for different git branches.

(setq lsp-enable-file-watchers nil)

GraphQL

(package! graphql-mode
  :recipe (:host github
           :repo "davazp/graphql-mode"))

Info screens better coloring

(use-package! info-colors
  :after info
  :commands (info-colors-fontify-node)
  :hook (Info-selection . info-colors-fontify-node))
(package! info-colors)

Major mode for K-Config mode

(package! kconfig-mode
  :recipe (:host github
           :repo "delaanthonio/kconfig-mode"))

Terminal

Run projectile vterm

(map! :leader
      (:prefix-map ("p" . "project")
       :desc "Browse project"               "v" #'projectile-run-vterm))

VTerm configuration

(setq vterm-kill-buffer-on-exit t)
(setq vterm-min-window-width    80)
(setq vterm-max-scrollback      10000000)
;; To things below to work, need to upload additional shell configuration
;; which defines these commands and allow them to call things
(after! vterm
  (setf (alist-get "woman" vterm-eval-cmds nil nil #'equal)
        '((lambda (topic)
            (woman topic))))
  (setf (alist-get "magit-status" vterm-eval-cmds nil nil #'equal)
        '((lambda (path)
            (magit-status path))))
  (setf (alist-get "dired" vterm-eval-cmds nil nil #'equal)
        '((lambda (dir)
            (dired dir)))))

Version Control System

Showing committer date instead of author date is better (for me), since it’s most of the time I am

(setq magit-log-margin-show-committer-date t)

Setup default repo locations

(setq magit-repository-directories '(("~/projects" . 1)
                                     ("~/work" . 1)))

Settings and packages for CV generation (org-cv)

There is a few additions to the org-cv packages from me, which are still (as of [2021-09-30]) not merged with the upstream.

(package! org-cv
  :recipe (:host github :repo "mskorzhinskiy/org-cv"))

File manager (dirvish)

(package! diredfl :pin "62b559e1d6b69834a56a57eb1832ac6ad4d2e5d0")
(package! dirvish :pin "119f9f59a618bb7b476c93e9ab1d7542c5c1df41")
(use-package! dired
  :commands dired-jump
  :init
  (setq dired-dwim-target t  ; suggest a target for moving/copying intelligently
        ;; don't prompt to revert, just do it
        dired-auto-revert-buffer #'dired-buffer-stale-p
        ;; Always copy/delete recursively
        dired-recursive-copies  'always
        dired-recursive-deletes 'top
        ;; Ask whether destination dirs should get created when copying/removing files.
        dired-create-destination-dirs 'ask
        ;; Where to store image caches
        image-dired-dir (concat doom-cache-dir "image-dired/")
        image-dired-db-file (concat image-dired-dir "db.el")
        image-dired-gallery-dir (concat image-dired-dir "gallery/")
        image-dired-temp-image-file (concat image-dired-dir "temp-image")
        image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image")
        ;; Screens are larger nowadays, we can afford slightly larger thumbnails
        image-dired-thumb-size 150)
  :config
  (set-popup-rule! "^\\*image-dired"
    :slot 20 :size 0.8 :select t :quit nil :ttl 0)
  (set-evil-initial-state! 'image-dired-display-image-mode 'emacs)

  (let* ((ls (executable-find "ls"))
         (gls (executable-find "gls"))
         (idp (executable-find insert-directory-program))
         (ls-is-gnu? (and ls (= 0 (process-file ls nil nil nil "--version"))))
         (idp-is-gnu-ls?
          (and idp (= 0 (process-file idp nil nil nil "--version")))))
    (setq dired-listing-switches
          "-l --almost-all --human-readable --group-directories-first")
    (setq insert-directory-program
          (cond
           ;; just use GNU ls if found
           (ls-is-gnu? ls)
           ;; use insert-directory-program if it points to GNU ls
           (idp-is-gnu-ls? insert-directory-program)
           ;; heuristic: GNU ls is often installed as gls by Homebrew on Mac
           ((and (eq system-type 'darwin) gls) gls)
           (t
            ;; Emacs 28+ sanitizes unknown switches silently
            (when (< emacs-major-version 28)
              (setq dired-listing-switches "-alh"))
            ;; fallback to insert-directory-program
            insert-directory-program))))

  (defadvice! +dired--no-revert-in-virtual-buffers-a (&rest args)
    "Don't auto-revert in dired-virtual buffers (see `dired-virtual-revert')."
    :before-while #'dired-buffer-stale-p
    (not (eq revert-buffer-function #'dired-virtual-revert)))

  (map! :map dired-mode-map
        ;; To be consistent with ivy/helm+wgrep integration
        "C-c C-e" #'wdired-change-to-wdired-mode))


(use-package! dired-x
  :hook (dired-mode . dired-omit-mode)
  :config
  (setq dired-omit-verbose nil
        dired-omit-files
        (concat dired-omit-files
                "\\|^\\.DS_Store\\'"
                "\\|^\\.project\\(?:ile\\)?\\'"
                "\\|^\\.\\(?:svn\\|git\\)\\'"
                "\\|^\\.ccls-cache\\'"
                "\\|\\(?:\\.js\\)?\\.meta\\'"
                "\\|\\.\\(?:elc\\|o\\|pyo\\|swp\\|class\\)\\'"))
  ;; Disable the prompt about whether I want to kill the Dired buffer for a
  ;; deleted directory. Of course I do!
  (setq dired-clean-confirm-killing-deleted-buffers nil)
  ;; Let OS decide how to open certain files
  (when-let (cmd (cond (IS-MAC "open")
                       (IS-LINUX "xdg-open")
                       (IS-WINDOWS "start")))
    (setq dired-guess-shell-alist-user
          `(("\\.\\(?:docx\\|pdf\\|djvu\\|eps\\)\\'" ,cmd)
            ("\\.\\(?:jpe?g\\|png\\|gif\\|xpm\\)\\'" ,cmd)
            ("\\.\\(?:xcf\\)\\'" ,cmd)
            ("\\.csv\\'" ,cmd)
            ("\\.tex\\'" ,cmd)
            ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|rm\\|rmvb\\|ogv\\)\\(?:\\.part\\)?\\'" ,cmd)
            ("\\.\\(?:mp3\\|flac\\)\\'" ,cmd)
            ("\\.html?\\'" ,cmd)
            ("\\.md\\'" ,cmd))))
  (map! :map dired-mode-map
        :localleader
        "h" #'dired-omit-mode))


(use-package! dired-aux
  :defer t
  :config
  (setq dired-create-destination-dirs 'ask
        dired-vc-rename-file t))


(use-package! diredfl
  :hook (dired-mode . diredfl-mode)
  :hook (dirvish-directory-view-mode . diredfl-mode))


(use-package! dirvish
  :defer t
  :general (dired-mode-map "C-c C-r" #'dirvish-rsync)
  :after-call dired-noselect dired dired-jump
  :custom
  (dirvish-hide-details t)
  (tab-width 2)
  :config
  (dirvish-override-dired-mode)
  (setq dirvish-cache-dir (concat doom-cache-dir "dirvish/"))
  (set-popup-rule! "^ ?\\*Dirvish.*" :ignore t)
  (map! :map dirvish-mode-map
        :n  "?"   #'dirvish-dispatch
        :n  "q"   #'dirvish-quit
        :ng "a"   #'dirvish-quick-access
        :ng "f"   #'dirvish-file-info-menu
        :ng "y"   #'dirvish-yank-menu
        :ng "s"   #'dirvish-quicksort
        :ng "TAB" #'dirvish-subtree-toggle
        :ng "M-t" #'dirvish-layout-toggle
        :ng "M-b" #'dirvish-history-go-backward
        :ng "M-f" #'dirvish-history-go-forward
        :ng "M-n" #'dirvish-narrow
        :ng "M-m" #'dirvish-mark-menu
        :ng "M-s" #'dirvish-setup-menu
        :ng "M-e" #'dirvish-emerge-menu)
  (setq dirvish-attributes '(file-size collapse)
        dirvish-mode-line-format
        '(:left (sort file-time symlink) :right (omit yank index)))
  (push 'vc-state dirvish-attributes)
  (appendq! dirvish-attributes '(all-the-icons subtree-state))
  ;; User configuration
  (setq dired-dwim-target t)
  (setq delete-by-moving-to-trash t)
  (setq dirvish-default-layout '(1 0.07 0.6))
  (setq dirvish-all-the-icons-height 0.8)
  (setq dirvish-icon-delimiter "	")
  (setq dired-listing-switches
        "-l --almost-all --human-readable --group-directories-first --no-group")
  (defconst dirvish-other-exts '("pdf" "html" "exe"))
  (setq dirvish-open-with-programs
        `((,dirvish-audio-exts . ("xdg-open" "%f"))
          (,dirvish-video-exts . ("xdg-open" "%f"))
          (,dirvish-image-exts . ("xdg-open" "%f"))
          (,dirvish-other-exts . ("xdg-open" "%f"))))
  ;; exa thing
  (dirvish-define-preview exa (file)
    "Use `exa' to generate directory preview."
    :require ("exa") ; tell Dirvish to check if we have the executable
    (when (file-directory-p file) ; we only interest in directories here
      `(shell . ("exa"
                 "--tree"
                 "--level" "1"
                 "--color=always"
                 "--icons"
                 "--group-directories-first"
                 "--sort" "extension"
                 "--classify"
                 ,file))))
  (setq dirvish-use-header-line 'global)    ; make header line span all panes
  (add-to-list 'dirvish-preview-dispatchers 'exa)
  ;; omito
  (setq dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\..*$"))

(map! :leader
      (:prefix-map ("o" . "open")
       ;; :desc "Toggle dirvish sideview" "p" #'dirvish-side
       :desc "Open dirvish"            "-" #'dirvish))
# Should be placed to ~/.local/share/applicatioons
[Desktop Entry]
Exec=emacsclient -a "" -c -F '((name . "doom-open") (transient . t))' %U
MimeType=text/plain
Name=Open in emacs
NoDisplay=false
Icon=emacs
Type=Application
# Should be placed to ~/.config/systemd/user/emacs.service
[Unit]
Description=Emacs text editor [org]
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
[Service]
Type=forking
ExecStart=/usr/bin/emacs --bg-daemon=server
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)" -s server
Restart=on-failure
[Install]
WantedBy=default.target
;;; init.el -*- lexical-binding: t; -*-
;; This file controls what Doom modules are enabled and what order they load in.
;; Remember to run 'doom sync' after modifying it!
(setq evil-respect-visual-line-mode t) ;; sane j and k behavior
(doom!
:completion
(company +childframe)
(ivy +prescient
+childframe
+icons)
:ui
doom
doom-dashboard
doom-quit
hl-todo
indent-guides
minimap
modeline
nav-flash
ophints
(popup +defaults)
unicode
vc-gutter
vi-tilde-fringe
window-select
zen
(emoji +unicode)
(treemacs +lsp)
:editor
(evil +everywhere)
file-templates
fold
multiple-cursors
rotate-text
snippets
word-wrap
:emacs
electric
undo
vc
:term vterm
:checkers
syntax
(spell +flyspell
+everywhere
+hunspell)
:tools
pdf
debugger ; FIXME stepping through code, to help you add bugs
docker
editorconfig ; let someone else argue about tabs vs spaces
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation
lsp ; M-x vscode
magit ; a git porcelain for Emacs
make ; run make tasks from Emacs
tree-sitter ; syntax and parsing, sitting in a tree...
upload ; map local to remote projects via ssh/ftp
:lang
(cc +lsp +tree-sitter)
(go +lsp +tree-sitter)
(yaml +lsp)
(rust +lsp +tree-sitter)
(haskell +lsp +tree-sitter)
data ; config/data formats
emacs-lisp
markdown
org
(python +lsp +pyright +tree-sitter)
(sh +tree-sitter)
lua
(json +lsp +tree-sitter)
(beancount +lsp)
plantuml
:config
literate
(default +bindings
+smartparens))
@mskorzhinskiy
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment