emacs.d/init.el

416 lines
12 KiB
EmacsLisp
Raw Normal View History

2022-05-13 17:04:23 -04:00
;;; Init --- Emacs settings
;;; Commentary:
;;; Code:
2022-05-03 18:30:29 -04:00
;; set up straight.el
(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))
;; set up use-package
(straight-use-package 'use-package)
2022-05-03 18:30:29 -04:00
;; set a bunch of varibles
(setq user-full-name "d_m"
user-mail-address "d_m@plastic-idolatry.com"
straight-use-package-by-default t
package-enable-at-startup nil
straight-vc-git-default-protocol 'https
2022-05-03 18:54:16 -04:00
load-path (cons (concat user-emacs-directory "lisp") load-path)
2022-05-03 18:30:29 -04:00
inhibit-startup-screen t
org-directory "~/org/"
line-move-visual nil
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
column-number-mode t
diff-switches "-u"
large-file-warning-threshold nil
sentence-end-double-space nil
mode-line-compact nil
company-idle-delay nil
company-tooltip-idle-delay nil
dired-kill-when-opening-new-dired-buffer t
read-minibuffer-restore-windows t
frame-background-mode 'dark)
;; turn off UI various gizmos
(set-face-attribute 'mode-line nil :box nil)
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(blink-cursor-mode 0)
;; use utf-8
(prefer-coding-system 'utf-8)
;; UI settings when not in a terminal
(when (display-graphic-p)
(setq mac-option-key-is-meta nil
mac-command-key-is-meta t
mac-command-modifier 'meta
mac-option-modifier nil
x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
2022-05-05 12:28:09 -04:00
(set-frame-font "PragmataPro Liga 24" nil t)
2022-05-03 18:30:29 -04:00
(set-foreground-color "#c7c7c7")
(set-background-color "#000000"))
;; set up font ligatures
(use-package pragmatapro-lig
:straight (pragmatapro-lig :type git
:host github
:repo "lumiknit/emacs-pragmatapro-ligatures")
:config (add-hook 'prog-mode-hook 'pragmatapro-lig-mode))
;; interactive font size
(defun set-font-size ()
"Set font size interactively."
(interactive)
(let* ((family (face-attribute 'default :family))
(curHeight (face-attribute 'default :height))
(curSize (/ curHeight 10))
(newSize (string-to-number (read-string "Font-size: " (number-to-string curSize))))
(newHeight (* newSize 10)))
(set-face-attribute 'default nil :height newHeight)))
2022-05-12 16:05:12 -04:00
;; ;; use doom themes
;; (use-package doom-themes
;; :straight (doom-themes :type git
;; :host github
;; :repo "doomemacs/themes")
;; :config (load-theme 'doom-badger t)
;; (setq doom-badger-brighter-comments t
;; doom-themes-treemacs-theme "doom-colors")
;; ; (set-face-foreground-color 'font-lock-constant-face #635770)
;; (set-face-foreground 'font-lock-constant-face "#834980")
;; (doom-themes-neotree-config)
;; (doom-themes-treemacs-config)
;; (doom-themes-org-config))
2022-05-05 12:28:09 -04:00
;; try using a fancier mode line
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
:config
(setq doom-modeline-height 1
2022-05-12 16:05:12 -04:00
doom-modeline-buffer-file-name-style 'truncate-all
;doom-modeline-buffer-file-name-style 'truncate-with-project
2022-05-05 12:28:09 -04:00
;doom-modeline-buffer-file-name-style 'relative-to-project
doom-modeline-buffer-encoding nil)
(display-battery-mode 1))
2022-05-03 18:30:29 -04:00
;; line numbers
2022-05-04 14:29:15 -04:00
;(global-display-line-numbers-mode t)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
2022-05-03 18:30:29 -04:00
(setq display-line-numbers "%4d ")
;; allow y or n instead of yes or no
(fset 'yes-or-no-p 'y-or-n-p)
;; C-x p to get back to mark
(bind-key "C-x p" 'pop-to-mark-command)
(setq set-mark-command-repeat-pop t)
2022-05-05 12:28:09 -04:00
;; install icons
(use-package all-the-icons
:if (display-graphic-p)
:config (let ((icon '(all-the-icons-faicon "recycle" :face all-the-icons-dcyan)))
(setq all-the-icons-mode-icon-alist
(cons (cons 'uxntal-mode icon) all-the-icons-mode-icon-alist))
(setq all-the-icons-extension-icon-alist
(cons (cons "tal" icon) all-the-icons-extension-icon-alist))))
;; show function names in modeline
(which-function-mode t)
2022-05-03 18:30:29 -04:00
;; work with multiple files not in same directory
(require 'find-dired)
(setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld"))
;; hippie expand stuff: M-/ to expand things
(bind-key "M-/" 'hippie-expand)
(defun sanityinc/dabbrev-friend-buffer (other-buffer)
(< (buffer-size other-buffer) (* 1 1024 1024)))
(setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
(setq hippie-expand-try-functions-list
'(try-expand-all-abbrevs
try-complete-file-name-partially
try-complete-file-name
try-expand-dabbrev
try-expand-dabbrev-from-kill
try-expand-dabbrev-all-buffers
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;; comment regions using C-c # (uncomment with C-u C-c #)
(global-set-key "\C-c#" 'comment-region)
(setq comment-empty-lines nil)
;; indent regions using C-c > and C-c <
(global-set-key "\C-c>" 'indent-region)
(global-set-key "\C-c<" 'unindent-region)
;; use M-g to go to a certain line
(global-set-key "\M-g" 'goto-line)
;; use M-$ to do query-replace-regexp
(global-set-key "\M-$" 'query-replace-regexp)
;; modes
(electric-indent-mode 0)
;; global keybindings
(global-unset-key (kbd "C-z"))
; synchronize emacs exec-path and $PATH
(use-package exec-path-from-shell
:config (when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
;; rainbow delimiters
(use-package rainbow-delimiters)
;; distraction free writing
(use-package writeroom-mode)
;; C-c <left> restore old buffer view after popups
(use-package winner
:config (winner-mode 1))
;; compact mode line
(use-package smart-mode-line)
;; various modes that might come in handy
(use-package markdown-mode)
(use-package racket-mode)
(use-package tuareg)
(use-package forth-mode)
;; scala-mode
(use-package scala-mode
:mode "\\.s\\(cala\\|bt\\)$"
:interpreter ("scala" . scala-mode)
:config
(setq scala-indent:indent-value-expression nil
scala-indent:align-parameters nil
scala-indent:align-forms nil
scala-indent:use-javadoc-style t))
2022-05-13 17:04:23 -04:00
;;; Enable nice rendering of diagnostics like compile errors.
;(use-package flycheck
; :init (global-flycheck-mode))
2022-05-12 16:05:12 -04:00
2022-05-03 18:30:29 -04:00
;; (use-package lsp-mode
;; :ensure t)
;; ; :init (setq lsp-prefer-flymake nil))
;;
;; (use-package lsp-ui
;; :ensure t
;; :hook (lsp-mode . lsp-ui-mode))
;;
;; (use-package lsp-scala
;; :after scala-mode
;; :demand t
;; ; :hook (scala-mode . lsp)
;; :init (setq lsp-scala-server-command "~/bin/metals-emacs"))
;; projectile
(use-package projectile
:demand
:init (setq projectile-use-git-grep t)
;;;:config (projectile-global-mode t)
:bind (("C-c C-f" . projectile-find-file)
("C-c C-g" . projectile-ripgrep)))
;; ripgrep
(use-package rg)
;; ido
(use-package flx-ido
:demand
:init (setq ido-show-dot-for-dired nil
ido-enable-dot-prefix nil
ido-use-faces t)
:config (ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1))
;; highlight-symbol
(use-package highlight-symbol
:diminish highlight-symbol-mode
:commands highlight-symbol
:bind ("s-h" . highlight-symbol))
;; popup-imenu
(use-package popup-imenu
:commands popup-imenu
:bind ("M-i" . popup-imenu))
2022-05-12 16:05:12 -04:00
;; eyebrowse
(use-package eyebrowse
:config (eyebrowse-mode t)
:bind (("M-0" . eyebrowse-switch-to-window-config-0)
("M-1" . eyebrowse-switch-to-window-config-1)
("M-2" . eyebrowse-switch-to-window-config-2)
("M-3" . eyebrowse-switch-to-window-config-3)
("M-4" . eyebrowse-switch-to-window-config-4)
("M-5" . eyebrowse-switch-to-window-config-5)
("M-6" . eyebrowse-switch-to-window-config-6)
("M-7" . eyebrowse-switch-to-window-config-7)
("M-8" . eyebrowse-switch-to-window-config-8)
("M-9" . eyebrowse-switch-to-window-config-9)))
2022-05-03 18:30:29 -04:00
;; magit
(use-package magit
:commands magit-status magit-blame
:init (setq magit-revert-buffers nil)
:bind (("C-x g" . magit-status)
("s-b" . magit-blame)))
;; org roam
(use-package org-roam
2022-05-24 13:29:10 -04:00
:custom (org-roam-directory "~/org/")
:config (org-roam-db-autosync-mode))
2022-05-03 18:30:29 -04:00
;; git-gutter
(use-package git-gutter
:config (global-git-gutter-mode t)
(set-face-foreground 'git-gutter:modified "orange")
(set-face-foreground 'git-gutter:added "green")
(set-face-foreground 'git-gutter:deleted "red")
(setq git-gutter:handled-backends '(git hg svn))
(global-set-key (kbd "C-x n") 'git-gutter:next-hunk))
;; git-timemachine
(use-package git-timemachine
:config (add-hook 'git-timemachine-mode-hook (lambda () (ensime-mode 0))))
;; json
(use-package json-mode)
;; glauce
(require 'glauce-mode)
;; uxntal
(use-package uxntal-mode
:straight (uxntal-mode :type git
:host github
:repo "non/uxntal-mode")
:bind ("C-c d" . uxntal-explain-word)
:config (setq uxntal-mode-strict-comments nil))
;; C-c C-c for M-x compile
(global-set-key "\C-c\C-c" 'compile)
;; bazel
(use-package bazel
:straight (bazel :type git
:host github
:repo "bazelbuild/emacs-bazel-mode")
:bind ("C-c C-b" . bazel-build)
:config (setq bazel-command '("/usr/local/bin/bazel")))
;; thrift
(use-package thrift-mode
:straight (thrift-mode :type git
:host github
:repo "davidmiller/thrift-mode")
:config (add-to-list 'auto-mode-alist '("\\.thrift\\'" . thrift-mode)))
2022-05-17 13:09:54 -04:00
;; yaml
(use-package yaml-mode)
2022-05-03 18:30:29 -04:00
;;; turn off branch in mode line for now
;(setq vc-handled-backends nil)
;; force vc to update branches, etc. (unused for now)
(defun force-update-vcs ()
"Update vc in all verson-controlled buffers"
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(vc-refresh-state))))
;; playing music in emacs
(use-package emms
:config
(setq emms-source-file-default-directory "~/bandcamp/"
emms-browser-covers 'emms-browser-cache-thumbnail-async
2022-05-17 13:09:54 -04:00
emms-repeat-playlist t
2022-05-03 18:30:29 -04:00
scroll-up-aggressively 0.0
scroll-down-aggressively 0.0
emms-playlist-buffer-name "*Music*")
(emms-all)
(emms-default-players))
;; browsing gemini/gopher sites in emacs
(use-package elpher
:config
(setq elpher-default-url-type "gemini://"))
;; local copy in .emacs.d/lisp
(require 'etags-select)
;; don't case fold for ctags
(setq tags-case-fold-search nil)
;; whitespace stuff
(require 'whitespace)
(global-whitespace-mode t)
(setq whitespace-style '(newline tab-mark))
(setq-default indent-tabs-mode nil
tab-width 4
c-basic-offset 4
show-trailing-whitespace t)
;; handy function to toggle tabs
(defun toggle-indent-tabs ()
"Toggle tabs on/off"
(interactive)
(setq indent-tabs-mode (if (indent-tabs-mode) nil t)))
;; handy function to regenerate tags
(defun regenerate-tags ()
"regenerate-tags"
(interactive)
(defun runloop (dir)
(let ((tagfile (concat dir "TAGS")))
(if (file-exists-p tagfile)
(let ((default-directory dir))
(progn
(shell-command "echo generating tags...")
(async-shell-command "ets")))
(progn
(let ((next (file-name-directory (directory-file-name dir))))
(if (equal dir next) (shell-command "uptime") (runloop next)))))))
(runloop default-directory))
(global-set-key (kbd "C-t") 'regenerate-tags)
;; spell checking as you type in text-mode
2022-05-17 13:12:05 -04:00
;(autoload 'flyspell-mode-on "flyspell" "On-the-fly ispell." t)
2022-05-03 18:30:29 -04:00
(add-hook 'text-mode-hook 'flyspell-mode-on)
;; use nicer diff colors
(defun update-diff-colors ()
"update the colors for diff faces"
(set-face-foreground 'diff-added "green")
(set-face-foreground 'diff-removed "red")
(set-face-foreground 'diff-changed "purple"))
(eval-after-load "diff-mode"
'(update-diff-colors))