Skip to content

Instantly share code, notes, and snippets.

@dosbol
Last active February 10, 2025 09:47
Show Gist options
  • Save dosbol/1da9466b874b4c75ca1b0a2c0715abcd to your computer and use it in GitHub Desktop.
Save dosbol/1da9466b874b4c75ca1b0a2c0715abcd to your computer and use it in GitHub Desktop.
init.el
(setq custom-file (locate-user-emacs-file "custom.el"))
(load custom-file :no-error-if-file-is-missing)
;;; Set up the package manager
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'display-buffer-alist
'("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
(display-buffer-no-window)
(allow-no-window . t)))
(use-package delsel
:ensure nil ; no need to install it as it is built-in
:hook (after-init . delete-selection-mode))
(defun prot/keyboard-quit-dwim ()
"Do-What-I-Mean behaviour for a general `keyboard-quit'.
The generic `keyboard-quit' does not do the expected thing when
the minibuffer is open. Whereas we want it to close the
minibuffer, even without explicitly focusing it.
The DWIM behaviour of this command is as follows:
- When the region is active, disable it.
- When a minibuffer is open, but not focused, close the minibuffer.
- When the Completions buffer is selected, close it.
- In every other case use the regular `keyboard-quit'."
(interactive)
(cond
((region-active-p)
(keyboard-quit))
((derived-mode-p 'completion-list-mode)
(delete-completion-window))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(t
(keyboard-quit))))
(define-key global-map (kbd "C-g") #'prot/keyboard-quit-dwim)
(menu-bar-mode 1)
(scroll-bar-mode 1)
(tool-bar-mode -1)
(let ((mono-spaced-font "Monospace")
(proportionately-spaced-font "Sans"))
(set-face-attribute 'default nil :family mono-spaced-font :height 150)
(set-face-attribute 'fixed-pitch nil :family mono-spaced-font :height 1.0)
(set-face-attribute 'variable-pitch nil :family proportionately-spaced-font :height 1.0))
(use-package modus-themes
:ensure t
:config
(load-theme 'modus-vivendi-tinted :no-confirm-loading))
(use-package nerd-icons
:ensure t)
(use-package nerd-icons-completion
:ensure t
:after marginalia
:config
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
(use-package nerd-icons-corfu
:ensure t
:after corfu
:config
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
(use-package nerd-icons-dired
:ensure t
:hook
(dired-mode . nerd-icons-dired-mode))
(use-package vertico
:ensure t
:hook (after-init . vertico-mode))
(use-package marginalia
:ensure t
:hook (after-init . marginalia-mode))
(use-package orderless
:ensure t
:config
(setq completion-styles '(orderless basic))
(setq completion-category-defaults nil)
(setq completion-category-overrides nil))
(use-package savehist
:ensure nil ; it is built-in
:hook (after-init . savehist-mode))
(use-package spacious-padding
:ensure t
:custom (spacious-padding-widths
'(:internal-border-width 22
:header-line-width 4
:mode-line-width 2
:tab-width 4
:right-divider-width 20
:scroll-bar-width 8
:fringe-width 0))
:config (spacious-padding-mode))
(use-package puni
:ensure t
:init (puni-global-mode)
:hook ((term-mode . puni-disable-puni-mode))
:bind (:map puni-mode-map
("s-r" . puni-raise)
("s-." . puni-slurp-forward)
("s-," . puni-barf-forward)
("s-/" . puni-split)
("C-(" . puni-wrap-round)))
(electric-pair-mode 1)
(use-package flycheck
:ensure t)
(use-package direnv
:ensure t
:config (direnv-mode 1))
(use-package cider
:ensure t
:hook
(clojure-mode . flycheck-mode)
:custom
(cider-enable-nrepl-jvmti-agent t)
(cider-auto-select-test-report-buffer nil)
(cider-use-overlays t)
(cider-overlays-use-font-lock t)
(cider-repl-display-help-banner nil)
(cider-repl-display-in-current-window nil)
(cider-save-file-on-load nil)
(cider-special-mode-truncate-lines nil)
(cider-use-overlays t)
(nrepl-hide-special-buffers t)
(repl-use-ssh-fallback-for-remote-hosts t)
(nrepl-force-ssh-for-remote-hosts t)
(tab-always-indent 'complete)
(cider-show-error-buffer nil)
(cider-auto-jump-to-error nil)
(cider-switch-to-repl-on-insert nil)
(cider-inver-insert-eval-p t)
(clojure-toplevel-inside-comment-form t)
:bind
(:map clojure-mode-map
("C-x s-e" . cider-pprint-eval-last-sexp-to-comment)
("s-i" . cider-inspect)
("s-r" . cider-inspect-last-result)
("<f7>" . clj-transient)
("<f6>" . cider-run-user-cmd)))
(use-package popper
:ensure t
:defer t
:bind (("s-z" . popper-toggle)
("C-s-z" . popper-cycle)
("C-M-z" . popper-toggle-type))
:init
(setq popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
"\\*Async Shell Command"
"*shell*"
"*eshell*"
"eshell\\*"
"*ansi-term*"
"*poetry-shell*"
"*mu4e-update*"
"*Python*"
"*IPython*"
"*terminal*"
cider-repl-mode
;; help-mode ;; not used because we're using helpful
compilation-mode))
(popper-mode 1)
(popper-echo-mode 1))
(use-package babashka
:defer t
:ensure t)
;;; Clojure
(defun clj-require-snitch ()
"Require snitch in current CIDER session"
(interactive)
(cider-interactive-eval "(require '[snitch.core :refer [defn* defmethod* *fn *let]])"))
(defun clj-remove-snitches ()
"Remove all snitch tools from buffer."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward (regexp-opt '("defn*" "*let" "*fn" "defmethod*")) nil t)
(replace-match (replace-regexp-in-string "*" "" (match-string 0)) nil nil))
(goto-char (point-min))
(while (re-search-forward (regexp-opt '("#p ")) nil t)
(replace-match ""))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment