Skip to content

Latest commit

 

History

History
459 lines (441 loc) · 15.4 KB

config.org

File metadata and controls

459 lines (441 loc) · 15.4 KB

DOOM EMACS Config

Place your private configuration here! Remember, you do not need to run ‘doom sync’ after modifying this file!

Some functionality uses this to identify you, e.g. GPG configuration, email clients, file templates and snippets.

(setq user-full-name "Cobalt Space"
      user-mail-address "cobaltspace@protonmail.com")

Font

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’; use this for presentations or streaming.

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 "Fantasque Sans Mono" :size 14)
;; (setq doom-font (font-spec :family "Source Han Mono" :size 12)
      doom-variable-pitch-font (font-spec :family "Ubuntu")
      doom-unicode-font doom-font)
;; (after! unicode-fonts (setq doom-unicode-font (font-spec :family "IPAexGothic")))
;; (after! unicode-fonts (setq doom-unicode-font doom-font))

testing bold italic underline code striketrhough

Theme

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. This is the default:

(setq doom-theme 'doom-tokyo-night)
(setq rand-theme-unwanted '(
                            adwaita
                            dichromacy
                            doom-acario-light
                            doom-ayu-light
                            doom-bluloco-light
                            doom-feather-light
                            doom-ir-black
                            doom-manokai-machine
                            doom-meltbus
                            doom-opera-light
                            doom-one-light
                            doom-solarized-light
                            doom-tomorrow-day
                            modus-vivendi-deuteranopia
                            modus-operandi
                            tsdh-light
                            wheatgrass
                            ))
(rand-theme)

Org Directory

If you use `org’ and don’t want your org files in the default location below, change `org-directory’. It must be set before org loads!

(setq org-directory "~/Documents/Org/"
      org-roam-directory "~/Documents/Roam")

Number Lines

This determines the style of line numbers in effect. If set to `nil’, line numbers are disabled. For relative line numbers, set this to `relative’.

