Skip to content

Instantly share code, notes, and snippets.

@alexispurslane
Last active June 6, 2024 16:49
Show Gist options
  • Save alexispurslane/7e73a1c4f3368752609bdafafc86004b to your computer and use it in GitHub Desktop.
Save alexispurslane/7e73a1c4f3368752609bdafafc86004b to your computer and use it in GitHub Desktop.
Kira's init
(setq gc-cons-threshold-original gc-cons-threshold)
(setq gc-cons-threshold most-positive-fixnum)
(run-with-timer 5 0 (lambda ()
(setq gc-cons-threshold gc-cons-threshold-original)
(message "Restored GC cons threshold")))
;;; ======Prelude======
(require 'cl-lib)
(require 'rx)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(require 'use-package-ensure)
(setq use-package-always-ensure t
package-enable-at-startup nil
use-package-compute-statistics t)
(use-package emacs
:init
;;;; Setting up Emacs to behave in a more familiar and pleasing way
(setq visible-bell t ; nobody likes being beeped at
make-backup-files nil ; don't litter all over the place
warning-minimum-level :emergency ; don't completely shit the bed on errors
display-line-numbers 'relative) ; whether you use evil or not, these are useful
(setq-default fill-column 65) ; this will be used in reading modes, so set it to something nice
(setq read-file-name-completion-ignore-case t ; ignore case when completing file names
read-buffer-completion-ignore-case t ; ignore case when completing buffer names
completion-ignore-case t) ; fucking ignore case in general!
(setopt use-short-answers t) ; so you don't have to type out "yes" or "no" and hit enter
(setq-default buffer-face-mode-face 'variable-pitch)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) ; people are used to ESC quitting things
(setq display-line-numbers-width-start t) ; when you open a file, set the width of the linum gutter to be large enough the whole file's line numbers
(menu-bar-mode 1)
(tool-bar-mode -1)
(scroll-bar-mode 1)
;;;;; Enable some modes that give nicer, more modern behavior
(setq pixel-scroll-precision-interpolate-mice t
pixel-scroll-precision-interpolate-page t)
(pixel-scroll-precision-mode 1) ; smooth scrolling
(winner-mode 1) ; better window manipulation
(savehist-mode 1) ; remember commands
(global-visual-line-mode) ; wrap lines at end of window
;;;;; A basic programmming mode to build off of that adds some expected things
(add-hook 'text-mode-hook (lambda ()
(display-line-numbers-mode 1)
(setq display-line-numbers 'relative)
(hl-line-mode t)
(electric-pair-mode)))
;;;;; Performance tuning
(setq gc-cons-percentage 0.2)
;;;;;; Optimize font-locking for greater responsiveness
(setq jit-lock-stealth-time 0.2
jit-lock-defer-time 0.0
jit-lock-context-time 0.2
jit-lock-stealth-load 200)
;;;;;; Optimize for long lines.
(setq-default bidi-paragraph-direction 'left-to-right ; assume we're using LtR text unless explicitly told otherwise
bidi-inhibit-bpa t) ; turn off bidirectional paren display algorithm, it is expensive
;;;;;; Faster minibuffer
(defun setup-fast-minibuffer ()
(setq gc-cons-threshold most-positive-fixnum))
(defun close-fast-minibuffer ()
(setq gc-cons-threshold (* 8 1024 1024)))
(add-hook 'minibuffer-setup-hook #'setup-fast-minibuffer)
(add-hook 'minibuffer-exit-hook #'close-fast-minibuffer))
(use-package tab-bar
:init
(setq tab-bar-button-relief 0)
:config
(add-hook 'tab-bar-mode-hook
(lambda ()
(set-face-attribute 'tab-bar nil :inherit 'variable-pitch)))
(setq tab-bar-auto-width t
tab-bar-auto-width-max '(200 20)
tab-bar-auto-width-min '(200 20))
(setq tab-bar-new-tab-choice "*dashboard*")
(setq tab-bar-show t)
(tab-bar-mode 1))
(use-package icomplete
:demand t
:bind (:map icomplete-minibuffer-map
("RET" . icomplete-force-complete-and-exit)
("M-RET" . icomplete-fido-exit)
("TAB" . icomplete-force-complete)
("DEL" . icomplete-fido-backward-updir)
("<down>" . icomplete-forward-completions)
("<up>" . icomplete-backward-completions))
:config
;; remove arbitrary optimization limits that make icomplete
;; feel old-fashioned
(setq icomplete-delay-completions-threshold 0)
(setq icomplete-max-delay-chars 0)
(setq icomplete-compute-delay 0)
(setq icomplete-show-matches-on-no-input t)
(setq icomplete-hide-common-prefix nil)
(setq icomplete-prospects-height 15)
(setq icomplete-with-completion-tables t)
(setq completion-styles '(flex substring basic)
orderless-component-separator "-"
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion))))
(icomplete-vertical-mode 1))
(use-package marginalia
:after icomplete
:init
(marginalia-mode))
(use-package which-key
:init (which-key-mode)
:diminish which-key-mode
:custom
(which-key-idle-delay 0.1)
(which-key-idle-secondary-delay nil)
(which-key-sort-order #'which-key-key-order-alpha))
(use-package org
:commands (org-mode)
:config
(set-face-attribute 'org-level-1 nil :height 2.0)
(set-face-attribute 'org-level-2 nil :height 1.7)
(set-face-attribute 'org-level-3 nil :height 1.4)
(set-face-attribute 'org-level-4 nil :height 1.1)
(set-face-attribute 'org-level-5 nil :height 1.0)
(setq org-ellipsis "" ;; folding symbol
org-startup-indented t
org-image-actual-width (list 300) ; no one wants gigantic images inline
org-hide-emphasis-markers nil
org-pretty-entities nil ; part of the benefit of lightweight markup is seeing these
org-agenda-block-separator ""
org-fontify-whole-heading-line nil ; don't fontify the whole like, so tags don't look weird
org-fontify-done-headline t
org-fontify-quote-and-verse-blocks t))
(use-package flymake-proselint
:hook (word-processing-mode . flymake-proselint-setup))
(use-package darkroom
:commands (darkroom-mode darkroom-tentative-mode))
(define-minor-mode word-processing-mode
"Toggle Word Processing mode.
Interactively with no argument, this command toggles the mode. A
positive prefix argument enables the mode, any other prefix
disables it. From Lisp, argument omitted or nil enables the mode,
`toggle' toggles the state.
When Word Processing mode is enabled, `darkroom-mode' is
triggered for a distraction-free writing experience. In addition,
column numbers, ligatures, prettified symbols, and fringes are
disabled, `buffer-face-mode' is enabled to set the current buffer
face to iA Writer Quattro V or your choice of writing-specific
faces, and the flymake `proselint' backend is enabled."
:init-value nil
:lighter " Word Processing"
(display-line-numbers-mode -1)
(setq line-spacing 0.1)
;; Less distracting UI
(setq left-fringe-width 0)
(setq right-fringe-width 0)
(if (and (boundp 'darkroom-mode) darkroom-mode)
(progn
(darkroom-mode -1)
(buffer-face-mode -1))
(progn
(darkroom-mode 1)
(buffer-face-mode 1)))
;; Proselint
(when (fboundp 'flymake-proselint-setup)
(flymake-mode))
;; Spellcheck
(flyspell-mode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment