;;; Init --- Emacs settings ;;; Commentary: ;;; Code: ;; set up local directory ;(add-to-list 'load-path "~/.emacs.d/lisp/") (add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) (setq-default flycheck-emacs-lisp-load-path 'inherit) ;; 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) ;; 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 load-path (cons (concat user-emacs-directory "lisp") load-path) 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) ;; show matching parenthesis ;(show-paren-mode 1) ;; 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) ;; disable annoying ring-bell when backspace key is pressed in certain situations (setq ring-bell-function 'ignore) ;; use utf-8 (prefer-coding-system 'utf-8) (set-language-environment "UTF-8") (set-default-coding-systems 'utf-8) (defvar use-pragmata) (setq use-pragmata (not (equal (system-name) "cleanse"))) ;; 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)) (if use-pragmata (set-frame-font "PragmataPro Liga 24" nil t) (set-frame-font "Iosevka 24" nil t)) (set-foreground-color "#c7c7c7") (set-background-color "#000000")) ;; set up font ligatures (use-package pragmatapro-lig :if (and window-system use-pragmata) :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))) ;; try using a fancier mode line (use-package doom-modeline :ensure t :init (doom-modeline-mode 1) :config (setq doom-modeline-height 1 doom-modeline-buffer-file-name-style 'truncate-all ;doom-modeline-buffer-file-name-style 'truncate-with-project ;doom-modeline-buffer-file-name-style 'relative-to-project doom-modeline-buffer-encoding nil) (display-battery-mode 1)) ;; line numbers (add-hook 'prog-mode-hook 'display-line-numbers-mode) (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) ;; 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) ;; work with multiple files not in same directory (require 'find-dired) (setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld")) ;; 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 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) (use-package rust-mode) (use-package which-key :ensure t :init (which-key-mode)) (defun my/ansi-colorize-buffer () (let ((buffer-read-only nil)) (ansi-color-apply-on-region (point-min) (point-max)))) (use-package ansi-color :ensure t :config (add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)) ;; 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)) (use-package company :hook (scala-mode . company-mode) (java-mode . company-mode) (emacs-lisp-mode . company-mode) (rust-mode . company-mode) (python-mode . company-mode) :bind (("M-/" . company-complete)) :config (add-hook 'after-init-hook 'global-company-mode)) (defvar use-lsp) (setq use-lsp (equal (system-name) "cult")) ;; when not using lsp use hippie expand (when (not use-lsp) ;; 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))) ;; Posframe is a pop-up tool that must be manually installed for dap-mode (use-package posframe :if use-lsp) ;; Use the Debug Adapter Protocol for running tests and debugging (use-package dap-mode :if use-lsp :hook (lsp-mode . dap-mode) (lsp-mode . dap-ui-mode)) (use-package flycheck :if use-lsp :init (global-flycheck-mode)) (use-package lsp-mode :if use-lsp :ensure t :config (setq lsp-headerline-breadcrumb-enable nil lsp-keymap-prefix "C-c l" lsp-enable-symbol-highlighting nil ;lsp-lens-enable nil ;lsp-signature-render-documentation nil lsp-eldoc-enable-hover nil ;lsp-signature-auto-activate nil ;lsp-enable-file-watchers nil read-process-output-max (* 1024 1024) ; 1M lsp-modeline-diagnostics-enable nil lsp-prefer-capf t lsp-completion-provider :capf lsp-completion-enable t lsp-prefer-flymake nil) ;(setf (lsp--client-multi-root (gethash 'iph lsp-clients)) nil) (define-key lsp-mode-map (kbd "C-c l") lsp-command-map) :hook (lsp-mode . lsp-lens-mode) (lsp-mode . lsp-enable-which-key-integration) (scala-mode . lsp) (rust-mode . lsp) (java-mode . lsp)) (use-package lsp-metals :if use-lsp :ensure t :config (setq lsp-metals-server-args '("-J-Dmetals.allow-multiline-string-formatting=off") lsp-metals-show-inferred-type nil lsp-metals-super-method-lenses-enabled nil lsp-metals-show-implicit-arguments nil lsp-meatals-show-implicit-conversions-and-classes nil)) (use-package lsp-ui :if use-lsp :ensure t :hook (lsp-mode . lsp-ui-mode) :config (setq lsp-ui-doc-enable nil lsp-ui-sideline-enable t ;lsp-ui-sideline-show-code-actions nil lsp-ui-sideline-diagnostic-max-line-length 60 lsp-ui-sideline-diagnostic-max-lines 6)) (use-package lsp-java :if use-lsp :ensure t :config (add-hook 'java-mode-hook 'lsp)) ;; 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)) ;; 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))) ;; magit (use-package magit :commands magit-status magit-blame :bind (("C-x g" . magit-status) ("s-b" . magit-blame)) :init ;; Have magit-status go full screen and quit to previous ;; configuration. Taken from ;; http://whattheemacsd.com/setup-magit.el-01.html#comment-748135498 ;; and http://irreal.org/blog/?p=2253 (defadvice magit-status (around magit-fullscreen activate) (window-configuration-to-register :magit-fullscreen) ad-do-it (delete-other-windows)) (defadvice magit-quit-window (after magit-restore-screen activate) (jump-to-register :magit-fullscreen)) :config (remove-hook 'magit-status-sections-hook 'magit-insert-tags-header) (remove-hook 'magit-status-sections-hook 'magit-insert-status-headers) (remove-hook 'magit-status-sections-hook 'magit-insert-unpushed-to-pushremote) (remove-hook 'magit-status-sections-hook 'magit-insert-unpulled-from-pushremote) (remove-hook 'magit-status-sections-hook 'magit-insert-unpulled-from-upstream) (remove-hook 'magit-status-sections-hook 'magit-insert-unpushed-to-upstream-or-recent) (setq magit-refresh-verbose t ; xyz magit-revert-buffers nil)) (use-package org-roam :if (equal (system-name) "cult") :config (setq org-roam-directory "~/org/") (org-roam-db-autosync-mode)) ;; 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) ;; json (use-package json-mode) ;; custom load path for ad-hoc lisp (add-to-list 'load-path (file-truename (concat user-emacs-directory "lisp"))) ;; 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)) ;; lua (use-package lua-mode) ;; pico-8 (use-package pico8-mode :straight (pico8-mode :type git :host github :repo "Kaali/pico8-mode")) ;; 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))) ;; yaml (use-package yaml-mode) ;; hcl / terraform (use-package hcl-mode) ;; dired (setq dired-auto-revert-buffer t) (defun my/toggle-dotfiles () "Toggle visibility of files starting with dot." (interactive) (if (equal dired-listing-switches "-al") (setq dired-listing-switches "-l") (setq dired-listing-switches "-al"))) ;;; 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 emms-repeat-playlist t 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://")) ;; ;; pdf/latex ;; (use-package doc-view ;; :custom doc-view-resolution 1600 ;; doc-view-scale-internally nil) ;; 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 (not indent-tabs-mode))) ;; handy function to regenerate tags (defun my/regenerate-tags () "Regenerate tags using ets." (interactive) (defun my/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") (my/runloop next))))))) (my/runloop default-directory)) (global-set-key (kbd "C-t") 'my/regenerate-tags) ;; spell checking as you type in text-mode ;(autoload 'flyspell-mode-on "flyspell" "On-the-fly ispell." t) (add-hook 'text-mode-hook 'flyspell-mode-on) ;; use nicer diff colors (defun my/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" '(my/update-diff-colors)) ;; (custom-set-variables ;; ;; custom-set-variables was added by Custom. ;; ;; If you edit it by hand, you could mess it up, so be careful. ;; ;; Your init file should contain only one such instance. ;; ;; If there is more than one, they won't work right. ;; '(ansi-color-names-vector ;; ["#171717" "#E2434C" "#86B187" "#E0D063" "#8AC6F2" "#E18Cbb" "cyan" "#F6F3E8"] ;; (custom-set-faces ;; ;; custom-set-faces was added by Custom. ;; ;; If you edit it by hand, you could mess it up, so be careful. ;; ;; Your init file should contain only one such instance. ;; ;; If there is more than one, they won't work right. ;; ) (provide 'init) ;;; init.el ends here