(setq display-line-numbers-type 'relative)

Extra Config

Here are some additional functions/macros that could help you configure Doom:

  • `load!’ for loading external *.el files relative to this one
  • `use-package’ for configuring packages
  • `after!’ for running code after a package has loaded
  • `add-load-path!’ for adding directories to the `load-path’, relative to this file. Emacs searches the `load-path’ when you load packages with `require’ or `use-package’.
  • `map!’ for binding new keys

To get information about any of these functions/macros, move the cursor over the highlighted symbol at press ‘K’ (non-evil users must press ‘C-c g k’). This will open documentation for it, including demos of how they are used.

You can also try ‘gd’ (or ‘C-c g d’) to jump to their definition and see how they are implemented.

Tab line similar to what vim plugin minibufexpl does

(global-tab-line-mode)

indent guide

(setq highlight-indent-guides-method 'bitmap)

evil

Fcitx (for japanese input)

(after! fcitx (fcitx-aggressive-setup))
(setq fcitx-remote-command "fcitx5-remote")
(fcitx-aggressive-setup)

Autosave

(setq auto-save-visited-mode t)

LaTeX

Enable tab key for cdlatex

(map! :map cdlatex-mode-map :i "TAB" #'cdlatex-tab)

Indentation see brackets

(setq TeX-indent-open-delimiters "[")
(setq TeX-indent-close-delimiters "]")
(defun TeX-brace-count-line ()
  "Count number of open/closed braces."
  (save-excursion
    (let ((count 0) (limit (line-end-position)) char)
      (while (progn
               (skip-chars-forward "^{}[]\\\\" limit)
               (when (and (< (point) limit) (not (TeX-in-comment)))
                 (setq char (char-after))
                 (forward-char)
                 (cond ((eq char ?\{)
                        (setq count (+ count TeX-brace-indent-level)))
                       ((eq char ?\})
                        (setq count (- count TeX-brace-indent-level)))
                       ((eq char ?\[)
                        (setq count (+ count TeX-brace-indent-level)))
                       ((eq char ?\])
                        (setq count (- count TeX-brace-indent-level)))
                       ((eq char ?\\)
                        (when (< (point) limit)
                          (forward-char)
                          t))))))
      count)))

sub/superscript improvements

Make size the same so width of characters is the same

(custom-set-faces!
  '(font-latex-subscript-face nil)
  '(font-latex-superscript-face nil))

Make nested go further up/down

(setq font-latex-fontify-script 'multi-level)

Org Mode

Startup

Inline images

(setq org-startup-with-inline-images t)

Folding

(setq org-startup-folded t)

Pretty Entities

(after! org (setq org-pretty-entities t))

Hide Emphasis Markers

(after! org (setq org-hide-emphasis-markers t))

colored text

(after! org (require 'org-colored-text))

Superstar bullets

(setq org-superstar-item-bullet-alist
      '((42 . 8226)
        (43 . 8227)
        (45 . 8211)))

Dynamic Numbering

(setq org-startup-numerated t
      org-num-skip-unnumbered t)

appear

(add-hook! org-mode 'org-appear-mode)
(setq org-appear-autolinks 't
      org-appear-autosubmarkers 't
      org-appear-autoentities 't
      org-appear-autokeywords 't)

Mobile

csl

(setq org-cite-csl-styles-dir "~/Zotero/styles")

LaTeX

Packages

(setq org-latex-packages-alist '(("dvipsnames,svgnames,x11names" "xcolor" t)
                                 ("" "mathtools" t)
                                 ("" "physics" t)
                                 ("bbsets" "jkmath" t)
                                 ("makeroom" "cancel" t)
                                 ("" "units" t)
                                 ("" "svg" nil)
                                 ("" "listings" nil)
                                 ("inline" "enumitem" nil)))

cite

(after! oc-biblatex
  (defun org-cite-biblatex-export-citation (citation style _ info)
    "Export CITATION object.
STYLE is the citation style, as a pair of either strings or nil.
INFO is the export state, as a property list."
    (apply
     #'org-cite-biblatex--command citation info
     (pcase style
       ;; "author" style.
       (`(,(or "author" "a") . ,variant)
        (pcase variant
          ((or "caps" "c")            '("Citeauthor*"))
          ((or "full" "f")            '("citeauthor"))
          ((or "caps-full" "cf")      '("Citeauthor"))
          (_                          '("citeauthor*"))))
       ;; "locators" style.
       (`(,(or "locators" "l") . ,variant)
        (pcase variant
          ((or "bare" "b")            '("notecite"))
          ((or "caps" "c")            '("Pnotecite"))
          ((or "bare-caps" "bc")      '("Notecite"))
          (_                          '("pnotecite"))))
       ;; "noauthor" style.
       (`(,(or "noauthor" "na") . ,variant)
        (pcase variant
          ((or "bare" "b")            '("cite*"))
          (_                          '("autocite*"))))
       ;; "nocite" style.
       (`(,(or "nocite" "n") . ,_)    '("nocite" nil t))
       ;; "text" style.
       (`(,(or "text" "t") . ,variant)
        (pcase variant
          ((or "caps" "c")            '("Textcite" t))
          (_                          '("textcite" t))))
       ;; "title" style
       (`(,(or "title" "t") . ,variant)
        (pcase variant
          ((or "full" "f")            '("citetitle*"))
          (_                          '("citetitle"))))
       ;; "year" style
       (`(,(or "year" "y") . ,_)      '("citeyear"))
       ;; Default "nil" style.
       (`(,_ . ,variant)
        (pcase variant
          ((or "bare" "b")            '("cite" t))
          ((or "caps" "c")            '("Autocite" t))
          ((or "bare-caps" "bc")      '("Cite" t))
          (_                          '("autocite" t))))
       ;; This should not happen.
       (_ (error "Invalid style: %S" style))))))

Format

(after! org
  (setq org-format-latex-options
        '(:foreground default
          :background default
          :scale 1.1
          :html-foreground "Black"
          :html-background "Transparent"
          :html-scale 1.0
          :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))))

Preview

Method Customizations
(after! org
  (add-to-list 'org-preview-latex-process-alist
               '(dvisvgm-svgcleaner
                 :programs ("latex" "dvisvgm" "svgcleaner")
                 :description "dvi > svg"
                 :message "you need to install the programs: latex and dvisvgm and svgcleaner."
                 :image-input-type "dvi"
                 :image-output-type "svg"
                 :image-size-adjust (1.7 . 1.5)
                 :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
                 :image-converter ("dvisvgm %f --no-fonts --exact-bbox --scale=%S --output=%O" "svgcleaner --multipass %O %O")))
  (add-to-list 'org-preview-latex-process-alist
               '(dvisvgm-svgz
                 :programs ("latex" "dvisvgm" "svgcleaner")
                 :description "dvi > svg"
                 :message "you need to install the programs: latex and dvisvgm and svgcleaner."
                 :image-input-type "dvi"
                 :image-output-type "svgz"
                 :image-size-adjust (1.7 . 1.5)
                 :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
                 :image-converter ("dvisvgm %f --no-fonts --exact-bbox --scale=%S --output=%O")))
  )
Default Method
(setq org-preview-latex-default-process 'dvisvgm-svgcleaner)

Export

lualatex
(setq org-latex-compiler "lualatex")
export commands
(setq org-latex-pdf-process
      '("latexmk -f -pdf -%latex -interaction=nonstopmode -shell-escape -outdir=%o %f"))
Full width image
(setq org-latex-image-default-width "")
Listings
(setq org-latex-listings t
      org-latex-listings-options '(("basicstyle" "\\ttfamily\\footnotesize")
                                   ("breakatwhitespace" "true")
                                   ("breaklines" "true")
                                   ("commentstyle" "\\color{gray}")
                                   ("keepspaces" "true")
                                   ("keywordstyle" "\\color{red}")
                                   ("showspaces" "false")
                                   ("showstringspaces" "false")
                                   ("stringstyle" "\\color{Green}")
                                   ("tabsize" "2")))
document classes
mla
(after! ox-latex
  (add-to-list 'org-latex-classes
               '("mla" "\\documentclass[mla8]{mla}"
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                 ("\\paragraph{%s}" . "\\paragraph*{%s}")
                 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
apa
(after! ox-latex
  (add-to-list 'org-latex-classes
               '("apa" "\\documentclass[stu,biblatex]{apa7}"
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                 ("\\paragraph{%s}" . "\\paragraph*{%s}")
                 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
standalone
(after! ox-latex
  (add-to-list 'org-latex-classes
               '("standalone" "\\documentclass{standalone}"
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                 ("\\paragraph{%s}" . "\\paragraph*{%s}")
                 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))

Pandoc

nil

(setq org-pandoc-options-for-nil nil)

docx

(setq org-pandoc-options-for-docx '((lua-filter . "pagebreak.lua")))

Tasks

(setq org-log-done 'time)

Async export

(setq org-export-in-background 't)
(defadvice! fixed-+org--fix-async-export-a (fn &rest args)
  :override #'+org--fix-async-export-a
  (let ((old-async-init-file org-export-async-init-file)
        (org-export-async-init-file (make-temp-file "doom-org-async-export")))
    (with-temp-file org-export-async-init-file
      (prin1 `(progn (setq org-export-async-debug
                           ,(or org-export-async-debug
                                debug-on-error)
                           load-path ',load-path)
                     (unwind-protect
                         (let ((file ,old-async-init-file))
                           (if file
                               (load file nil t)
                             (load ,early-init-file nil t)
                             (require 'doom-start)))
                       (delete-file load-file-name)))
             (current-buffer)))
    (apply fn args)))

Prose stuff

setup vale

(flycheck-vale-setup)

Writeroom width

(setq writeroom-width 100)

Plantuml use system jar

(setq plantuml-jar-path "/usr/share/java/plantuml/plantuml.jar")

cc

default indentation

(after! cc-mode
  (setq c-default-style '((awk-mode . "awk")
                          (other . "linux")))
  (setq-default c-basic-offset 2)
  (c-set-offset 'innamespace 0))

clang files

Java disable lsp format

(setq lsp-java-format-enabled nil)

lsp

sideline

(setq lsp-ui-sideline-update-mode 'line
      lsp-ui-sideline-diagnostic-max-lines 99)

doc

(setq lsp-ui-doc-enable nil)

zoxide

(map! :leader
      :desc "Find file with zoxide" "f z" #'zoxide-find-file)