diff options
32 files changed, 1933 insertions, 0 deletions
diff --git a/.emacs.d/.gitignore b/.emacs.d/.gitignore new file mode 100644 index 0000000..67bb165 --- /dev/null +++ b/.emacs.d/.gitignore @@ -0,0 +1,33 @@ +*~ +*.elc +auto-save-list +cider-history +recentf +savehist +saveplace +save +eshell +elpa +el-get +semanticdb +url +ede-projects.el +.DS_Store +custom.el +places +.smex-items +savefile/ +projectile-bookmarks.eld +session* +.cask +tramp +/var/pcache +.emacs.desktop +.emacs.desktop.lock +network-security.data +transient/ +var/ +.cache/ +.lsp-session* +lisp/init-local.el +site-lisp diff --git a/.emacs.d/README.md b/.emacs.d/README.md new file mode 100644 index 0000000..965a718 --- /dev/null +++ b/.emacs.d/README.md @@ -0,0 +1,15 @@ +My Emacs Configuration, inspired by Prelude (https://github.com/bbatsov/prelude), along with: + +- https://github.com/purcell/emacs.d +- https://git.sr.ht/~technomancy/better-defaults +- https://sachachua.com/dotemacs +- https://config.daviwil.com/emacs +- https://www.lucacambiaghi.com/vanilla-emacs/readme.html +- https://github.com/jwiegley/dot-emacs +- https://github.com/bodil/emacs.d +- https://gitlab.com/protesilaos/dotfiles +- https://gitlab.com/buildfunthings/emacs-config +- https://www.emacswiki.org/emacs + +As well as the github READMEs and wikis for corfu, vertico, orderless, consult, embark, marginalia, and other places too. + diff --git a/.emacs.d/early-init.el b/.emacs.d/early-init.el new file mode 100644 index 0000000..93e35a2 --- /dev/null +++ b/.emacs.d/early-init.el @@ -0,0 +1,25 @@ +;;; early-init.el --- Early Init File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(setq gc-cons-threshold most-positive-fixnum + gc-cons-percentage 0.6) + +(push '(menu-bar-lines . 0) default-frame-alist) +(push '(tool-bar-lines . 0) default-frame-alist) +(push '(vertical-scroll-bars) default-frame-alist) +(when (featurep 'ns) + (push '(ns-transparent-titlebar . t) default-frame-alist)) + +(setq frame-inhibit-implied-resize t) + +(menu-bar-mode -1) +(tool-bar-mode -1) +(scroll-bar-mode -1) +(horizontal-scroll-bar-mode -1) + +(setq package-enable-at-startup nil) + +; (setq comp-deferred-compilation nil) + +;;; early-init.el ends here diff --git a/.emacs.d/init.el b/.emacs.d/init.el new file mode 100644 index 0000000..83324bd --- /dev/null +++ b/.emacs.d/init.el @@ -0,0 +1,51 @@ +;;; init.el --- Init File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(setq load-prefer-newer t) + +(defvar save-dir (expand-file-name "save" user-emacs-directory)) +(unless (file-exists-p save-dir) + (make-directory save-dir)) + +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) + +(defgroup djm nil + "Custom variables added by me" + :group 'convenience) + +(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) + +(require 'init-packages) +(require 'init-ui) +(require 'init-compile) +(require 'init-editor) +(require 'init-crux) +(require 'init-navigation) +(require 'init-windows) +(require 'init-projectile) +(require 'init-modeline) +(require 'init-dashboard) +(require 'init-completion) +(require 'init-kill) +(require 'init-dired) +(require 'init-smartparens) +(require 'init-lisp) +(require 'init-emacs-lisp) +(require 'init-clojure) +(require 'init-paredit) +(require 'init-paredit-x) +(require 'init-lsp) +(require 'init-git) +(require 'init-org) +;;(require 'init-latex) +(require 'init-xml) +(require 'init-web) +(require 'init-misc) +(require 'init-tramp) +(require 'init-local nil t) + +(add-hook 'after-init-hook '(lambda () + (setq gc-cons-threshold (* 100 1024 1024) + gc-cons-percentage 0.1))) +;;; init.el ends here diff --git a/.emacs.d/lisp/init-clojure.el b/.emacs.d/lisp/init-clojure.el new file mode 100644 index 0000000..0f19c15 --- /dev/null +++ b/.emacs.d/lisp/init-clojure.el @@ -0,0 +1,58 @@ +;;; init-clojure.el --- Clojure Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +;(require 'init-lisp) + +(use-package yasnippet + :diminish yas-minor-mode) + +(use-package flycheck-clj-kondo) + +(use-package clojure-mode + :config + (require 'flycheck-clj-kondo) + (subword-mode +1)) + +(use-package hydra) +(use-package clj-refactor + :diminish + :after yasnippet + :bind ("C-c '" . hydra-cljr-help-menu/body) + :config + (cljr-add-keybindings-with-prefix "C-c C-m") + (setq cljr-suppress-no-project-warning t) + :hook + (clojure-mode . + (lambda () + (clj-refactor-mode 1) + (yas-minor-mode 1)))) + +(use-package cider + :diminish + :after key-chord + :config + (setq cider-repl-pop-to-buffer-on-connect 'display-only + cider-repl-display-help-banner nil + cider-repl-history-highlight-current-entry t + cider-repl-history-highlight-inserted-item t + cider-repl-use-clojure-font-lock t + cider-repl-use-pretty-printing t + cider-save-file-on-load t + ;; cider-invert-insert-eval-p t + ;; cider-switch-to-repl-on-insert nil + cider-repl-history-file "~/.emacs.d/cider-history" + nrepl-log-messages t + clojure-toplevel-inside-comment-form t) + (key-chord-define-global "??" 'cider-xref-fn-refs-select) + (key-chord-define-global "qq" 'cider-xref-fn-refs) + (unbind-key "C-c C-l" cider-mode-map) + :bind (:map cider-mode-map ("C-c M-l" . cider-load-file)) + :hook + (cider-repl-mode . (lambda () + (display-line-numbers-mode -1) + (subword-mode +1))) + (cider-mode . eldoc-mode)) + +(provide 'init-clojure) +;;; init-clojure.el ends here diff --git a/.emacs.d/lisp/init-compile.el b/.emacs.d/lisp/init-compile.el new file mode 100644 index 0000000..dd38510 --- /dev/null +++ b/.emacs.d/lisp/init-compile.el @@ -0,0 +1,22 @@ +;;; init-compile.el --- Compilation Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Based on code from prelude-editor.el +;;; Code: + +(use-package compile + :ensure nil + :custom + (compilation-ask-about-save nil) + (compilation-always-kill t) + (compilation-scroll-output 'first-error)) + +;; http://stackoverflow.com/a/3072831/355252 +(use-package ansi-color + :hook + (compilation-filter . (lambda () + (when (eq major-mode 'compilation-mode) + (let ((inhibit-read-only t)) + (ansi-color-apply-on-region (point-min) (point-max))))))) + +(provide 'init-compile) +;;; init-compile.el ends here diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el new file mode 100644 index 0000000..a602e42 --- /dev/null +++ b/.emacs.d/lisp/init-completion.el @@ -0,0 +1,371 @@ +;;; init-completion.el --- Commpletion Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Config for completion-at-point (corfu) and minibuffer (vertico, embark, consult, etc) +;;; Code: + +(use-package dabbrev + :diminish) + +(use-package hippie-expand + :ensure nil + :init + (setq hippie-expand-try-functions-list + '(;yas-hippie-try-expand + try-expand-dabbrev + try-expand-all-abbrevs + try-expand-dabbrev-all-buffers + try-expand-dabbrev-from-kill + try-complete-file-name-partially + try-complete-file-name + try-expand-list + try-expand-line + try-complete-lisp-symbol-partially + try-complete-lisp-symbol)) + :bind + ("M-/" . hippie-expand)) + +(use-package emacs + :init + ;; for corfu + (setq completion-cycle-threshold 3) + (setq tab-always-indent 'complete) + + ;; for vertico + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + (setq enable-recursive-minibuffers t)) + +;; orderless is used by corfu and vertico +(use-package orderless + :bind (:map minibuffer-local-completion-map + ("C-l" . my/orderless-match-components-literally)) + :custom (orderless-component-separator 'orderless-escapable-split-on-space) + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles . (partial-completion orderless))))) + + (defun my/orderless-match-components-literally () + "Components match literally for the rest of the session." + (interactive) + (setq-local orderless-matching-styles '(orderless-literal) + orderless-style-dispatchers nil)) + :config + ;; Recognizes the following patterns: + ;; * ~flex flex~ + ;; * =literal literal= + ;; * %char-fold char-fold% + ;; * `initialism initialism` + ;; * !without-literal without-literal! + ;; * .ext (file extension) + ;; * regexp$ (regexp matching at end) + (defun my/orderless-dispatch (pattern _index _total) + (cond + ;; Ensure that $ works with Consult commands, which add disambiguation suffixes + ((string-suffix-p "$" pattern) `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x100000-\x10FFFD]*$"))) + ;; File extensions + ((string-match-p "\\`\\.." pattern) `(orderless-regexp . ,(concat "\\." (substring pattern 1) "[\x100000-\x10FFFD]*$"))) + ;; Ignore single ! + ((string= "!" pattern) `(orderless-literal . "")) + ;; Character folding + ((string-prefix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 1))) + ((string-suffix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 0 -1))) + ;; Without literal + ((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1))) + ((string-suffix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 0 -1))) + ;; Initialism matching + ((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1))) + ((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1))) + ;; Literal matching + ((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1))) + ((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1))) + ;; Flex matching + ((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1))) + ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1))))) + (setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism) + orderless-style-dispatchers '(my/orderless-dispatch))) + + +;; code completion - corfu +(use-package corfu + ;; Optional customizations + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + :bind (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + :init + (corfu-global-mode)) + +(use-package fancy-dabbrev + :diminish + :config + (global-fancy-dabbrev-mode)) + +;; minibuffer completion - vertico et al +(use-package vertico + :init + (vertico-mode) + (setq vertico-cycle t) + (advice-add #'vertico--format-candidate :around + (lambda (orig cand prefix suffix index _start) + (setq cand (funcall orig cand prefix suffix index _start)) + (concat + (if (= vertico--index index) + (propertize "» " 'face 'vertico-current) + " ") + cand))) + :config + (defun down-from-outside () + "Move to next candidate in minibuffer, even when minibuffer isn't selected." + (interactive) + (with-selected-window (active-minibuffer-window) + (execute-kbd-macro [down]))) + + (defun up-from-outside () + "Move to previous candidate in minibuffer, even when minibuffer isn't selected." + (interactive) + (with-selected-window (active-minibuffer-window) + (execute-kbd-macro [up]))) + + (defun preview-from-outside () + "Preview the selected candidate, even when minibuffer isn't selected." + (interactive) + (with-selected-window (active-minibuffer-window) + (execute-kbd-macro (kbd "M-.")))) + + (defun to-and-fro-minibuffer () + "Go back and forth between minibuffer and other window." + (interactive) + (if (window-minibuffer-p (selected-window)) + (select-window (minibuffer-selected-window)) + (select-window (active-minibuffer-window)))) + + (key-chord-define-global "XX" 'to-and-fro-minibuffer) + ;(key-chord-define-global ">>" 'preview-from-outside) + :bind (("C-M-<" . up-from-outside) + ("C-M->" . down-from-outside) + ("C-M-+" . preview-from-outside) + ("M-X" . to-and-fro-minibuffer) + ("C-M-S-g" . minibuffer-keyboard-quit))) + +;; See init-packages.el for fetching of Vertico Extenions +;; Required extensions must be in the vertico-extensions var +(use-package vertico-directory + :load-path "site-lisp/vertico-extensions/vertico-directory.el" + :bind (:map vertico-map + ("RET" . vertico-directory-enter) + ("/" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word)) + ;; Tidy shadowed file names + :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) + +(use-package vertico-repeat + :load-path "site-lisp/vertico-extensions/vertico-repeat.el" + :bind ("M-P" . vertico-repeat)) + +(use-package consult + :after projectile + :bind (;; C-c bindings (mode-specific-map) + ("C-c h" . consult-history) + ("C-c m" . consult-mode-command) + ("C-c b" . consult-bookmark) + ("C-c k" . consult-kmacro) + ;; C-x bindings (ctl-x-map) + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x B" . consult-buffer-no-preview) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("C-S-s" . consult-line) + ("C-M-S" . consult-line-symbol-at-point) + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ("<help> a" . consult-apropos) ;; orig. apropos-command + ;; M-g bindings (goto-map) + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flycheck) + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-project-imenu) + ;; (Mostly) C-c c bindings (search-map) + ("C-c f" . consult-recent-file) + ("C-c c f" . consult-find) + ("C-c c L" . consult-locate) + ("C-c c g" . consult-grep) + ("C-c c G" . consult-git-grep) + ("C-c c r" . consult-ripgrep) + ("C-c r" . consult-ripgrep) + ("C-c c R" . consult-ripgrep-auto-preview) + ("C-c R" . consult-ripgrep-auto-preview) + ("C-c c M-r" . consult-ripgrep-unrestricted) + ("C-c c s" . consult-ripgrep-symbol-at-point) + ("C-c c l" . consult-line) + ("C-c c m" . consult-multi-occur) + ("C-c c k" . consult-keep-lines) + ("C-c c u" . consult-focus-lines) + ;; Isearch integration + ("C-c c e" . consult-isearch) + :map isearch-mode-map + ("M-e" . consult-isearch) ;; orig. isearch-edit-string + ("C-c c e" . consult-isearch) ;; orig. isearch-edit-string + ("C-c c l" . consult-line)) ;; needed by consult-line to detect isearch + + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Optionally replace `completing-read-multiple' with an enhanced version. + (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key (kbd "M-.")) + ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>"))) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-theme + :preview-key '(:debounce 0.2 any) + consult-ripgrep consult-git-grep consult-grep + consult-ripgrep-unrestricted consult-ripgrep-symbol-at-point + consult-bookmark consult-recent-file consult-xref consult-buffer-no-preview + consult--source-file consult--source-project-file consult--source-bookmark + :preview-key (kbd "M-.")) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; (kbd "C-+") + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + (autoload 'projectile-project-root "projectile") + (setq consult-project-root-function #'projectile-project-root) + + (defvar consult-initial-narrow-config + '((consult-buffer . ?p) + (consult-buffer-no-preview . ?p))) + ;; Add initial narrowing hook + (defun consult-initial-narrow () + (when-let (key (alist-get this-command consult-initial-narrow-config)) + (setq unread-command-events (append unread-command-events (list key 32))))) + (add-hook 'minibuffer-setup-hook #'consult-initial-narrow) + + (when (and (eq system-type 'darwin) (string-match-p "^find" consult-find-command)) + (setq consult-find-command (concat "g" consult-find-command))) + + (defun consult--orderless-regexp-compiler (input type) + (setq input (orderless-pattern-compiler input)) + (cons + (mapcar (lambda (r) (consult--convert-regexp r type)) input) + (lambda (str) (orderless--highlight input str)))) + ;; (setq consult--regexp-compiler #'consult--orderless-regexp-compiler) + (defun consult--with-orderless (&rest args) + (minibuffer-with-setup-hook + (lambda () + (setq-local consult--regexp-compiler #'consult--orderless-regexp-compiler)) + (apply args))) + (advice-add #'consult-ripgrep :around #'consult--with-orderless) + + (defun consult-ripgrep-symbol-at-point (&optional dir initial) + (interactive + (list prefix-arg (when-let ((s (symbol-at-point))) + (symbol-name s)))) + (consult-ripgrep dir initial)) + (defun consult-ripgrep-auto-preview (&optional dir initial) + (interactive "P") + (consult-ripgrep dir initial)) + (defun consult-ripgrep-unrestricted (&optional dir initial) + (interactive "P") + (let ((consult-ripgrep-args (replace-regexp-in-string "\\." "-uu ." consult-ripgrep-args))) + (consult-ripgrep dir initial))) + (defun consult-buffer-no-preview () + (interactive) + (consult-buffer)) + (defun consult-line-symbol-at-point () + (interactive) + (consult-line (thing-at-point 'symbol)))) + +(use-package consult-flycheck) + +(use-package consult-lsp + :bind (:map lsp-mode-map + ([remap xref-find-apropos] . consult-lsp-symbols))) + +(use-package consult-dir + :ensure t + :bind (("C-x C-d" . consult-dir) + :map vertico-map ;minibuffer-local-completion-map + ("C-x C-d" . consult-dir) + ("C-x C-j" . consult-dir-jump-file))) + +(use-package marginalia + :bind (("M-A" . marginalia-cycle) + :map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode) + :config + ;; For Projectile + (add-to-list 'marginalia-prompt-categories '("Switch to project" . file)) + (add-to-list 'marginalia-prompt-categories '("Find file" . project-file)) + (add-to-list 'marginalia-prompt-categories '("Recently visited files" . project-file)) + (add-to-list 'marginalia-prompt-categories '("Switch to buffer" . buffer))) + +(use-package embark + :bind + (("C-." . embark-act) + ("C-;" . embark-dwim) + ("C-c C-o" . embark-export) + ("C-h b" . embark-bindings) + ("C-h B" . describe-bindings)) + :init + ;; Optionally replace the key help with a completing-read interface + (setq prefix-help-command #'embark-prefix-help-command) + :config + ;; Hide the mode line of the Embark live/completions buffers + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + nil + (window-parameters (mode-line-format . none))))) + +(use-package embark-consult + :after (embark consult) + :demand t ; only necessary if you have the hook below + ;; if you want to have consult previews as you move around an + ;; auto-updating embark collect buffer + :hook + (embark-collect-mode . consult-preview-at-point-mode)) + +(provide 'init-completion) +;;; init-completion.el ends here diff --git a/.emacs.d/lisp/init-crux.el b/.emacs.d/lisp/init-crux.el new file mode 100644 index 0000000..f7e8de8 --- /dev/null +++ b/.emacs.d/lisp/init-crux.el @@ -0,0 +1,37 @@ +;;; init-crux.el --- Crux Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package crux + :config + (key-chord-define-global "JJ" 'crux-switch-to-previous-buffer) + :bind + ("C-^" . crux-top-join-line) + ("C-<backspace>" . crux-kill-line-backwards) + ([remap kill-whole-line] . crux-kill-whole-line) + ("C-a" . crux-move-beginning-of-line) + ;; TODO don't need all of these + ("C-<return>" . crux-smart-open-line) + ("S-<return>" . crux-smart-open-line) + ([remap open-line] . crux-smart-open-line) + ("C-S-<return>" . crux-smart-open-line-above) + ("M-o" . crux-smart-open-line-above) + ("C-c d" . crux-duplicate-current-line-or-region) + ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region) + ("C-c F" . crux-recentf-find-file) + ("C-x 4 s" . crux-swap-windows) + ("C-x M-o" . crux-other-window-or-switch-buffer) + ("C-c e" . crux-eval-and-replace) + ("C-c M-k" . crux-kill-other-buffers) + ("C-c C-r" . crux-rename-buffer-and-file) + ("C-c D" . crux-delete-file-and-buffer) + ("C-c w" . crux-cleanup-buffer-or-region) + ("C-c M-o" . crux-open-with) + ("C-M-z" . curx-indent-defun) + ("C-c C-u" . crux-view-url) + ("C-c TAB" . crux-indent-rigidly-and-copy-to-clipboard) + ("C-c C-j" . crux-switch-to-previous-buffer) + ("C-c x" . crux-reopen-as-root)) + +(provide 'init-crux) +;;; init-crux.el ends here diff --git a/.emacs.d/lisp/init-dashboard.el b/.emacs.d/lisp/init-dashboard.el new file mode 100644 index 0000000..30285a5 --- /dev/null +++ b/.emacs.d/lisp/init-dashboard.el @@ -0,0 +1,22 @@ +;;; init-dashboard.el --- Dashboard Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package dashboard + :init + (setq dashboard-center-content t + dashboard-startup-banner 'logo + dashboard-set-footer nil + dashboard-week-agenda t + dashboard-projects-backend 'projectile + dashboard-projects-switch-function 'projectile-persp-switch-project + dashboard-items '((recents . 15) + (bookmarks . 5) + (projects . 5) + (agenda . 5) + (registers . 5))) + :config + (dashboard-setup-startup-hook)) + +(provide 'init-dashboard) +;;; init-dashboard.el ends here diff --git a/.emacs.d/lisp/init-dired.el b/.emacs.d/lisp/init-dired.el new file mode 100644 index 0000000..380861c --- /dev/null +++ b/.emacs.d/lisp/init-dired.el @@ -0,0 +1,29 @@ +;;; init-dired.el --- Dired Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package dired + :ensure nil + :config + (put 'dired-find-alternate-file 'disabled nil) + (when (eq system-type 'darwin) + (setq insert-directory-program "/usr/local/bin/gls")) + :custom + (dired-use-ls-dired t) + (dired-recursive-deletes 'always) + (dired-recursive-copies 'always) + (dired-dwim-target t) + (dired-kill-when-opening-new-dired-buffer t) + (wdired-use-dired-vertical-movement 'sometimes)) + +(use-package dired-x + :ensure nil) + +(use-package dired-subtree + :config + (bind-keys :map dired-mode-map + ("i" . dired-subtree-insert) + (";" . dired-subtree-remove))) + +(provide 'init-dired) +;;; init-dired.el ends here diff --git a/.emacs.d/lisp/init-editor.el b/.emacs.d/lisp/init-editor.el new file mode 100644 index 0000000..dacb2d9 --- /dev/null +++ b/.emacs.d/lisp/init-editor.el @@ -0,0 +1,213 @@ +;;; init-editor.el --- Editing Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; based on prelude-editor.el +;;; Code: + +(use-package emacs + :ensure nil + :bind + ("C-x \\" . align-regexp) + ("C-+" . text-scale-increase) + ("C--" . text-scale-decrease) + ("C-x O" . (lambda () + (interactive) + (other-window -1))) + ("C-x C-b" . ibuffer) + :hook + (after-save . executable-make-buffer-file-executable-if-script-p) + ;; (text-mode . whitespace-cleanup) + + :config + (put 'narrow-to-region 'disabled nil) + (put 'narrow-to-page 'disabled nil) + (put 'narrow-to-defun 'disabled nil) + (put 'upcase-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'erase-buffer 'disabled nil) + + (setq-default indent-tabs-mode nil) + (setq require-final-newline t) + (setq comment-auto-fill-only-comments t) + (setq large-file-warning-threshold 100000000) + (setq create-lockfiles nil) + (delete-selection-mode t) + (global-auto-revert-mode t) + + (setq backup-directory-alist + `((".*" . ,temporary-file-directory)) + auto-save-file-name-transforms + `((".*" ,temporary-file-directory t))) + + (setq save-place-file (expand-file-name "saveplace" save-dir)) + (save-place-mode 1) + + ;; https://git.sr.ht/~technomancy/better-defaults/tree/master/item/better-defaults.el + (setq save-interprogram-paste-before-kill t + apropos-do-all t + mouse-yank-at-point t + require-final-newline t + load-prefer-newer t) + + ;; https://github.com/natecox/dotfiles/blob/master/workspaces/shared/symlinks/emacs/.emacs.d/nathancox.org + (setq sentence-end-double-space nil) + (set-charset-priority 'unicode) + (setq locale-coding-system 'utf-8) + (set-terminal-coding-system 'utf-8) + (set-keyboard-coding-system 'utf-8) + (set-selection-coding-system 'utf-8) + (prefer-coding-system 'utf-8) + (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) + + (defadvice set-buffer-major-mode (after set-major-mode activate compile) + "Set buffer major mode according to `auto-mode-alist'." + (let* ((name (buffer-name buffer)) + (mode (assoc-default name auto-mode-alist 'string-match))) + (when (and mode (consp mode)) + (setq mode (car mode))) + (with-current-buffer buffer (if mode (funcall mode))))) + + (defadvice server-visit-files (before parse-numbers-in-lines (files proc &optional nowait) activate) + "Open file with emacsclient with cursors positioned on requested line. +Most of console-based utilities prints filename in format +'filename:linenumber'. So you may wish to open filename in that format. +Just call: + + emacsclient filename:linenumber + +and file 'filename' will be opened and cursor set on line 'linenumber'" + (ad-set-arg 0 + (mapcar (lambda (fn) + (let ((name (car fn))) + (if (string-match "^\\(.*?\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?$" name) + (cons + (match-string 1 name) + (cons (string-to-number (match-string 2 name)) + (string-to-number (or (match-string 3 name) "")))) + fn))) files))) + + (set-default 'imenu-auto-rescan t)) + +(use-package move-text + :bind + ("M-S-<down>" . move-text-down) + ("C-S-<down>" . move-text-down)) + +(use-package zop-to-char + :bind + ("M-z" . zop-up-to-char) + ("M-Z" . zop-to-char)) + +(use-package savehist + :config + (savehist-mode 1) + :custom + (savehist-additional-variables '(search-ring regexp-search-ring)) + (savehist-autosave-interval 60) + (savehist-file (expand-file-name "savehist" save-dir)) + :config + (savehist-mode +1)) + +(use-package uniquify + :ensure nil + :custom + (uniquify-buffer-name-style 'forward)) + +(use-package super-save + :diminish + :custom + (super-save-remote-files nil) + :config + (super-save-mode +1) + (add-to-list 'super-save-triggers 'ace-window) + (add-to-list 'super-save-hook-triggers 'find-file-hook)) + +(use-package recentf + :config + (recentf-mode +1) + :custom + (recentf-save-file (expand-file-name "recentf" save-dir)) + (recentf-max-saved-items 1000) + (recentf-max-menu-items 30) + (recentf-auto-cleanup (* 5 60))) + +(use-package flycheck + :config + (global-flycheck-mode)) + +;(use-package flyspell +; :custom +; (ispell-program-name "aspell") +; (ispell-extra-args '("--sug-mode=ultra")) +; :hook +; (text-mode . (lambda () (flyspell-mode +1))) +; (prog-mode . (lambda () (flyspell-prog-mode)))) + +(use-package expand-region) + +(use-package bookmark + :custom + (bookmark-default-file (expand-file-name "bookmarks" save-dir)) + (bookmark-save-flag 1)) + +(use-package anzu + :diminish + :config + (global-anzu-mode) + (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold) + :custom + (anzu-deactivate-region t) + (anzu-search-threshold 1000) + (anzu-replace-threshold 100) + (anzu-replace-to-string-separator " => ") + :bind + ([remap query-replace] . anzu-query-replace) + ([remap query-replace-regexp] . anzu-query-replace-regexp)) + +(use-package midnight) + +(use-package re-builder + :custom + (reb-re-syntax 'string)) + +(use-package undo-tree + :diminish + :after key-chord + :config + (global-undo-tree-mode) + (key-chord-define-global "uu" 'undo-tree-visualize) + :custom + (undo-tree-history-directory-alist `((".*" . ,temporary-file-directory))) + (undo-tree-auto-save-history t)) + +(use-package abbrev-mode + :ensure nil + :diminish + :hook (text-mode . abbrev-mode)) + +(use-package tabify + :ensure nil + :config + (defmacro with-region-or-buffer (func) + "When called with no active region, call FUNC on current buffer." + `(defadvice ,func (before with-region-or-buffer activate compile) + (interactive + (if mark-active + (list (region-beginning) (region-end)) + (list (point-min) (point-max)))))) + (with-region-or-buffer indent-region) + (with-region-or-buffer untabify)) + +(use-package subword + :diminish) + +(use-package markdown-mode + :config + (add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode)) + (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))) + +;; (use-package adoc-mode +;; (add-to-list 'auto-mode-alist '("\\.adoc\\'" . adoc-mode)) +;; (add-to-list 'auto-mode-alist '("\\.asciidoc\\'" . adoc-mode))) + +(provide 'init-editor) +;;; init-editor.el ends here diff --git a/.emacs.d/lisp/init-emacs-lisp.el b/.emacs.d/lisp/init-emacs-lisp.el new file mode 100644 index 0000000..ed608c3 --- /dev/null +++ b/.emacs.d/lisp/init-emacs-lisp.el @@ -0,0 +1,52 @@ +;;; init-emacs-lisp.el --- Emacs Lisp Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Based on prelude-emacs-lisp.el +;;; Code: + +(require 'init-lisp) + +(use-package eldoc + :ensure nil + :diminish) + +(use-package elisp-slime-nav + :diminish) + +(use-package emacs + :ensure nil + :config + ;; From prelude-emacs-lisp.el + (defun recompile-elc-on-save () + "Recompile your elc when saving an elisp file. (Adds buffer-local hook)" + (add-hook 'after-save-hook + (lambda () + (when (and + (string-prefix-p user-emacs-directory (file-truename buffer-file-name)) + (file-exists-p (byte-compile-dest-file buffer-file-name))) + (emacs-lisp-byte-compile))) + nil + t)) + ;; From prelude-emacs-lisp.el + (defun visit-ielm () + "Switch to default `ielm' buffer. +Start `ielm' if it's not already running." + (interactive) + (crux-start-or-switch-to 'ielm "*ielm*")) + :hook + (ielm-mode . (lambda () + (eldoc-mode +1) + (rainbow-delimiters-mode +1))) + (emacs-lisp-mode . (lambda () + (eldoc-mode +1) + (rainbow-mode +1) + (rainbow-delimiters-mode +1) + (setq mode-name "EL") + (recompile-elc-on-save))) + :bind + (:map emacs-lisp-mode-map + (("C-c C-z" . visit-ielm) + ("C-c C-c" . eval-defun) + ("C-c C-b" . eval-buffer)))) + +(provide 'init-emacs-lisp) +;;; init-emacs-lisp.el ends here diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el new file mode 100644 index 0000000..f4fabd6 --- /dev/null +++ b/.emacs.d/lisp/init-git.el @@ -0,0 +1,70 @@ +;;; init-git.el --- VCS/Git Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package ediff + :custom + (ediff-setup-windows-plain 'ediff-setup-windows-plain)) + +(use-package diff-hl + :config + (global-diff-hl-mode +1) + :hook + (dired-mode . diff-hl-dired-mode) + (magit-post-refresh . diff-hl-magit-post-refresh)) + +(use-package gitconfig) +(use-package gitignore-mode) +(use-package gist) +(use-package git-timemachine) + +(use-package magit + :after key-chord + :bind + ("C-c g" . magit-file-dispatch) + ("C-c C-g" . magit-dispatch) + :config + (defun my/magit-set-upstream () + (interactive) + (magit-shell-command-topdir "git upstream")) + ;; update stale git info on the modeline (based on code removed from doom modeline) + (defun my/magit-refresh-state () + (interactive) + (dolist (buf (buffer-list)) + (when (and (not (buffer-modified-p buf)) + (buffer-file-name buf) + (file-exists-p (buffer-file-name buf)) + (file-in-directory-p (buffer-file-name buf) (magit-toplevel))) + (with-current-buffer buf + (vc-refresh-state))))) + (key-chord-define-global "UU" 'my/magit-set-upstream) + (key-chord-define-global "RR" 'my/magit-refresh-state) + ;; :custom-face + ;; (diff-added ((t (:foreground "green4")))) + ;; (magit-diff-added ((t (:foreground "green4")))) + ;; (magit-diff-added-highlight ((t (:foreground "green4")))) + ;; (diff-removed ((t (:foreground "red3")))) + ;; (magit-diff-removed ((t (:foreground "red3")))) + ;; (magit-diff-removed-highlight ((t (:foreground "red3")))) + :custom + (magit-diff-refine-hunk 'all) + ;; (magit-diff-paint-whitespace t) + ;; (magit-diff-paint-whitespace-lines 'all) + (magit-diff-highlight-trailing t) + (magit-diff-highlight-indentation t)) + +(use-package forge + :after magit) + +(use-package git-gutter + :diminish + :bind + ("C-c j g" . git-gutter-mode) + ("C-c j S-g" . git-gutter) + ("C-c j n" . git-gutter:next-hunk) + ("C-c j p" . git-gutter:previous-hunk) + ("C-c j r" . git-gutter:revert-hunk) + ("C-c j d" . git-gutter:popup-hunk)) + +(provide 'init-git) +;;; init-git.el ends here diff --git a/.emacs.d/lisp/init-kill.el b/.emacs.d/lisp/init-kill.el new file mode 100644 index 0000000..ceada0d --- /dev/null +++ b/.emacs.d/lisp/init-kill.el @@ -0,0 +1,48 @@ +;;; init-kill.el --- Kill Ring Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Contains code copied from prelude-editor.el +;;; Code: + +(use-package browse-kill-ring + :after key-chord + :config + (browse-kill-ring-default-keybindings) + (key-chord-define-global "yy" 'browse-kill-ring)) + +(use-package easy-kill + :bind + ([remap kill-ring-save] . easy-kill) + ([remap mark-sexp] . easy-mark)) + +(use-package emacs + :config + (defadvice exchange-point-and-mark (before deactivate-mark activate compile) + "When called with no active region, do not activate mark." + (interactive + (list (not (region-active-p))))) + + (defun yank-advised-indent-function (beg end) + "Do indentation, as long as the region isn't too large." + (if (<= (- end beg) 1000) + (indent-region beg end nil))) + + (defmacro advise-commands (advice-name commands class &rest body) + "Apply advice named ADVICE-NAME to multiple COMMANDS. + +The body of the advice is in BODY." + `(progn + ,@(mapcar (lambda (command) + `(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate) + ,@body)) + commands))) + + (advise-commands "indent" (yank yank-pop) after + (if (and (not (ad-get-arg 0)) + (not (member major-mode '(conf-mode coffee-mode haml-mode python-mode slim-mode yaml-mode))) + (or (derived-mode-p 'prog-mode) + (member major-mode '(LaTeX-mode TeX-mode)))) + (let ((transient-mark-mode nil)) + (yank-advised-indent-function (region-beginning) (region-end)))))) + +(provide 'init-kill) +;;; init-kill.el ends here diff --git a/.emacs.d/lisp/init-latex.el b/.emacs.d/lisp/init-latex.el new file mode 100644 index 0000000..8aa243d --- /dev/null +++ b/.emacs.d/lisp/init-latex.el @@ -0,0 +1,36 @@ +;;; init-latex.el --- LaTeX Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Based on prelude-latex.el +;;; Code: + +;; (use-package auctex +;; :defer t +;; :config +;; (require 'smartparens-latex) +;; (setq-default TeX-master nil) +;; (when (eq system-type 'darwin) +;; (setq TeX-view-program-selection +;; '((output-dvi "DVI Viewer") +;; (output-pdf "PDF Viewer") +;; (output-html "HTML Viewer"))) +;; (setq TeX-view-program-list +;; '(("DVI Viewer" "open %o") +;; ("PDF Viewer" "open %o") +;; ("HTML Viewer" "open %o")))) +;; :custom +;; (TeX-auto-save t) +;; (TeX-parse-qself t) +;; (TeX-close-quote "") +;; (TeX-open-quote "") +;; ;; use pdflatex +;; (TeX-PDF-mode t) +;; :hook LaTeX-mode . (lambda () +;; (abbrev-mode +1) +;; (turn-on-auto-fill) +;; ;; (LaTeX-math-mode (LaTeX-math-mode 1)) ;; alternative to the below +;; (turn-on-cdlatex))) +;; +;; (use-package cdlatex) + +(provide 'init-latex) +;;; init-latex.el ends here diff --git a/.emacs.d/lisp/init-lisp.el b/.emacs.d/lisp/init-lisp.el new file mode 100644 index 0000000..6abe0eb --- /dev/null +++ b/.emacs.d/lisp/init-lisp.el @@ -0,0 +1,15 @@ +;;; init-lisp.el --- LISP Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: +(require 'init-paredit) + +(use-package eval-expr + :bind ("M-:" . eval-expr) + :config + (defun eval-expr-minibuffer-setup () + (local-set-key (kbd "<tab>") #'completion-at-point) + (set-syntax-table emacs-lisp-mode-syntax-table) + (paredit-mode))) + +(provide 'init-lisp) +;;; init-lisp.el ends here diff --git a/.emacs.d/lisp/init-local-template.el b/.emacs.d/lisp/init-local-template.el new file mode 100644 index 0000000..f67ac9e --- /dev/null +++ b/.emacs.d/lisp/init-local-template.el @@ -0,0 +1,8 @@ +;;; init-local.el --- Local Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Local configuration that shouldn't be checked into source control +;; Copy this template to init-local.el and edit as required +;;; Code: + +(provide 'init-local) +;;; init-local.el ends here diff --git a/.emacs.d/lisp/init-lsp.el b/.emacs.d/lisp/init-lsp.el new file mode 100644 index 0000000..4b72759 --- /dev/null +++ b/.emacs.d/lisp/init-lsp.el @@ -0,0 +1,49 @@ +;;; init-lsp.el --- LSP Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package lsp-ui + :config + (require 'lsp-ui-imenu)) + +(use-package lsp-mode + :diminish + :after key-chord + :hook (clojure-mode . lsp) + :config + (if (eq system-type 'darwin) + (setq lsp-keymap-prefix "s-l") + (setq lsp-keymap-prefix "C-c C-l")) + (setq read-process-output-max (* 1024 1024) + lsp-ui-sideline-enable t + lsp-ui-peek-enable t + lsp-ui-peek-always-show t + lsp-ui-doc-delay 1 + lsp-lens-enable nil + lsp-ui-doc-enable t + lsp-ui-doc-show-with-cursor t + lsp-ui-doc-show-with-mouse t + lsp-headerline-breadcrumb-enable nil + lsp-enable-symbol-highlighting t + lsp-ui-sideline-show-diagnostics t + lsp-ui-sideline-show-code-actions nil + lsp-modeline-code-actions-enable nil + lsp-modeline-diagnostics-enable nil + lsp-ui-doc-position 'top + lsp-treemacs-theme "Iconless" + ;; user cider for indendation and completion instead + lsp-enable-indentation nil + lsp-completion-enable nil) + (key-chord-define-global "QQ" 'lsp-find-references) + (key-chord-define-global "PP" 'lsp-peek-find-references) + (key-chord-define-global "GG" 'lsp-find-definition) + (key-chord-define-global "DD" 'lsp-peek-find-definitions) + :bind + (:map lsp-ui-mode-map + ([remap xref-find-definitions] . lsp-ui-peek-find-definitions) + ([remap xref-find-references] . lsp-ui-peek-find-references))) + +(use-package lsp-treemacs) + +(provide 'init-lsp) +;;; init-lsp.el ends here diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el new file mode 100644 index 0000000..55de62b --- /dev/null +++ b/.emacs.d/lisp/init-misc.el @@ -0,0 +1,55 @@ +;;; init-misc.el --- Miscellaneous Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package exec-path-from-shell + :config + (when (memq window-system '(mac ns x)) + (exec-path-from-shell-initialize))) + +(use-package envrc + :diminish + :config + (envrc-global-mode)) + +(use-package rg + :config + (rg-enable-default-bindings)) + +(use-package restclient + :mode (("\\.http\\'" . restclient-mode))) + +(use-package es-mode + :mode "\.es\'") + +(use-package miniedit + :commands minibuffer-edit + :init (miniedit-install)) + +(use-package multi-vterm + :bind (("C-c t" . multi-vterm-next) + ("C-c C-M-t" . multi-vterm) + (:map vterm-mode-map + ("M-[" . multi-vterm-prev) + ("M-]" . multi-vterm-next)))) + +(use-package eshell + :ensure nil + :bind ("C-x m " . eshell) + :custom + (eshell-directory-name (expand-file-name "eshell" save-dir))) + +(use-package eshell-z + :defer t + :hook (eshell-mode . (lambda () (require 'eshell-z)))) + +(use-package json-mode) +(use-package csv-mode) +(use-package yaml-mode + :diminish + :hook + (yaml-mode . whitespace-mode) + (yaml-mode . subword-mode)) + +(provide 'init-misc) +;;; init-misc.el ends here diff --git a/.emacs.d/lisp/init-modeline.el b/.emacs.d/lisp/init-modeline.el new file mode 100644 index 0000000..55984dd --- /dev/null +++ b/.emacs.d/lisp/init-modeline.el @@ -0,0 +1,48 @@ +;;; init-modeline.el --- Modeline Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(line-number-mode t) +(column-number-mode t) +;(size-indication-mode t) ; TODO + +(use-package which-func + :ensure nil + :config + (which-func-mode 1)) + +(use-package hl-todo + :config + (global-hl-todo-mode 1)) + +(use-package simple-modeline + :hook (after-init . simple-modeline-mode) + :custom + (simple-modeline-segments + '((simple-modeline-segment-modified + simple-modeline-segment-buffer-name + simple-modeline-segment-position) + (simple-modeline-segment-minor-modes + simple-modeline-segment-vc + simple-modeline-segment-misc-info + simple-modeline-segment-process + simple-modeline-segment-major-mode)))) + +(use-package flycheck-indicator + :after flycheck + :hook (flycheck-mode . flycheck-indicator-mode) + :custom + (flycheck-indicator-icon-error 9632) + (flycheck-indicator-icon-info 9679) + (flycheck-indicator-icon-warning 9650) + (flycheck-indicator-status-icons + '((running . "◉") + (errored . "◙") + (finished . "●") + (interrupted . "◘") + (suspicious . "◘") + (no-checker . "○") + (not-checked . "○")))) + +(provide 'init-modeline) +;;; init-modeline.el ends here diff --git a/.emacs.d/lisp/init-navigation.el b/.emacs.d/lisp/init-navigation.el new file mode 100644 index 0000000..c9a3e90 --- /dev/null +++ b/.emacs.d/lisp/init-navigation.el @@ -0,0 +1,81 @@ +;;; init-navigation.el --- Navigation Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package ctrlf + :init + (ctrlf-mode +1) + :config + (add-to-list 'ctrlf-minibuffer-bindings '("C-M-g" . ctrlf-cancel)) + (add-to-list 'ctrlf-minibuffer-bindings '("C-o o" . ctrlf-occur)) + (add-to-list 'ctrlf-minibuffer-bindings '("C-o C-o" . ctrlf-occur)) + :custom + (ctrlf-default-search-style 'fuzzy-regexp) + (ctrlf-alternate-search-style 'literal) + :bind + ("C-*" . ctrlf-forward-symbol-at-point)) + +(use-package smartscan + :config + (global-smartscan-mode t) + :hook + (cider-repl-mode . (lambda () (smartscan-mode -1))) + (ielm-mode . (lambda () (smartscan-mode -1))) + (vterm-mode . (lambda () (smartscan-mode -1))) + (eshell-mode . (lambda () (smartscan-mode -1)))) + +(use-package affe + :after (consult orderless) + :config + (setq affe-grep-command (replace-regexp-in-string "\\." "-Suu ." affe-grep-command)) + (when (and (eq system-type 'darwin) (string-match-p "^find" affe-find-command)) + (setq affe-find-command (concat "g" affe-find-command))) + ;; Configure Orderless + (setq affe-regexp-function #'orderless-pattern-compiler + affe-highlight-function #'orderless--highlight) + ;; Manual preview key for `affe-grep' + (consult-customize affe-grep :preview-key (kbd "M-.")) + (defun my/affe-grep-symbol-at-point (&optional dir initial) + (interactive + (list prefix-arg (when-let ((s (symbol-at-point))) + (symbol-name s)))) + (affe-grep dir initial)) + (defun my/affe-find-symbol-at-point (&optional dir initial) + (interactive + (list prefix-arg (when-let ((s (symbol-at-point))) + (symbol-name s)))) + (affe-find dir initial)) + ;; TODO is this faster and/or more portable? + ;; :custom + ;; (affe-find-command "fd --color never -t f") + :bind + ("C-#" . affe-grep) + ("C-c z" . affe-find) + ("C-c Z" . my/affe-find-symbol-at-point) + ("C-~" . my/affe-grep-symbol-at-point)) + +;; TODO - which of these are useful? +(use-package avy + :custom + (avy-background t) + (avy-style 'pre) + :config + (key-chord-define-global "LL" 'avy-goto-line) + (key-chord-define-global ",," 'avy-goto-char-in-line) + (key-chord-define-global "jj" 'avy-goto-word-1) + (key-chord-define-global "jk" 'avy-goto-char) + :bind + ("C-:" . avy-goto-char) + ("C-'" . avy-goto-char-2) + ("C-c C-v" . avy-goto-char-in-line) + ("C-c v" . avy-goto-word-or-subword-1) + ("M-g w" . avy-goto-word-1) + ("M-g M-w" . avy-goto-word-0) + ("M-g M-f" . avy-goto-line)) + +(use-package rg + :config + (rg-enable-default-bindings)) + +(provide 'init-navigation) +;;; init-navigation.el ends here diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el new file mode 100644 index 0000000..3af62fd --- /dev/null +++ b/.emacs.d/lisp/init-org.el @@ -0,0 +1,21 @@ +;;; init-ui.el --- Org-Mode Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Some parts copied from prelude-org.el +;;; Code: + +(use-package org + :ensure nil + :custom (org-log-done t) + :config + (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) + :bind + ("C-c l" . org-store-link) + ("C-c a" . org-agenda) + ("C-c b" . org-switchb) + ;; TODO bindings + ;("C-c r" . org-refile) + ;("C-c c" . org-capture) + ) + +(provide 'init-org) +;;; init-org.el ends here diff --git a/.emacs.d/lisp/init-packages.el b/.emacs.d/lisp/init-packages.el new file mode 100644 index 0000000..ad501b8 --- /dev/null +++ b/.emacs.d/lisp/init-packages.el @@ -0,0 +1,57 @@ +;;; init-packages.el --- Package Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +;; TODO - straight.el? + +(require 'package) +(require 'url) + +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("melpa-stable" . "https://stable.melpa.org/packages/") + ("nongnu" . "https://elpa.nongnu.org/nongnu/") + ("elpa" . "https://elpa.gnu.org/packages/"))) + +(package-initialize) + +(unless package-archive-contents + (package-refresh-contents)) + +(unless (package-installed-p 'use-package) + (package-install 'use-package)) +(require 'use-package) + +(setq use-package-always-ensure t) + +(use-package diminish) + +(use-package paradox + :config + (paradox-enable)) + +(defvar vertico-extensions-dir (expand-file-name "site-lisp/vertico-extensions" user-emacs-directory)) +(defvar vertico-extensions '("vertico-directory" "vertico-repeat")) + +(defun fetch-vertico-extensions () + "Download the latest versions of the required vertico extensions into vertico-extensions-dir" + (dolist (extension vertico-extensions) + (let ((ext-file (format "%s.el" extension))) + (url-copy-file + (format "https://raw.githubusercontent.com/minad/vertico/main/extensions/%s" ext-file) + (expand-file-name ext-file vertico-extensions-dir))))) + +(unless (file-directory-p vertico-extensions-dir) + (make-directory vertico-extensions-dir t) + (fetch-vertico-extensions)) + +(use-package epl + :config + (defun my/upgrade-packages () + (interactive) + (epl-refresh) + (epl-upgrade) + (fetch-vertico-extensions) + (message "Package upgrade finished."))) + +(provide 'init-packages) +;;; init-packages.el ends here diff --git a/.emacs.d/lisp/init-paredit-x.el b/.emacs.d/lisp/init-paredit-x.el new file mode 100644 index 0000000..41cf7ba --- /dev/null +++ b/.emacs.d/lisp/init-paredit-x.el @@ -0,0 +1,107 @@ +;;; init-paredit-x.el --- Paredit Extra Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Code taken from emacswiki and https://github.com/bodil/emacs.d/blob/master/bodil/bodil-paredit.el +;;; Code: + +(with-eval-after-load 'paredit +;; From emacswiki +(defun paredit-barf-all-the-way-backward () + (interactive) + (paredit-split-sexp) + (paredit-backward-down) + (paredit-splice-sexp)) + +(defun paredit-barf-all-the-way-forward () + (interactive) + (paredit-split-sexp) + (paredit-forward-down) + (paredit-splice-sexp) + (if (eolp) (delete-horizontal-space))) + +(defun paredit-slurp-all-the-way-backward () + (interactive) + (catch 'done + (while (not (bobp)) + (save-excursion + (paredit-backward-up) + (if (eq (char-before) ?\() + (throw 'done t))) + (paredit-backward-slurp-sexp)))) + +(defun paredit-slurp-all-the-way-forward () + (interactive) + (catch 'done + (while (not (eobp)) + (save-excursion + (paredit-forward-up) + (if (eq (char-after) ?\)) + (throw 'done t))) + (paredit-forward-slurp-sexp)))) + +(nconc paredit-commands + '("Extreme Barfage & Slurpage" + (("C-M-)") + paredit-slurp-all-the-way-forward + ("(foo (bar |baz) quux zot)" + "(foo (bar |baz quux zot))") + ("(a b ((c| d)) e f)" + "(a b ((c| d)) e f)")) + (("C-M-}" "M-F") + paredit-barf-all-the-way-forward + ("(foo (bar |baz quux) zot)" + "(foo (bar|) baz quux zot)")) + (("C-M-(") + paredit-slurp-all-the-way-backward + ("(foo bar (baz| quux) zot)" + "((foo bar baz| quux) zot)") + ("(a b ((c| d)) e f)" + "(a b ((c| d)) e f)")) + (("C-M-{" "M-B") + paredit-barf-all-the-way-backward + ("(foo (bar baz |quux) zot)" + "(foo bar baz (|quux) zot)")))) + +(paredit-define-keys) +(paredit-annotate-mode-with-examples) +(paredit-annotate-functions-with-examples) + +;; From https://github.com/bodil/emacs.d/blob/master/bodil/bodil-paredit.el +;; Inverse M-( +(defun paredit-wrap-round-from-behind () + (interactive) + (forward-sexp -1) + (paredit-wrap-round) + (insert " ") + (forward-char -1)) +(eval-after-load "paredit" + '(define-key paredit-mode-map (kbd "M-)") + 'paredit-wrap-round-from-behind)) + +;; From https://github.com/bodil/emacs.d/blob/master/bodil/bodil-paredit.el +;; Duplicate sexp +(defun paredit-duplicate-after-point + () + "Duplicates the content of the line that is after the point." + (interactive) + ;; skips to the next sexp + (while (looking-at " ") + (forward-char)) + (set-mark-command nil) + ;; while we find sexps we move forward on the line + (while (and (<= (point) (car (bounds-of-thing-at-point 'sexp))) + (not (= (point) (line-end-position)))) + (forward-sexp) + (while (looking-at " ") + (forward-char))) + (kill-ring-save (mark) (point)) + ;; go to the next line and copy the sexprs we encountered + (paredit-newline) + (set-mark-command nil) + (yank) + (exchange-point-and-mark))) +(eval-after-load "paredit" + '(define-key paredit-mode-map (kbd "C-c C-S-d") + 'paredit-duplicate-after-point)) + +(provide 'init-paredit-x) +;;; init-paredit-x.el ends here diff --git a/.emacs.d/lisp/init-paredit.el b/.emacs.d/lisp/init-paredit.el new file mode 100644 index 0000000..20dc2da --- /dev/null +++ b/.emacs.d/lisp/init-paredit.el @@ -0,0 +1,35 @@ +;;; init-paredit.el --- Paredit Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; add-hooks/add-lisp-hook based on https://github.com/bodil/emacs.d/blob/master/bodil/bodil-lisp.el +;;; Code: + +(defun add-hooks (modes func) + (dolist (mode modes) + (add-hook (intern (concat (symbol-name mode) "-hook")) func))) + +(setq lisp-modes + '(scheme-mode emacs-lisp-mode lisp-mode clojure-mode cider-repl-mode + eval-expression-minibuffer-setup ielm-mode lisp-interaction-mode)) + +(defun add-lisp-hook (func) + (add-hooks lisp-modes func)) + +(use-package paredit + :diminish + ;; sp does a few things better + :bind (([remap mark-sexp] . sp-mark-sexp) + ("M-[" . sp-wrap-square) + ("C-c M-{" . sp-wrap-curly) + ([remap paredit-wrap-round] . sp-wrap-round) + ([remap paredit-meta-doublequote] . sp-wrap-double-quotation-marks) + ("M-W" . paredit-copy-as-kill)) + :config + (defun sp-wrap-double-quotation-marks () + (interactive) + (sp-wrap-with-pair "\"")) + :init + (add-lisp-hook #'turn-off-smartparens-mode) + (add-lisp-hook #'enable-paredit-mode)) + +(provide 'init-paredit) +;;; init-paredit.el ends here diff --git a/.emacs.d/lisp/init-projectile.el b/.emacs.d/lisp/init-projectile.el new file mode 100644 index 0000000..c131935 --- /dev/null +++ b/.emacs.d/lisp/init-projectile.el @@ -0,0 +1,57 @@ +;;; init-projectile.el --- Projectile Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(defcustom projectile-default-dir "~/src" + "Starting directory when looking for new projects." + :group 'djm + :type 'directory) + +(defcustom projectile-switch-project-command 'projectile-persp-switch-project + "Projectile switch project command." + :group 'djm + :type 'function) + +(use-package projectile + :diminish + :after smartrep + :config + (projectile-mode t) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (def-projectile-commander-method ?b + "consult-buffer" + (progn + (setq unread-command-events (listify-key-sequence "p ")) + (consult-buffer))) + (def-projectile-commander-method ?B + "Switch to project buffer" + (projectile-switch-to-buffer)) + (def-projectile-commander-method ?r + "consult-ripgrep" + (consult-ripgrep)) + (def-projectile-commander-method ?p + "DWIM" + (cond ((> (length (projectile-project-buffer-names)) 4) (projectile-switch-to-buffer)) + ((> (length (projectile-recentf-files)) 0) (projectile-recentf)) + (t (projectile-find-file)))) + (defun projectile-open-new-project (project-root) + (interactive (list (read-directory-name "Select project directory: " (file-name-as-directory projectile-default-dir)))) + (projectile-add-known-project project-root) + (funcall projectile-switch-project-command project-root)) + (smartrep-define-key projectile-mode-map + "C-c p" '(("C-p" . projectile-previous-project-buffer) + ("C-n" . projectile-next-project-buffer))) + :bind-keymap ("C-c p" . projectile-command-map) + :bind (:map projectile-mode-map ("C-c p n" . projectile-open-new-project)) + :custom + (projectile-switch-project-action 'projectile-commander) + (projectile-cache-file (expand-file-name "projectile.cache" save-dir))) + +(use-package perspective + :init (persp-mode) + :custom (persp-modestring-short t)) + +(use-package persp-projectile) + +(provide 'init-projectile) +;;; init-projectile.el ends here diff --git a/.emacs.d/lisp/init-smartparens.el b/.emacs.d/lisp/init-smartparens.el new file mode 100644 index 0000000..aeeb6fd --- /dev/null +++ b/.emacs.d/lisp/init-smartparens.el @@ -0,0 +1,47 @@ +;;; init-smartparens.el --- Smartparens Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package smartparens + :diminish + :custom + (sp-base-key-bindings 'paredit) + (sp-autoskip-closing-pair 'always) + (sp-hybrid-kill-entire-symbol t) + (sp-hybrid-kill-excessive-whitespace t) + :config + ;; https://github.com/syl20bnr/spacemacs/blob/develop/layers/+spacemacs/spacemacs-editing/funcs.el (spacemacs/smart-closing-parenthesis) + ;; TODO can make things unbalanced + (defun sp-close-round () + (interactive) + (let* ((sp-navigate-close-if-unbalanced t) + (current-pos (point)) + (current-line (line-number-at-pos current-pos)) + next-pos next-line) + (save-excursion + (let ((buffer-undo-list) + (modified (buffer-modified-p))) + (unwind-protect + (progn + (sp-up-sexp) + (setq next-pos (point) + next-line (line-number-at-pos))) + (primitive-undo (length buffer-undo-list) + buffer-undo-list) + (set-buffer-modified-p modified)))) + (cond + ((and (= current-line next-line) + (not (= current-pos next-pos))) + (sp-up-sexp)) + (t + (insert-char ?\)))))) + + (smartparens-global-strict-mode) + (show-smartparens-global-mode) + (require 'smartparens-config) + (sp-use-paredit-bindings) + ;:bind (:map prog-mode-map ((")" . sp-close-round))) + ) + +(provide 'init-smartparens) +;;; init-smartparens.el ends here diff --git a/.emacs.d/lisp/init-tramp.el b/.emacs.d/lisp/init-tramp.el new file mode 100644 index 0000000..326344d --- /dev/null +++ b/.emacs.d/lisp/init-tramp.el @@ -0,0 +1,19 @@ +;;; init-tramp.el --- Tramp Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package tramp + :ensure nil + :custom + (tramp-default-method "ssh") + (vc-ignore-dir-regexp + (format "\\(%s\\)\\|\\(%s\\)" + vc-ignore-dir-regexp + tramp-file-name-regexp)) + (tramp-default-method "ssh") + (tramp-auto-save-directory (expand-file-name "tramp-auto-save" user-emacs-directory)) + (tramp-persistency-file-name (expand-file-name "tramp-connection-history" user-emacs-directory)) + (password-cache-expiry nil)) + +(provide 'init-tramp) +;;; init-tramp.el ends here diff --git a/.emacs.d/lisp/init-ui.el b/.emacs.d/lisp/init-ui.el new file mode 100644 index 0000000..1f1a388 --- /dev/null +++ b/.emacs.d/lisp/init-ui.el @@ -0,0 +1,110 @@ +;;; init-ui.el --- UI Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Some parts copied from prelude-ui.el and prelude-editor.el +;; {menu,tool,scoll}-bar-mode disabled in early-init.el, rather than here +;;; Code: + +(use-package emacs + :config + (toggle-frame-maximized) + + ;; https://github.com/rougier/elegant-emacs/blob/master/sanity.el + (setq inhibit-startup-screen t + inhibit-startup-echo-area-message t + inhibit-startup-message t + initial-scratch-message nil) + + (blink-cursor-mode -1) + + (setq whitespace-line-column 120) + (setq ring-bell-function 'ignore + visible-bell t) + + ;; TODO do we want these? (copied from prelude) + (setq scroll-margin 0 + scroll-conservatively 100000 + scroll-preserve-screen-position 1) + + (global-display-line-numbers-mode) + (global-hl-line-mode +1) + + (fset 'yes-or-no-p 'y-or-n-p) + + (global-set-key (kbd "C-x C-S-k") 'kill-this-buffer) + + (setq frame-title-format + '("Emacs: " (:eval (if (buffer-file-name) + (abbreviate-file-name (buffer-file-name)) + "%b")))) + + (when (eq system-type 'darwin) + (setq mac-option-modifier 'meta) + (setq mac-right-option-modifier 'none) + (setq mac-command-modifier 'super))) + +(use-package modus-themes + :init + ;; (setq modus-themes-syntax '(alt-syntax green-strings yellow-comments)) + (setq modus-themes-syntax '(green-strings yellow-comments) + modus-themes-paren-match '(bold intense underline) + modus-themes-lang-checkers '(text-also background)) + (load-theme 'modus-vivendi t)) + +(use-package whitespace + :ensure nil + :diminish + :custom + (whitespace-line-column 120) + (whitespace-style '(face tabs empty trailing lines-tail)) + :hook + (text-mode . (lambda () (whitespace-mode +1))) + (prog-mode . (lambda () (whitespace-mode +1))) + (cider-repl-mode . (lambda () (whitespace-mode -1))) + (ielm-mode . (lambda () (whitespace-mode -1))) + (vterm-mode . (lambda () (whitespace-mode -1))) + (eshell-mode . (lambda () (whitespace-mode -1)))) + +(use-package hi-lock + :diminish + :config + (when (eq system-type 'darwin) + (defun my/toggle-highlight-symbol-at-point () + (interactive) + (if hi-lock-interactive-patterns + (unhighlight-regexp (car (car hi-lock-interactive-patterns))) + (highlight-symbol-at-point))) + (global-set-key (kbd "s-.") 'my/toggle-highlight-symbol-at-point))) + +(use-package volatile-highlights + :diminish + :config + (volatile-highlights-mode t)) + +(use-package idle-highlight-mode + :hook (prog-mode . idle-highlight-mode)) + +(use-package paren + :config + (show-paren-mode +1)) + +(use-package which-key + :diminish + :config (which-key-mode +1)) + +;; Other key-chords defined with in the relevant use-package calls +(use-package key-chord + :config + (key-chord-mode +1) + (key-chord-define-global "xx" 'execute-extended-command)) + +(use-package rainbow-delimiters + :config + (rainbow-delimiters-mode +1)) + +(use-package rainbow-mode + :diminish) + +(use-package smartrep) + +(provide 'init-ui) +;;; init-ui.el ends here diff --git a/.emacs.d/lisp/init-web.el b/.emacs.d/lisp/init-web.el new file mode 100644 index 0000000..0fc1e21 --- /dev/null +++ b/.emacs.d/lisp/init-web.el @@ -0,0 +1,57 @@ +;;; init-ui.el --- Web Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Some parts copied from prelude-web.el, prelude-js.el and prelude-css.el +;;; Code: + +(use-package css-mode + :custom + (css-indent-offset 2) + :config + (rainbow-mode +1)) + +(use-package sass-mode) + +(use-package web-mode + :custom + (web-mode-enable-auto-pairing nil) + :config + (sp-with-modes '(web-mode) + (sp-local-pair "%" "%" + :unless '(sp-in-string-p) + :post-handlers '(((lambda (&rest _ignored) + (just-one-space) + (save-excursion (insert " "))) + "SPC" "=" "#"))) + (sp-local-tag "%" "<% " " %>") + (sp-local-tag "=" "<%= " " %>") + (sp-local-tag "#" "<%# " " %>")) + (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.tpl\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.hbs\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.blade\\.php\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.jsp\\'" . 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 '("\\.html?\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("/\\(views\\|html\\|theme\\|templates\\)/.*\\.php\\'" . web-mode))) + +(use-package tagedit + :config (tagedit-add-paredit-like-keybindings) + :hook (html-mode . (lambda () (tagedit-mode 1)))) + +(use-package js2-mode + :config + (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) + :hook (js2-mode . (lambda () + (setq-local electric-layout-rules '((?\; . after))) + (setq mode-name "JS2") + (js2-imenu-extras-mode +1) + (subword-mode +1)))) + +(use-package scss-mode + :custom + (scss-compile-at-save nil)) + +(provide 'init-web) +;;; init-web.el ends here diff --git a/.emacs.d/lisp/init-windows.el b/.emacs.d/lisp/init-windows.el new file mode 100644 index 0000000..b80e8bc --- /dev/null +++ b/.emacs.d/lisp/init-windows.el @@ -0,0 +1,65 @@ +;;; init-windows.el --- Window/Buffer Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(use-package emacs + :config + (winner-mode +1) + ;; From EmacsWiki + (defun toggle-window-split () + (interactive) + (if (= (count-windows) 2) + (let* ((this-win-buffer (window-buffer)) + (next-win-buffer (window-buffer (next-window))) + (this-win-edges (window-edges (selected-window))) + (next-win-edges (window-edges (next-window))) + (this-win-2nd (not (and (<= (car this-win-edges) + (car next-win-edges)) + (<= (cadr this-win-edges) + (cadr next-win-edges))))) + (splitter + (if (= (car this-win-edges) + (car (window-edges (next-window)))) + 'split-window-horizontally + 'split-window-vertically))) + (delete-other-windows) + (let ((first-win (selected-window))) + (funcall splitter) + (if this-win-2nd (other-window 1)) + (set-window-buffer (selected-window) this-win-buffer) + (set-window-buffer (next-window) next-win-buffer) + (select-window first-win) + (if this-win-2nd (other-window 1)))))) + (define-key ctl-x-4-map "t" 'toggle-window-split)) + + +(use-package windmove + :init (windmove-default-keybindings)) + +(use-package buffer-move + :bind (("C-S-<up>" . buf-move-up) + ("C-S-<down>" . buf-move-down) + ("C-S-<left>" . buf-move-left) + ("C-S-<right>" . buf-move-right))) + +(use-package fullframe + :after (magit dashboard) + :config + (fullframe magit-status magit-mode-quit-window)) + +(use-package ace-window + :diminish + :bind ([remap other-window] . ace-window) + :custom-face + (aw-leading-char-face + ((t (:foreground "white" :background "red" + :weight bold :height 2.5 :box (:line-width 10 :color "red")))))) + +(smartrep-define-key global-map + "C-x" '(("}" . enlarge-window-horizontally) + ("{" . shrink-window-horizontally) + ("^" . enlarge-window) + ("-" . shrink-window-if-larger-than-buffer))) + +(provide 'init-windows) +;;; init-windows.el ends here diff --git a/.emacs.d/lisp/init-xml.el b/.emacs.d/lisp/init-xml.el new file mode 100644 index 0000000..5a3d162 --- /dev/null +++ b/.emacs.d/lisp/init-xml.el @@ -0,0 +1,20 @@ +;;; init-xml.el --- XML Configuration File -*- lexical-binding: t -*- +;;; Commentary: +;; Based on prelude-xml.el +;;; Code: + +(use-package nxml-mode + :ensure nil + :config + (push '("<\\?xml" . nxml-mode) magic-mode-alist) + ;; pom files should be treated as xml files + (add-to-list 'auto-mode-alist '("\\.pom\\'" . nxml-mode)) + :custom + (nxml-child-indent 4) + (nxml-attribute-indent 4) + (nxml-auto-insert-xml-declaration-flag nil) + (nxml-bind-meta-tab-to-complete-flag t) + (nxml-slash-auto-complete-flag t)) + +(provide 'init-xml) +;;; init-xml.el ends here |