Files
EmacsConfig/init.el
2021-08-21 21:33:23 -04:00

215 lines
6.7 KiB
EmacsLisp

;; -*- lexical-binding: t -*-
;; Bootstrap straight.el for package management
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; Disable package.el from loading at startup
(setq package-enable-at-startup nil)
;; Ensure custom writes to specific file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file 'noerror 'nomessage)
;; Change the location of file backups/locks into the emacs.d/backups/
(setq backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups"))))
;;;; VISUAL
;; Disable Scroll bar, menubar
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;; Set location of custom theme dir
(setq custom-theme-directory (concat user-emacs-directory "themes"))
(load-theme 'UniverseHighContrast)
;;;; END VISUAL
;;;; PACKAGE INSTALL AND CONFIG
;; Set the packagemanager of use-package
(setq straight-use-package-by-default t)
;; Default to lazy loading
(setq use-package-always-defer t)
;; Ensure use-package.el is installed
(straight-use-package 'use-package)
;; Ensure shell variables are loaded
(use-package exec-path-from-shell
:init
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
)
;; Profiling
(use-package esup)
;; Prevents emacs and packages from messily writing to dirs
(use-package no-littering
:demand t)
;;;; Science Related
(use-package conda)
;;;; End Science Related
;;;; Web Related
(use-package web-mode
:init
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
)
(use-package php-mode)
;;;; End Web related
;;;; C Related
(use-package irony
:init
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
)
;;;; End C Related
;;;; Company Related
(use-package company :demand t
:bind
(("C-<tab>" . company-complete))
:custom-face
(company-preview ((t (:background "#000000" :foreground "#ffffff"))))
(company-preview-common ((t (:inherit company-preview :foreground "#ff00cf"))))
(company-preview-search ((t (:inherit company-preview :background "black"))))
(company-scrollbar-bg ((t (:background "grey35"))))
(company-scrollbar-fg ((t (:background "#a22390"))))
(company-template-field ((t (:background "grey75" :foreground "black"))))
(company-tooltip ((t (:background "#353535" :foreground "white"))))
(company-tooltip-common ((t (:foreground "magenta"))))
(company-tooltip-mouse ((t (:inherit company-tooltip-selection))))
(company-tooltip-search ((t (:inherit company-tooltip-selection))))
(company-tooltip-search-selection ((t (:inherit company-tooltip-selection))))
(company-tooltip-selection ((t (:background "#4584a2" :foreground "white"))))
)
(add-hook 'after-init-hook 'global-company-mode)
; Python
(use-package company-jedi)
; C related
(use-package company-ctags)
(use-package company-c-headers)
(use-package company-irony)
; Haskell
(use-package company-ghci)
;;;; End Company Related
;;;; Haskell Related
(use-package haskell-mode
:config
(setq haskell-mode-hook '(flyspell-prog-mode interactive-haskell-mode))
)
(use-package ghci-completion)
;;;; End Haskell Related
;;;; Org Related
;; (use-package org)
(use-package org-contrib)
(use-package org
:config
(require 'org-tempo)
(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")
(with-eval-after-load 'ox-latex
(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")))
)
; References etc.
(use-package org-ref
:after org
:defer t
:config
(setq reftex-default-bibliography '("~/Documents/Bibliography/references.bib"))
;; see org-ref for use of these variables
(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/")
)
; PDF preview etc.
(use-package pdf-tools)
; better TEX
(use-package auctex
:after org)
; Plotting support
(use-package gnuplot)
;;Org Auto Wrap Config
(add-hook 'org-mode-hook 'auto-fill-mode)
(set-fill-column 100)
;;;; End Org Related
;; ghci-completion company-ghci
;; exec-path-from-shell nix-haskell-mode haskell-mode
;; pyvenv rainbow-mode company-ctags company-jedi
;; company-anaconda anaconda-mode matlab-mode markdown-mode company-irony-c-headers company-irony irony rust-mode company-c-headers cdlatex auctex use-package smog conda gnuplot php-mode web-mode org-ref pdf-tools chess
;;;; END PACKAGES