Files
EmacsConfig/main.org

11 KiB

Universe Emacs Config

Intialization

We must initialize leaf.el, which we use as a use-package replacement for defining configs for different things.

  ;; <leaf-install-code>
  (eval-and-compile
    (customize-set-variable
     'package-archives '(("org" . "https://orgmode.org/elpa/")
			 ("melpa" . "https://melpa.org/packages/")
			 ("gnu" . "https://elpa.gnu.org/packages/")))
    (package-initialize)
    (unless (package-installed-p 'leaf)
      (package-refresh-contents)
      (package-install 'leaf))

    (leaf leaf-keywords
      :ensure t
      :init
      (leaf el-get :ensure t)
      (leaf hydra :ensure t)
      (leaf blackout :ensure t)

      :config
      ;; initialize leaf-keywords.el
      (leaf-keywords-init)))
  ;; </leaf-install-code>

  (leaf leaf-tree :ensure t)
  (leaf leaf-convert :ensure t)
  (leaf transient-dwim
    :ensure t
    :bind (("M-=" . transient-dwim-dispatch)))
  (leaf custom-el
	:config
	;; Ensure custom writes to specific file
	(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
	(load custom-file 'noerror 'nomessage))
  (leaf backup
	:config
	;; Change the location of file backups/locks into the emacs.d/backups/
	(setq backup-directory-alist
	      `(("." . ,(concat user-emacs-directory "backups")))))

Visual Customization

(leaf visual
  :doc "Visual Changes to Emacs"
  :tag "builtin" "internal"
  :custom ((menu-bar-mode . nil)
	   (tool-bar-mode . nil)
	   (scroll-bar-mode . nil))
  :custom-face ((default . '((t (:family "JuliaMono"
					 :height 150
					 :weight normal)))))
  :config (prog1 'visual
	   ;; Set location of custom theme dir
	   (setq custom-theme-directory (concat user-emacs-directory "themes"))
	   (load-theme 'UniverseHighContrast)))

Package Configuration

Path Preservation

Exec-path-from-shell ensures that path variable is preserved from shell.

  (leaf exec-path-from-shell :ensure t
    :config
    (exec-path-from-shell-initialize))

Font Related

Ligature

Font related ligatures, combining multiple characters into "one".

  (leaf ligature
	:ensure t
	:config
	;; Enable the "www" ligature in every possible major mode
	(ligature-set-ligatures 't '("www"))
	;; Enable traditional ligature support in eww-mode, if the
	;; `variable-pitch' face supports it
	(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
	;; Enable all Cascadia Code ligatures in programming modes
	(ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
					     ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
					     "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
					     "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
					     "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
					     "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
					     "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
					     "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
					     ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
					     "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
					     "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
					     "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
					     "\\\\" "://"))
	;; Enables ligature checks globally in all buffers. You can also do it
	;; per mode with `ligature-mode'.
	(global-ligature-mode t))

Profiling

  (leaf esup :disabled nil :ensure t)

Version Control

  (leaf magit :ensure t :require t)

Nix Related

Direnv

In order to support direnv (loading nix-shell / nix develop)

  (leaf direnv
	:ensure t
	:hook
	(direnv-mode))

Nix-mode

.nix file mode

  (leaf nix-mode :ensure t)

WEB

We all know the web is the future, obviously, of course.

  (leaf web-mode
	:ensure t
	:mode
	"\\.p?html?\\'"
	"\\.djtml\\'"
	"\\.jsx?\\'"
	"\\.tsx?\\'")
  (leaf php-mode
	:ensure t)

D2

  (leaf d2-mode :ensure t)

YAML

  (leaf yaml-mode :ensure t)

IDE Like Things

Company Completion!

We like autocomplete, it… is nice, okay?

  (leaf company :ensure t
    :bind
    (("C-<tab>" . company-complete))
    :hook after-init-hook
    :config (global-company-mode))

Language Server Protocol

We love language features that make languages nice

  (leaf lsp-mode
    :ensure t
    :init
    (setq lsp-keymap-prefix "C-c l")
    :hook
    ((dart-mode-hook . lsp)
     (python-mode-hook . lsp)
     (c-mode-hook . lsp)
     (c++-mode-hook . lsp)
     (haskell-mode-hook . lsp)
     (java-mode-hook . lsp)
     (rust-mode-hook . lsp)
     ;; which key support v v v
     (lsp-mode-hook . lsp-enable-which-key-integration))
    :commands lsp
    :config
    (leaf lsp-ui :ensure t
	  :commands lsp-ui-mode)
    (leaf flycheck :ensure t)
    (leaf lsp-treemacs :ensure t
	  :commands lsp-treemacs-errors-list)
    (leaf helm-lsp :ensure t
	  :commands helm-lsp-workspace-symbol)
    (leaf dap-mode :ensure t)
    (leaf which-key :ensure t
	  :config (which-key-mode)))
Projectile (Projects)
  (leaf projectile
    :commands projectile-mode
    :config
    (projectile-mode +1))

Python Things

Python-mode

Using python-mode is to have more up to date features (and highlighting) compared to builtin python-mode.

  (leaf python-mode :ensure t
	:config
	(setq python-shell-interpreter "ipython"
	      python-shell-interpreter-args "-i --simple-prompt --InteractiveShell.display_page=True"))

Poetry

For when we aren't nix'ing things, and want some nice poetry.

  (leaf poetry :ensure t)

Java

LSP for java is nice.

  (leaf lsp-java
	:hook (java-mode-hook . lsp))

C

Who even needs C++, not me, no way, no how.

  (leaf company-ctags :ensure t)
  (leaf company-c-headers :ensure t)
  (leaf meson-mode :ensure t)

Haskell

  (leaf haskell-mode :ensure t
	:config
	(leaf lsp-haskell :ensure t)
	(leaf company-ghci :ensure t))

Rust

  (leaf rust-mode :ensure t)

Minecraft??

Minecraft mcfunction support, because, it can be annoying to type this stuff otherwise.

  (leaf mcf-mode
	:el-get rasensuihei/mcf)

Lisps

Gonna need to have pretty brackets

  (leaf rainbow-delimiters
	:ensure t
	:commands rainbow-delimiters-mode
	:config
	(leaf rainbow
	      :hook (emacs-lisp-mode-hook . rainbow-delimiters-mode)
	      (geiser-mode-hook . rainbow-delimiters-mode)))

Racket

Makes using racket so much nicer

  (leaf geiser-racket :ensure t)

Org

We use org-ref because it provides some niceties, like doi-utils for updating our bibliography.

  (leaf ivy-bibtex :ensure t)
  (leaf helm-bibtex :ensure t)
  (leaf org-ref :ensure t
	:after org
	:init
	(leaf pdf-tools :ensure t)
	:config
	:require org-ref org-ref-ivy org-ref-helm doi-utils)

For more export formats we use pandoc:

  (leaf ox-pandoc :ensure t
	:after org)

Nicer LaTeX editing (AuCTeX):

  (leaf auctex :ensure t
	:after org)

We also ma(k|d)e use of org-tempo for templating things, which can be nice. Should use the export based templating probably. Eventually.

  (leaf org-cfg
	:after org
	:require org-ref oc-csl org-tempo ox-latex ox-pandoc
	:init
	:bind
	("C-c ]" . org-ref-insert-link)
	("s-[" . org-ref-insert-link-hydra/body)
	:hook
	(org-mode-hook . auto-fill-mode)
	:config
	(set-fill-column 100)
	(setq org-src-fontify-natively t
	      org-confirm-babel-evaluate nil
	      org-src-preserve-indentation t)

	(setq bibtex-completion-bibliography
	      (list (expand-file-name "~/Documents/Bibliography/references.bib")))

	(setq org-ref-bibliography-notes "~/Documents/Bibliography/notes.org"
	      org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
	      org-ref-pdf-directory "~/Documents/Bibliography/bibtex-pdfs/")

	(setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body
	      org-ref-insert-cite-function 'org-ref-cite-insert-helm
	      org-ref-insert-label-function 'org-ref-insert-label-link
	      org-ref-insert-ref-function 'org-ref-insert-ref-link
	      org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body)))
	(tempo-define-template
	 "Lab Template" '("#+TITLE: PHY324: LAB TITLE"n
			  "#+AUTHOR: ***REMOVED*** | ***REMOVED***"n
			  "#+DATE: \\today"n
			  "#+LATEX_HEADER: \\usepackage{natbib}"n
			  "#+LATEX_HEADER: \\usepackage{float}"n
			  "#+LATEX_CLASS: labtemplate"n
			  "#+OPTIONS: toc:nil"n
			  ""n
			  "* Abstract:"n
			  "* Introduction:"n > p
			  "* Methods:"n
			  "* Results:"n
			  "* Discussion:"n
			  "bibliographystyle:ieeetr"n
			  "bibliography:~/Documents/Bibliography/references.bib" >)
	 "<LAB" "Insert Lab Template With Headings")
	(tempo-define-template "Fig. Caption"
			       '("" (P "Image: " image t)
				 (P "Caption: " caption t)
				 (P "Figure Name: " name t)
				 "#+CAPTION: " (s caption) > n >
				 "#+NAME: fig:" (s name) > n >
				 "#+ATTR_LaTeX: :placement [H]" > n >
				 "[[" (s image) "]]" > n > p >)
			       "<fig" "Inserts Figure with Caption")
	(add-to-list 'org-latex-packages-alist '("" "minted"))
	(setq org-latex-listings 'minted) 

	(add-to-list 'org-latex-classes
		     '("labtemplate" "\\documentclass{labtemplate}"
		       ("\\section{%s}" . "\\section*{%s}")
		       ("\\subsection{%s}" . "\\subsection*{%s}")
		       ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
		       ("\\paragraph{%s}" . "\\paragraph*{%s}")
		       ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
		     )

	(setq org-latex-pdf-process
	      '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f"
		"%latex -shell-escape -interaction nonstopmode -output-directory %o %f"
		"bibtex %b"
		"%latex -shell-escape -interaction nonstopmode -output-directory %o %f"
		"%latex -shell-escape -interaction nonstopmode -output-directory %o %f")))

And in case we want to make some (GNU)?plots?

  (leaf gnuplot
	:ensure t)

Flutter

  (leaf dart-mode :ensure t)
  (leaf lsp-dart :ensure t)

BQN

  (leaf bqn-mode
    :el-get "museoa/bqn-mode"
    :config
    (leaf bqn-font
	  :after bqn-mode
	  :config
	  (set-face-attribute 'bqn-default nil :family 'unspecified)))