home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit a9b94619c0c112680f9480b0c45734f9af4bfe1a
parent 9b859d3f2dc56e7386b9df246b13096461bb2eab
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Tue,  7 Apr 2020 11:48:00 +0200

emacs: bankrupcy 😛

… as disabling most of the configuration, and re-enabling when I need it.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mdocs/emacs.org | 13+++++++++----
Mtools/emacs/config/00-environments.el | 1+
Atools/emacs/config/02-help.el | 15+++++++++++++++
Atools/emacs/config/appearance.el | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools/emacs/config/setup-buffers.el | 276++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mtools/emacs/config/setup-compile.el | 117++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mtools/emacs/config/setup-completion.el | 255+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Mtools/emacs/config/setup-docker.el | 1+
Mtools/emacs/config/setup-editing.el | 45++++++++++++++++++++++-----------------------
Mtools/emacs/config/setup-files.el | 28+++++++++++++++-------------
Mtools/emacs/config/setup-go.el | 4++++
Mtools/emacs/config/setup-hydras.el | 93+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mtools/emacs/config/setup-keybindings.el | 21+--------------------
Mtools/emacs/config/setup-mails.el | 4+++-
Mtools/emacs/config/setup-multiple-cursors.el | 22++++++++++++++++++++++
Mtools/emacs/config/setup-navigating.el | 14+++++---------
Mtools/emacs/config/setup-projectile.el | 10+---------
Mtools/emacs/config/setup-search.el | 29++++++++++-------------------
Mtools/emacs/config/setup-shells.el | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mtools/emacs/config/setup-style.el | 294++++++++++++++++++++++++++-----------------------------------------------------
Mtools/emacs/config/setup-vcs.el | 32++++++++++++++------------------
Mtools/emacs/config/setup-windows.el | 18+++---------------
22 files changed, 867 insertions(+), 645 deletions(-)

diff --git a/docs/emacs.org b/docs/emacs.org @@ -498,7 +498,7 @@ the =Ubuntu= font are not available on the system, I am just letting Emacs start with its default font. -#+INCLUDE: "../tools/emacs/config/setup-style.el" src emacs-lisp :range-begin "TypeFaceConfiguration" :range-end "-TypeFaceConfiguration" :lines "7-47" +#+INCLUDE: "../tools/emacs/config/appearance.el" src emacs-lisp :range-begin "TypeFaceConfiguration" :range-end "-TypeFaceConfiguration" :lines "6-45" ** Typeface suitability test :PROPERTIES: @@ -580,6 +580,11 @@ :CUSTOM_ID: h:5fb80d63-6c5b-4d2d-9755-ffe48c851b73 :END: + The minibuffer is the locus of extended command interaction. Whether it is about offering + input to a prompt, performing a search, executing a function by its name, the minibuffer + remains at the epicentre. The default experience is far more powerful than it seems to + be. It can get even better by tweaking the available customisation options and defining + our own extensions. * TODO Directory, buffer and window management :PROPERTIES: :CUSTOM_ID: h:88c7f450-bb9d-41f6-a8f9-3082a32d3179 @@ -1197,16 +1202,16 @@ :CUSTOM_ID: h:8cd8c972-ba38-40c2-b30f-68a4233593d6 :END: -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "SendmailCfg" :range-end "-SendmailCfg" :lines "22-36" +#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "SendmailCfg" :range-end "-SendmailCfg" :lines "22-38" -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "MessageCfg" :range-end "-MessageCfg" :lines "39-50" +#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "MessageCfg" :range-end "-MessageCfg" :lines "41-52" *** TODO ~notmuch~ configuration :PROPERTIES: :CUSTOM_ID: h:b67b377e-0fbc-4237-857c-641cdf2de1cf :END: -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "Notmuch" :range-end "-Notmuch" :lines "53-70" +#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "Notmuch" :range-end "-Notmuch" :lines "55-72" * User interface and interactions :PROPERTIES: diff --git a/tools/emacs/config/00-environments.el b/tools/emacs/config/00-environments.el @@ -1,4 +1,5 @@ (use-package exec-path-from-shell ; Set up environment variables + :disabled :if (display-graphic-p) :unless (or (eq system-type 'windows-nt) (eq system-type 'gnu/linux)) :config diff --git a/tools/emacs/config/02-help.el b/tools/emacs/config/02-help.el @@ -0,0 +1,15 @@ +;;; 02-help.el --- -*- lexical-binding: t -*- +;;; Commentary: +;;; help and info mode setup +;;; Code: +(use-package helpful + :unless noninteractive + :bind (("C-h f" . helpful-callable) + ("C-h F" . helpful-function) + ("C-h M" . helpful-macro) + ("C-c h S" . helpful-at-point) + ("C-h k" . helpful-key) + ("C-h v" . helpful-variable) + ("C-h C" . helpful-command))) + +;;; 02-help.el ends here diff --git a/tools/emacs/config/appearance.el b/tools/emacs/config/appearance.el @@ -0,0 +1,146 @@ +;;; appearance.el --- -*- lexical-binding: t -*- +;;; Commentary: +;;; Appearance configuration +;;; Code: +;; TypeFaceConfiguration +(use-package emacs + :bind ("C-c f r" . mu-reset-fonts) + :config +;;; ¯\_(ツ)_/¯ + (defconst font-height 130 + "Default font-height to use.") + ;; Middle/Near East: שלום, السّلام عليكم + (when (member "Noto Sans Arabic" (font-family-list)) + (set-fontset-font t 'arabic "Noto Sans Arabic")) + (when (member "Noto Sans Hebrew" (font-family-list)) + (set-fontset-font t 'arabic "Noto Sans Hebrew")) + ;; Africa: ሠላም + (when (member "Noto Sans Ethiopic" (font-family-list)) + (set-fontset-font t 'ethiopic "Noto Sans Ethiopic")) + + ;; Default font is Ubuntu Mono (and Ubuntu Sans for variable-pitch) + ;; If Ubuntu Mono or Ubuntu Sans are not available, use the default Emacs face + (when (member "Ubuntu Mono" (font-family-list)) + (set-face-attribute 'default nil + :family "Ubuntu Mono" + :height font-height)) + (when (member "Ubuntu Sans" (font-family-list)) + (set-face-attribute 'variable-pitch nil + :family "Ubuntu Sans" + :height font-height + :weight 'regular)) + + (defun mu-reset-fonts () + "Reset fonts to my preferences." + (interactive) + (when when (member "Ubuntu Mono" (font-family-list)) + (set-face-attribute 'default nil + :family "Ubuntu Mono" + :height font-height)) + (when when (member "Ubuntu Sans" (font-family-list)) + (set-face-attribute 'variable-pitch nil + :family "Ubuntu Sans" + :height font-height + :weight 'regular)))) +;; -TypeFaceConfiguration + +(use-package emacs + :config + (setq-default use-file-dialog nil + use-dialog-box nil + echo-keystrokes 0.1 + line-number-display-limit-width 10000 + display-time-world-list '(("Europe/London" "London") + ("Europe/Paris" "Paris") + ("America/New_York" "Boston") + ("America/Los_Angeles" "San-Francisco") + ("Asia/Calcutta" "Bangalore") + ("Australia/Brisbane" "Brisbane"))) + (line-number-mode 1) + (column-number-mode 1) + (global-hl-line-mode 1) + (global-unset-key (kbd "C-z")) + (global-unset-key (kbd "C-x C-z")) + (global-unset-key (kbd "C-h h"))) + +;;; Theme +(setq custom-safe-themes t) ; Treat themes as safe + +(use-package shortbrain-light-theme + :config + (load-theme 'shortbrain-light)) + + +(use-package moody + :config + (setq-default x-underline-at-descent-line t + ;; Show buffer position percentage starting from top + mode-line-percent-position '(-3 "%o")) + + (defvar mu-eyebrowse-mode-line + '(:propertize + (:eval + (when (bound-and-true-p eyebrowse-mode) + (let* ((num (eyebrowse--get 'current-slot)) + (tag (when num + (nth 2 (assoc num (eyebrowse--get 'window-configs))))) + (str (concat + " " + (if (and tag (< 0 (length tag))) + tag + (when num (int-to-string num))) + " "))) + str))) + face (:background "#81a2be" :foreground "#373b41")) + "Mode line format for Eyebrowse.") + + (put 'mu-eyebrowse-mode-line 'risky-local-variable t) + + (setq-default mode-line-format + '("%e" + my-eyebrowse-mode-line + mode-line-front-space + mode-line-client + mode-line-modified + mode-line-remote + mode-line-frame-identification + mode-line-buffer-identification " " mode-line-position + (vc-mode vc-mode) + (multiple-cursors-mode mc/mode-line) + " " mode-line-modes + mode-line-end-spaces)) + + (use-package minions + :ensure t + :config + (setq-default minions-mode-line-lighter "λ=" + minions-mode-line-delimiters '("" . "") + minions-direct '(flycheck-mode)) + (minions-mode +1)) + + (use-package time + :config + (setq-default display-time-24hr-format t + display-time-day-and-date t + display-time-world-list '(("Europe/Paris" "Paris") + ("Europe/London" "London") + ("America/New_York" "Boston") + ("America/Los_Angeles" "San Francisco") + ("Asia/Calcutta" "Bangalore") + ("Australia/Brisbane" "Brisbane")) + display-time-string-forms + '((format "%s %s %s, %s:%s" + dayname + monthname day + 24-hours minutes))) + (display-time)) + + (setq-default global-mode-string (remove 'display-time-string global-mode-string) + mode-line-end-spaces + (list (propertize " " 'display '(space :align-to (- right 19))) + 'display-time-string)) + + (moody-replace-mode-line-buffer-identification) + (moody-replace-vc-mode)) + +;;; appearance.el ends here diff --git a/tools/emacs/config/setup-buffers.el b/tools/emacs/config/setup-buffers.el @@ -1,153 +1,143 @@ ;;; -*- lexical-binding: t; -*- -;; Don't let the cursor go into minibuffer prompt -(let ((default (eval (car (get 'minibuffer-prompt-properties 'standard-value)))) - (dont-touch-prompt-prop '(cursor-intangible t))) - (setq minibuffer-prompt-properties - (append default dont-touch-prompt-prop)) - (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)) -;; Allow to read from minibuffer while in minibuffer. -(setq enable-recursive-minibuffers t) +(when nil + (progn + ;; Show the minibuffer depth (when larger than 1) + (use-package savehist ; Save minibuffer history + :init (savehist-mode t) + :config + (setq-default history-length 1000 + savehist-save-minibuffer-history t + savehist-autosave-interval 180) + (savehist-mode 1)) -;; Show the minibuffer depth (when larger than 1) -(minibuffer-depth-indicate-mode 1) + (use-package emacs + :init + ;; Configure `display-buffer' behaviour for some special buffers + (setq display-buffer-alist + '(;; bottom side window + ("\\*e?shell.*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . -1)) + ("\\*v?term.*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . -1)) + ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\)\\*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 0)) + ("\\*\\(helpful\\).*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 0)) + ("\\*\\(compilation\\|go test\\).*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 0)) + ("\\*\\(ielm\\).*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 1)) + ;; right side window + ("\\*wclock*" + (display-buffer-in-side-window) + (window-width . 0.20) + (side . right) + (slot . -1)) + ("\\*undo-tree*" + (display-buffer-in-side-window) + (window-width . 0.20) + (side . right) + (slot . -1)) + ("\\*\\(Flycheck\\|Package-Lint\\).*" + (display-buffer-in-side-window) + (window-width . 0.20) + (side . right) + (slot . 0) + (window-parameters . ((no-other-window . t) + (mode-line-format . (" " + mode-line-buffer-identification))))) + ("\\*Faces\\*" + (display-buffer-in-side-window) + (window-width . 0.20) + (side . right) + (slot . 1) + (window-parameters . ((no-other-window . t) + (mode-line-format . (" " + mode-line-buffer-identification))))) + ("\\*Custom.*" + (display-buffer-in-side-window) + (window-width . 0.20) + (side . right) + (slot . 2)))) + (setq window-sides-vertical nil) + (setq window-combination-resize t) ; Size new windows proportionally + :bind (("C-x +" . balance-windows-area) + ("<f7>" . window-toggle-side-windows))) -(use-package savehist ; Save minibuffer history - :init (savehist-mode t) - :custom - (history-length 1000) - (savehist-save-minibuffer-history t) - (savehist-autosave-interval 180) - :config - (savehist-mode 1)) + (use-package uniquify + :config + (setq-default uniquify-buffer-name-style 'post-forward + uniquify-separator ":" + uniquify-ignore-buffers-re "^\\*" + uniquify-after-kill-buffer-p t)) -(use-package emacs - :init - ;; Configure `display-buffer' behaviour for some special buffers - (setq display-buffer-alist - '(;; bottom side window - ("\\*e?shell.*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . -1)) - ("\\*v?term.*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . -1)) - ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\)\\*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 0)) - ("\\*\\(helpful\\).*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 0)) - ("\\*\\(compilation\\|go test\\).*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 0)) - ("\\*\\(ielm\\).*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 1)) - ;; right side window - ("\\*wclock*" - (display-buffer-in-side-window) - (window-width . 0.20) - (side . right) - (slot . -1)) - ("\\*undo-tree*" - (display-buffer-in-side-window) - (window-width . 0.20) - (side . right) - (slot . -1)) - ("\\*\\(Flycheck\\|Package-Lint\\).*" - (display-buffer-in-side-window) - (window-width . 0.20) - (side . right) - (slot . 0) - (window-parameters . ((no-other-window . t) - (mode-line-format . (" " - mode-line-buffer-identification))))) - ("\\*Faces\\*" - (display-buffer-in-side-window) - (window-width . 0.20) - (side . right) - (slot . 1) - (window-parameters . ((no-other-window . t) - (mode-line-format . (" " - mode-line-buffer-identification))))) - ("\\*Custom.*" - (display-buffer-in-side-window) - (window-width . 0.20) - (side . right) - (slot . 2)))) - (setq window-sides-vertical nil) - (setq window-combination-resize t) ; Size new windows proportionally - :bind (("C-x +" . balance-windows-area) - ("<f7>" . window-toggle-side-windows))) + (use-package ibuf-ext ; Extensions for Ibuffer + :config + ;; Do not show empty groups + (setq-default ibuffer-show-empty-filter-groups nil)) -(use-package uniquify ; Unique buffer names - :custom - (uniquify-buffer-name-style 'post-forward) - (uniquify-separator ":") - (uniquify-ignore-buffers-re "^\\*") - (uniquify-after-kill-buffer-p t)) + (use-package ibuffer ; Buffer management + :bind (("C-x C-b" . ibuffer) + ([remap list-buffers] . ibuffer)) + :config + (setq-default ibuffer-expert t + ibuffer-filter-group-name-face 'font-lock-doc-face + ibuffer-default-sorting-mode 'filename/process + ibuffer-use-header-line t) + ;; Use human readable Size column instead of original one + (define-ibuffer-column size-h + (:name "Size" :inline t) + (cond + ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) + ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) + (t (format "%8d" (buffer-size))))) -(use-package ibuf-ext ; Extensions for Ibuffer - :config - ;; Do not show empty groups - (setq ibuffer-show-empty-filter-groups nil)) + (setq ibuffer-formats + '((mark modified read-only " " + (name 18 18 :left :elide) + " " + (size-h 9 -1 :right) + " " + (mode 16 16 :left :elide) + " " + filename-and-process) + (mark modified read-only " " + (name 18 18 :left :elide) + " " + (size 9 -1 :right) + " " + (mode 16 16 :left :elide) + " " + (vc-status 16 16 :left) + " " + filename-and-process)))) -(use-package ibuffer ; Buffer management - :custom - (ibuffer-expert t) - (ibuffer-filter-group-name-face 'font-lock-doc-face) - (ibuffer-default-sorting-mode 'filename/process) - (ibuffer-use-header-line t) - :bind (("C-x C-b" . ibuffer) - ([remap list-buffers] . ibuffer)) - :config - ;; Use human readable Size column instead of original one - (define-ibuffer-column size-h - (:name "Size" :inline t) - (cond - ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) - ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) - (t (format "%8d" (buffer-size))))) - - (setq ibuffer-formats - '((mark modified read-only " " - (name 18 18 :left :elide) - " " - (size-h 9 -1 :right) - " " - (mode 16 16 :left :elide) - " " - filename-and-process) - (mark modified read-only " " - (name 18 18 :left :elide) - " " - (size 9 -1 :right) - " " - (mode 16 16 :left :elide) - " " - (vc-status 16 16 :left) - " " - filename-and-process)))) - -(use-package ibuffer-vc ; Group buffers by VC project and status - :defer 2 - :init (add-hook 'ibuffer-hook - (lambda () - (ibuffer-vc-set-filter-groups-by-vc-root) - (unless (eq ibuffer-sorting-mode 'filename/process) - (ibuffer-do-sort-by-filename/process))))) + (use-package ibuffer-vc ; Group buffers by VC project and status + :defer 2 + :init (add-hook 'ibuffer-hook + (lambda () + (ibuffer-vc-set-filter-groups-by-vc-root) + (unless (eq ibuffer-sorting-mode 'filename/process) + (ibuffer-do-sort-by-filename/process))))) + )) (provide 'setup-buffers) diff --git a/tools/emacs/config/setup-compile.el b/tools/emacs/config/setup-compile.el @@ -1,63 +1,64 @@ ;;; -*- lexical-binding: t; -*- -(use-package compile - :defer 2 - :config - (progn - ;; http://stackoverflow.com/a/13408008/1219634 - (setq - compilation-scroll-output t - ;; I'm not scared of saving everything. - compilation-ask-about-save nil - ;; Automatically scroll and jump to the first error - compilation-scroll-output 'next-error - ;; compilation-scroll-output 'first-error - ;; compilation-auto-jump-to-first-error t - ;; Skip over warnings and info messages in compilation - compilation-skip-threshold 2 - ;; Don't freeze when process reads from stdin - compilation-disable-input t - ;; Show three lines of context around the current message - compilation-context-lines 3) - (require 'ansi-color) - (defun vde/colorize-compilation-buffer () - (unless (or (derived-mode-p 'grep-mode) ;Don't mess up colors in Grep/Ag results buffers - (derived-mode-p 'ag-mode)) - (ansi-color-apply-on-region compilation-filter-start (point)))) - (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer) +(when nil + (progn (use-package compile + :defer 2 + :config + (progn + ;; http://stackoverflow.com/a/13408008/1219634 + (setq-default compilation-scroll-output t + ;; I'm not scared of saving everything. + compilation-ask-about-save nil + ;; Automatically scroll and jump to the first error + compilation-scroll-output 'next-error + ;; compilation-scroll-output 'first-error + ;; compilation-auto-jump-to-first-error t + ;; Skip over warnings and info messages in compilation + compilation-skip-threshold 2 + ;; Don't freeze when process reads from stdin + compilation-disable-input t + ;; Show three lines of context around the current message + compilation-context-lines 3) + (require 'ansi-color) + (defun vde/colorize-compilation-buffer () + (unless (or (derived-mode-p 'grep-mode) ;Don't mess up colors in Grep/Ag results buffers + (derived-mode-p 'ag-mode)) + (ansi-color-apply-on-region compilation-filter-start (point)))) + (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer) - (defun vde/mark-compilation-window-as-dedicated () - "Setup the *compilation* window with custom settings." - (when (string-prefix-p "*compilation: " (buffer-name)) - (save-selected-window - (save-excursion - (let* ((w (get-buffer-window (buffer-name)))) - (when w - (select-window w) - (switch-to-buffer (buffer-name)) - (set-window-dedicated-p w t))))))) - (add-hook 'compilation-mode-hook 'vde/mark-compilation-window-as-dedicated))) + (defun vde/mark-compilation-window-as-dedicated () + "Setup the *compilation* window with custom settings." + (when (string-prefix-p "*compilation: " (buffer-name)) + (save-selected-window + (save-excursion + (let* ((w (get-buffer-window (buffer-name)))) + (when w + (select-window w) + (switch-to-buffer (buffer-name)) + (set-window-dedicated-p w t))))))) + (add-hook 'compilation-mode-hook 'vde/mark-compilation-window-as-dedicated))) -(use-package flycheck - :if (not (eq system-type 'windows-nt)) - :defer 4 - :commands (flycheck-mode - flycheck-next-error - flycheck-previous-error) - :init - (dolist (where '((emacs-lisp-mode-hook . emacs-lisp-mode-map) - (haskell-mode-hook . haskell-mode-map) - (js2-mode-hook . js2-mode-map) - (go-mode-hook . go-mode-map) - (c-mode-common-hook . c-mode-base-map))) - (add-hook (car where) - `(lambda () - (bind-key "M-n" #'flycheck-next-error ,(cdr where)) - (bind-key "M-p" #'flycheck-previous-error ,(cdr where))) - t)) - :config - (add-hook 'prog-mode-hook 'flycheck-mode) - (defalias 'show-error-at-point-soon - 'flycheck-show-error-at-point) - (setq flycheck-idle-change-delay 1.2)) + (use-package flycheck + :if (not (eq system-type 'windows-nt)) + :defer 4 + :commands (flycheck-mode + flycheck-next-error + flycheck-previous-error) + :init + (dolist (where '((emacs-lisp-mode-hook . emacs-lisp-mode-map) + (haskell-mode-hook . haskell-mode-map) + (js2-mode-hook . js2-mode-map) + (go-mode-hook . go-mode-map) + (c-mode-common-hook . c-mode-base-map))) + (add-hook (car where) + `(lambda () + (bind-key "M-n" #'flycheck-next-error ,(cdr where)) + (bind-key "M-p" #'flycheck-previous-error ,(cdr where))) + t)) + :config + (add-hook 'prog-mode-hook 'flycheck-mode) + (defalias 'show-error-at-point-soon + 'flycheck-show-error-at-point) + (setq flycheck-idle-change-delay 1.2)) + )) (provide 'setup-compile) diff --git a/tools/emacs/config/setup-completion.el b/tools/emacs/config/setup-completion.el @@ -1,12 +1,203 @@ -;;; -*- lexical-binding: t; -*- +;;; setup-completion.el --- -*- lexical-binding: t -*- +;;; Commentary: +;;; Setup completion framework +;;; Code +(use-package minibuffer + :config + (setq completion-cycle-threshold 3) + (setq completion-flex-nospace nil) + (setq completion-pcm-complete-word-inserts-delimiters t) + (setq completion-pcm-word-delimiters "-_./:| ") + ;; NOTE: flex completion is introduced in Emacs 27 + (setq completion-show-help nil) + (setq completion-styles '(partial-completion substring initials flex)) + (setq completion-category-overrides + '((file (styles initials basic)) + (buffer (styles initials basic)) + (info-menu (styles basic)))) + (setq completions-format 'vertical) ; *Completions* buffer + (setq enable-recursive-minibuffers t) + (setq read-answer-short t) + (setq read-buffer-completion-ignore-case t) + (setq read-file-name-completion-ignore-case t) + (setq resize-mini-windows t) + + (file-name-shadow-mode 1) + (minibuffer-depth-indicate-mode 1) + (minibuffer-electric-default-mode 1) + + (defun vde/focus-minibuffer () + "Focus the active minibuffer. + +Bind this to `completion-list-mode-map' to M-v to easily jump +between the list of candidates present in the \\*Completions\\* +buffer and the minibuffer (because by default M-v switches to the +completions if invoked from inside the minibuffer." + (interactive) + (let ((mini (active-minibuffer-window))) + (when mini + (select-window mini)))) + + (defun vde/focus-minibuffer-or-completions () + "Focus the active minibuffer or the \\*Completions\\*. + +If both the minibuffer and the Completions are present, this +command will first move per invocation to the former, then the +latter, and then continue to switch between the two. + +The continuous switch is essentially the same as running +`vde/focus-minibuffer' and `switch-to-completions' in +succession." + (interactive) + (let* ((mini (active-minibuffer-window)) + (completions (get-buffer-window "*Completions*"))) + (cond ((and mini + (not (minibufferp))) + (select-window mini nil)) + ((and completions + (not (eq (selected-window) + completions))) + (select-window completions nil))))) + + ;; Technically, this is not specific to the minibuffer, but I define + ;; it here so that you can see how it is also used from inside the + ;; "Completions" buffer + (defun vde/describe-symbol-at-point (&optional arg) + "Get help (documentation) for the symbol at point. + +With a prefix argument, switch to the *Help* window. If that is +already focused, switch to the most recently used window +instead." + (interactive "P") + (let ((symbol (symbol-at-point))) + (when symbol + (describe-symbol symbol))) + (when current-prefix-arg + (let ((help (get-buffer-window "*Help*"))) + (when help + (if (not (eq (selected-window) help)) + (select-window help) + (select-window (get-mru-window))))))) + + ;; Defines, among others, aliases for common actions to Super-KEY. + ;; Normally these should go in individual package declarations, but + ;; their grouping here makes things easier to understand. + :bind (("M-v" . vde/focus-minibuffer-or-completions) + :map completion-list-mode-map + ("h" . vde/describe-symbol-at-point) + ("n" . next-line) + ("p" . previous-line) + ("f" . next-completion) + ("b" . previous-completion) + ("M-v" . vde/focus-minibuffer))) + +(use-package icomplete + :demand + :after minibuffer ; Read that section as well + :config + (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 1) + (setq icomplete-separator " · ") ; mid dot, not full stop + (setq icomplete-with-completion-tables t) + (setq icomplete-in-buffer t) + + (fido-mode -1) ; Emacs 27.1 + (icomplete-mode 1) + + (defun vde/icomplete-force-complete-and-exit () + "Complete the current `icomplete' match and exit the minibuffer. + +Contrary to `icomplete-force-complete-and-exit', this will +confirm your choice without complaining about incomplete matches. + +Those incomplete matches can block you from performing legitimate +actions, such as defining a new tag in an `org-capture' prompt. + +In my testing, this is necessary when the variable +`icomplete-with-completion-tables' is non-nil, because then +`icomplete' will be activated practically everywhere it can." + (interactive) + (icomplete-force-complete) + (exit-minibuffer)) + + (defun vde/icomplete-kill-ring-save (&optional arg) + "Expand and save current `icomplete' match to the kill ring. + +With a prefix argument, insert the match to the point in the +current buffer and switch focus back to the minibuffer." + (interactive "*P") + (when (and (minibufferp) + (bound-and-true-p icomplete-mode)) + (icomplete-force-complete) + (kill-new (field-string-no-properties)) + (when current-prefix-arg + (kill-new (field-string-no-properties)) + (select-window (get-mru-window)) + (insert (car kill-ring)) + (vde/focus-minibuffer)))) + + (defun vde/icomplete-toggle-completion-styles (&optional arg) + "Toggle between flex and prefix matching. + +With pregix ARG use basic completion instead. These styles are +described in `completion-styles-alist'. + +Bind this function in `icomplete-minibuffer-map'." + (interactive "*P") + (when (and (minibufferp) + (bound-and-true-p icomplete-mode)) + (let* ((completion-styles-original completion-styles) + (basic '(emacs22 basic)) + (flex '(flex initials substring partial-completion)) + (prefix '(partial-completion substring initials flex))) + (if current-prefix-arg + (progn + (setq-local completion-styles basic) + (message "%s" (propertize "Prioritising BASIC matching" 'face 'highlight))) + (if (not (eq (car completion-styles) 'flex)) + (progn + (setq-local completion-styles flex) + (message "%s" (propertize "Prioritising FLEX matching" 'face 'highlight))) + (setq-local completion-styles prefix) + (message "%s" (propertize "Prioritising PREFIX matching" 'face 'highlight))))))) + + (defun vde/switch-buffer (arg) + "Custom switch to buffer. +With universal argument ARG or when not in project, rely on +`switch-to-buffer'. +Otherwise, use `projectile-switch-to-project'." + (interactive "P") + (if (or arg (not (projectile-project-p))) + (switch-to-buffer) + (projectile-switch-to-buffer))) + + :bind (:map icomplete-minibuffer-map + ("C-m" . minibuffer-complete-and-exit) ; force current input + ("C-n" . icomplete-forward-completions) + ("<right>" . icomplete-forward-completions) + ("<down>" . icomplete-forward-completions) + ("C-p" . icomplete-backward-completions) + ("<left>" . icomplete-backward-completions) + ("<up>" . icomplete-backward-completions) + ("<return>" . vde/icomplete-force-complete-and-exit) + ("M-o w" . vde/icomplete-kill-ring-save) + ("M-o i" . (lambda () + (interactive) + (let ((current-prefix-arg t)) + (vde/icomplete-kill-ring-save)))) + ("C-M-," . vde/icomplete-toggle-completion-styles) + ("C-M-." . (lambda () + (interactive) + (let ((current-prefix-arg t)) + (vde/icomplete-toggle-completion-styles)))))) + (use-package ivy - :delight - :bind (("C-x b" . vde/switch-buffer) - ("C-x B" . ivy-switch-buffer) - ("M-u" . ivy-resume) ;Override the default binding for `upcase-word' - ("C-c C-w p" . ivy-push-view) ;Push window configuration to `ivy-views' - ("C-c C-w P" . ivy-pop-view) ;Remove window configuration from `ivy-views' - ("C-c C-w s" . ivy-switch-view) ; Switch window configuration to `ivy-views' + :disabled + :bind (("C-x B" . ivy-switch-buffer) :map ivy-occur-mode-map ("f" . forward-char) ("b" . backward-char) @@ -30,27 +221,10 @@ ) (ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur) (ivy-set-occur 'swiper 'swiper-occur) - (ivy-set-occur 'swiper-isearch 'swiper-occur) - (ivy-mode 1) - (progn - (defun vde/switch-buffer (arg) - "Custom switch to buffer. -With universal argument ARG or when not in project, rely on -`ivy-switch-buffer'. -Otherwise, use `counsel-projectile-switch-project'." - (interactive "P") - (if (or arg - (not (projectile-project-p))) - (ivy-switch-buffer) - (counsel-projectile-switch-to-buffer))) - ;; Disable ido - (with-eval-after-load 'ido - (ido-mode -1) - ;; Enable ivy - (ivy-mode 1)) - )) + (ivy-set-occur 'swiper-isearch 'swiper-occur)) (use-package counsel + :disabled :after ivy :bind (("M-i" . counsel-semantic-or-imenu) ("C-x C-r" . counsel-recentf) @@ -59,35 +233,15 @@ Otherwise, use `counsel-projectile-switch-project'." ("C-h S" . counsel-info-lookup-symbol) ("C-c u" . counsel-unicode-char) ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display' - ([remap execute-extended-command] . counsel-M-x) - ([remap bookmark-jump] . counsel-bookmark) ;Jump to book or set it if it doesn't exist, C-x r b - ([remap bookmark-set] . counsel-bookmark) ;C-x r m - ([remap find-file] . counsel-find-file) - ([remap describe-bindings] . counsel-descbinds) - ([remap finder-by-keyword] . counsel-package) ;C-h p - ([remap describe-variable] . counsel-describe-variable) - ([remap describe-function] . counsel-describe-function) ("M-s r" . counsel-rg) ("M-s g" . counsel-git-grep) - ("M-s z" . prot/counsel-fzf-rg-files) :map ivy-minibuffer-map ("C-r" . counsel-minibuffer-history) ("C-SPC" . ivy-restrict-to-matches)) :config (setq counsel-yank-pop-preselect-last t counsel-yank-pop-separator "\n—————————\n" - counsel-describe-function-function 'helpful-function - counsel-describe-variable-function 'helpful-variable - counsel-find-file-at-point t - counsel-find-file-ignore-regexp - ;; Note that `ivy-extra-directories' should also not contain the "../" and - ;; "./" elements if you don't want to see those in the `counsel-find-file' - ;; completion list. - (concat - ;; file names beginning with # or . - "\\(?:\\`[#.]\\)" - ;; file names ending with # or ~ - "\\|\\(?:[#~]\\'\\)")) + counsel-find-file-at-point t) (progn (ivy-set-actions 'counsel-find-file @@ -110,8 +264,8 @@ Otherwise, use `counsel-projectile-switch-project'." ;https://github.com/abo-abo/swiper/issues/427 )))) - (use-package company + :disabled :commands global-company-mode :init (add-hook 'after-init-hook #'global-company-mode) @@ -146,7 +300,8 @@ Otherwise, use `counsel-projectile-switch-project'." company-keywords))) (use-package company-emoji - :ensure company + :disabled + :after company :config (add-to-list 'company-backends 'company-emoji)) diff --git a/tools/emacs/config/setup-docker.el b/tools/emacs/config/setup-docker.el @@ -1,5 +1,6 @@ ;;; -*- lexical-binding: t; -*- (use-package dockerfile-mode ; Edit docker's Dockerfiles + :disabled :unless *sys/full* :mode ("Dockerfile\\'" . dockerfile-mode)) diff --git a/tools/emacs/config/setup-editing.el b/tools/emacs/config/setup-editing.el @@ -1,5 +1,6 @@ ;;; -*- lexical-binding: t; -*- -(setq enable-remote-dir-locals t) +(setq-default enable-remote-dir-locals t) + (use-package aggressive-indent ; Automatically indent code :bind ("C-c e i" . aggressive-indent-mode) :hook ((lisp-mode . aggressive-indent-mode) @@ -12,17 +13,18 @@ (use-package undo-tree ; Show buffer changes as a tree :defer 1 :init (global-undo-tree-mode) - :config (setq undo-tree-visualizer-timestamps t + :config + (setq-default undo-tree-visualizer-timestamps t undo-tree-enable-undo-in-region t)) (use-package whitespace - :defer 1 :hook ((prog-mode . whitespace-mode)) :config - (setq whitespace-style '(face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark))) + (setq-default whitespace-style '(face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark))) (use-package smartparens :defer 1 + :disabled :init (progn (use-package smartparens-config) @@ -47,6 +49,7 @@ ("C--". er/contract-region))) (use-package iedit + :disabled :defines hydra-iedit/body :bind* (:map global-map ("C-*" . iedit-mode) @@ -97,20 +100,17 @@ (global-set-key [remap kill-ring-save] 'easy-kill) (global-set-key [remap mark-sexp] 'easy-mark)) -(use-package define-word) - (setq display-line-numbers-type 'relative) (add-hook 'prog-mode-hook 'display-line-numbers-mode) (add-hook 'prog-mode-hook 'toggle-truncate-lines) (use-package newcomment - :custom - (comment-empty-lines t) - (comment-fill-column nil) - (comment-multi-line t) - (comment-style 'multi-line) :config + (setq-default comment-empty-lines t + comment-fill-column nil + comment-multi-line t + comment-style 'multi-line) (defun prot/comment-dwim (&optional arg) "Alternative to `comment-dwim': offers a simple wrapper around `comment-line' and `comment-dwim'. @@ -158,25 +158,24 @@ Else toggle the comment status of the line at point." ([remap flyspell-correct-word-before-point] . flyspell-correct-previous-word-generic))) (use-package electric - :custom - (electric-pair-inhibit-predicate 'electric-pair-default-inhibit) - (electric-pair-pairs '((8216 . 8217) - (8220 . 8221) - (171 . 187))) - (electric-pair-skip-self 'electric-pair-default-skip-self) - (electric-quote-context-sensitive t) - (electric-quote-paragraph t) - (electric-quote-string nil) :config + (setq-default electric-pair-inhibit-predicate 'electric-pair-default-inhibit + electric-pair-pairs '((8216 . 8217) + (8220 . 8221) + (171 . 187)) + electric-pair-skip-self 'electric-pair-default-skip-self + electric-quote-context-sensitive t + electric-quote-paragraph t + electric-quote-string nil) (electric-indent-mode 1) (electric-pair-mode 1) (electric-quote-mode -1)) (use-package emacs :init - (setq-default tab-always-indent 'complete) - (setq-default tab-width 4) - (setq-default indent-tabs-mode nil)) + (setq-default tab-always-indent 'complete + tab-width 4 + indent-tabs-mode nil)) (use-package emacs :hook (before-save . delete-trailing-whitespace)) diff --git a/tools/emacs/config/setup-files.el b/tools/emacs/config/setup-files.el @@ -1,26 +1,27 @@ ;;; -*- lexical-binding: t; -*- -(use-package files ; Core commands for files +(use-package files + :disabled :bind (("<f5>" . revert-buffer))) -(use-package ripgrep - :defer 2) - -(setq view-read-only t) ; View read-only +(setq-default view-read-only t) ; View read-only (use-package direnv - :custom - (direnv-always-show-summary t) - (direnv-show-paths-in-summary nil) + :disabled :config + (setq-default direnv-always-show-summary t + direnv-show-paths-in-summary nil) (direnv-mode)) -(use-package hardhat ; Protect user-writable files +(use-package hardhat + :disabled :init (global-hardhat-mode)) -(use-package image-file ; Visit images as images +(use-package image-file + :disabled :init (auto-image-file-mode)) -(use-package markdown-mode ; Edit markdown files +(use-package markdown-mode + :disabled :mode ("\\.md\\'" . markdown-mode) :config (setq markdown-fontify-code-blocks-natively t) @@ -41,19 +42,21 @@ (add-hook 'markdown-mode-hook #'auto-fill-mode)) (use-package highlight-indentation + :disabled :config (set-face-background 'highlight-indentation-face "#e3e3d3") (set-face-background 'highlight-indentation-current-column-face "#c3b3b3")) (use-package yaml-mode + :disabled :mode "\\.ya?ml\\'" :hook ((yaml-mode . highlight-indentation-mode) (yaml-mode . highlight-indentation-current-column-mode))) (use-package toml-mode + :disabled :mode "\\.to?ml\\'") -;;;###autoload (defun vde/delete-this-file () "Delete the current file, and kill the buffer." (interactive) @@ -63,7 +66,6 @@ (delete-file (buffer-file-name)) (kill-this-buffer))) -;;;###autoload (defun vde/rename-this-file-and-buffer (new-name) "Renames both current buffer and file it's visiting to NEW-NAME." (interactive "sNew name: ") diff --git a/tools/emacs/config/setup-go.el b/tools/emacs/config/setup-go.el @@ -1,5 +1,6 @@ ;;; -*- lexical-binding: t; -*- (use-package go-mode + :disabled :mode "\\.go$" :interpreter "go" :config @@ -16,13 +17,16 @@ "go build -v && go test -v && go vet"))) (use-package flycheck-golangci-lint + :disabled :hook (go-mode . flycheck-golangci-lint-setup) :config (setq flycheck-golangci-lint-tests t)) (use-package gotest + :disabled :after go-mode) (use-package gotest-ui + :disabled :after (go-mode gotest) :bind (:map go-mode-map ("C-c t t" . gotest-ui-current-test) diff --git a/tools/emacs/config/setup-hydras.el b/tools/emacs/config/setup-hydras.el @@ -1,38 +1,40 @@ ;;; -*- lexical-binding: t; -*- -(defhydra hydra-goto-line (goto-map "") - "goto-line" - ("g" goto-line "go") - ("m" set-mark-command "mark" :bind nil) - ("q" nil "quit")) +(when nil + (progn + (defhydra hydra-goto-line (goto-map "") + "goto-line" + ("g" goto-line "go") + ("m" set-mark-command "mark" :bind nil) + ("q" nil "quit")) -(defhydra hydra-yank-pop () - "yank" - ("C-y" yank nil) - ("M-y" yank-pop nil) - ("y" (yank-pop 1) "next") - ("Y" (yank-pop -1) "prev")) ; or browse-kill-ring + (defhydra hydra-yank-pop () + "yank" + ("C-y" yank nil) + ("M-y" yank-pop nil) + ("y" (yank-pop 1) "next") + ("Y" (yank-pop -1) "prev")) ; or browse-kill-ring -(defhydra hydra-zoom (global-map "<f2>") - "zoom" - ("g" text-scale-increase "in") - ("l" text-scale-decrease "out") - ("r" (text-scale-set 0) "reset") - ("0" (text-scale-set 0) :bind nil :exit t) - ("1" (text-scale-set 0) nil :bind nil :exit t)) + (defhydra hydra-zoom (global-map "<f2>") + "zoom" + ("g" text-scale-increase "in") + ("l" text-scale-decrease "out") + ("r" (text-scale-set 0) "reset") + ("0" (text-scale-set 0) :bind nil :exit t) + ("1" (text-scale-set 0) nil :bind nil :exit t)) -;; Better shrink/enlarge windows -(defhydra hydra-resize (global-map "<f2>") - "resize windows" - ("<up>" enlarge-window "enlarge") - ("<down>" shrink-window "shrink") - ("<left>" shrink-window-horizontally "shrink horizontaly") - ("<right>" enlarge-window-horizontally "enlarge horizontaly")) + ;; Better shrink/enlarge windows + (defhydra hydra-resize (global-map "<f2>") + "resize windows" + ("<up>" enlarge-window "enlarge") + ("<down>" shrink-window "shrink") + ("<left>" shrink-window-horizontally "shrink horizontaly") + ("<right>" enlarge-window-horizontally "enlarge horizontaly")) -(defvar hide-mode-line-mode nil) -(defvar whitespace-mode nil) -(defvar subword-mode nil) -(defhydra hydra-toggle (:color pink :hint nil) - " + (defvar hide-mode-line-mode nil) + (defvar whitespace-mode nil) + (defvar subword-mode nil) + (defhydra hydra-toggle (:color pink :hint nil) + " _a_ abbrev-mode: %`abbrev-mode _b_ subword-mode: %`subword-mode _d_ debug-on-error: %`debug-on-error @@ -45,22 +47,23 @@ _w_ whitespace-mode: %`whitespace-mode _s_ smartparens-strict: %`smartparens-strict-mode _V_ visible-mode: %`visible-mode " - ("a" abbrev-mode nil) - ("b" subword-mode nil) - ("d" toggle-debug-on-error nil) - ("f" auto-fill-mode nil) - ("h" hide-mode-line-mode nil) - ("r" dired-toggle-read-only nil) - ("t" toggle-truncate-lines nil) - ("v" visual-line-mode nil) - ("V" visible-mode nil) - ("w" whitespace-mode nil) - ("s" smartparens-strict-mode nil) - ("q" nil "quit")) + ("a" abbrev-mode nil) + ("b" subword-mode nil) + ("d" toggle-debug-on-error nil) + ("f" auto-fill-mode nil) + ("h" hide-mode-line-mode nil) + ("r" dired-toggle-read-only nil) + ("t" toggle-truncate-lines nil) + ("v" visual-line-mode nil) + ("V" visible-mode nil) + ("w" whitespace-mode nil) + ("s" smartparens-strict-mode nil) + ("q" nil "quit")) -(global-set-key (kbd "C-c C-v") 'hydra-toggle/body) + (global-set-key (kbd "C-c C-v") 'hydra-toggle/body) -(bind-key "M-y" #'hydra-yank-pop/yank-pop) -(bind-key "C-y" #'hydra-yank-pop/yank) + (bind-key "M-y" #'hydra-yank-pop/yank-pop) + (bind-key "C-y" #'hydra-yank-pop/yank) + )) (provide 'setup-hydras) diff --git a/tools/emacs/config/setup-keybindings.el b/tools/emacs/config/setup-keybindings.el @@ -1,4 +1,5 @@ (use-package which-key + :disabled :init (which-key-mode) :custom (which-key-idle-delay 2) @@ -15,26 +16,6 @@ (add-to-list 'which-key-replacement-alist '(("DEL" . nil) . ("⇤" . nil))) (add-to-list 'which-key-replacement-alist '(("SPC" . nil) . ("␣" . nil)))) -(use-package region-bindings-mode - :config - ;; Do not activate `region-bindings-mode' in Special modes like `dired' and - ;; `ibuffer'. Single-key bindings like 'm' are useful in those modes even - ;; when a region is selected. - (setq region-bindings-mode-disabled-modes '(dired-mode ibuffer-mode)) - - (region-bindings-mode-enable) - - (defun vde/disable-rbm-deactivate-mark () - "Disable `region-bindings-mode' and deactivate mark." - (interactive) - (region-bindings-mode -1) - (deactivate-mark) - (message "Mark deactivated")) - - (bind-keys - :map region-bindings-mode-map - ("<C-SPC>" . vde/disable-rbm-deactivate-mark))) - ;; Disable C-x C-n to avoid the disabled command buffer (unbind-key "C-x C-n" global-map) diff --git a/tools/emacs/config/setup-mails.el b/tools/emacs/config/setup-mails.el @@ -20,6 +20,8 @@ ;; SendmailCfg (use-package smtpmail + :defer t + ;;:commands (mail-mode mail-text) :config (setq message-send-mail-function 'message-send-mail-with-sendmail) (setq sendmail-program "msmtp") @@ -28,7 +30,7 @@ (use-package sendmail :defer t - :commands (mail-mode mail-text) + ;;:commands (mail-mode mail-text) :defines (send-mail-function) :config (setq send-mail-function 'sendmail-send-it diff --git a/tools/emacs/config/setup-multiple-cursors.el b/tools/emacs/config/setup-multiple-cursors.el @@ -1,4 +1,26 @@ +(use-package region-bindings-mode + :disabled + :config + ;; Do not activate `region-bindings-mode' in Special modes like `dired' and + ;; `ibuffer'. Single-key bindings like 'm' are useful in those modes even + ;; when a region is selected. + (setq region-bindings-mode-disabled-modes '(dired-mode ibuffer-mode)) + + (region-bindings-mode-enable) + + (defun vde/disable-rbm-deactivate-mark () + "Disable `region-bindings-mode' and deactivate mark." + (interactive) + (region-bindings-mode -1) + (deactivate-mark) + (message "Mark deactivated")) + + (bind-keys + :map region-bindings-mode-map + ("<C-SPC>" . vde/disable-rbm-deactivate-mark))) + (use-package multiple-cursor + :disabled :bind (:map region-bindings-mode-map ("a" . mc/mark-all-like-this) ("p" . mc/mark-previous-like-this) diff --git a/tools/emacs/config/setup-navigating.el b/tools/emacs/config/setup-navigating.el @@ -1,25 +1,20 @@ -(use-package avy ; Jump to characters in buffers +(use-package avy + :disabled :bind (("C-c j" . avy-goto-word-1) ("C-c n b" . avy-pop-mark) ("C-c n j" . avy-goto-char-2) ("C-c n t" . avy-goto-char-timer) ("C-c n w" . avy-goto-word-1))) -(use-package helpful - :unless noninteractive - :bind (("C-c h F" . helpful-function) - ("C-c h C" . helpful-command) - ("C-c h M" . helpful-macro) - ("C-c h L" . helpful-callable) - ("C-c h S" . helpful-at-point) - ("C-c h V" . helpful-variable))) (use-package winner + :disabled :unless noninteractive :defer 5 :config (winner-mode 1)) (use-package hideshow + :disabled :defer 5 :bind (("C-c @ a" . hs-show-all) ("C-c @ c" . hs-toggle-hiding) @@ -28,6 +23,7 @@ ("C-c @ l" . hs-hide-level))) (use-package mwim + :disabled :bind (:map prog-mode-map ("C-a" . mwim-beginning-of-code-or-line) ("C-e" . mwim-end-of-code-or-line))) diff --git a/tools/emacs/config/setup-projectile.el b/tools/emacs/config/setup-projectile.el @@ -1,6 +1,6 @@ ;;; -*- lexical-binding: t; -*- (use-package projectile - :defer t + :disabled :commands (projectile-ack projectile-ag @@ -33,7 +33,6 @@ (setq ;; Custom compilation buffer name function compilation-buffer-name-function (lambda (mode) (concat "*" (downcase mode) ": " (projectile-project-name) "*")) - projectile-completion-system 'ivy projectile-find-dir-includes-top-level t projectile-switch-project-action #'projectile-commander projectile-create-missing-test-files t @@ -45,11 +44,4 @@ "Run `compile' in the project" (projectile-compile-project nil))) -(use-package counsel-projectile ; Ivy integration for Projectile - :commands (counsel-projectile-switch-project) - :bind (:map projectile-command-map - ("p" . counsel-projectile-switch-project) - ("r" . counsel-projectile-rg)) - :config (counsel-projectile-mode)) - (provide 'setup-projectile) diff --git a/tools/emacs/config/setup-search.el b/tools/emacs/config/setup-search.el @@ -7,21 +7,13 @@ ;; Truncate lines during grep (add-hook 'grep-mode-hook #'toggle-truncate-lines) + (use-package isearch - :custom - (search-whitespace-regexp ".*?") - (isearch-lax-whitespace t) - (isearch-regexp-lax-whitespace nil) + :disabled :config - (defun prot/isearch-mark-and-exit () - "Marks the current search string. Can be used as a building -block for a more complex chain, such as to kill a region, or -place multiple cursors." - (interactive) - (push-mark isearch-other-end t 'activate) - (setq deactivate-mark nil) - (isearch-done)) - + (setq-default search-whitespace-regexp ".*?" + isearch-lax-whitespace t + isearch-regexp-lax-whitespace nil) (defun stribb/isearch-region (&optional not-regexp no-recursive-edit) "If a region is active, make this the isearch default search pattern." @@ -58,11 +50,11 @@ confines of word boundaries (e.g. multiple words)." (when isearch-other-end (goto-char isearch-other-end))) :bind (("M-s M-o" . multi-occur) :map isearch-mode-map - ("C-SPC" . prot/isearch-mark-and-exit) ("DEL" . contrib/isearchp-remove-failed-part-or-last-char) ("<C-return>" . contrib/isearch-done-opposite-end))) (use-package anzu + :disabled :ensure t :delight :custom @@ -79,6 +71,7 @@ confines of word boundaries (e.g. multiple words)." ("M-s %" . anzu-query-replace-at-cursor)) (use-package swiper + :disabled :after ivy :custom (swiper-action-recenter t) @@ -91,17 +84,15 @@ confines of word boundaries (e.g. multiple words)." ("M-y" . yank) ("C-." . swiper-avy))) -(use-package wgrep ; Editable grep buffer +(use-package wgrep + :disabled :defer 2 :custom (wgrep-auto-save-buffer t) (wgrep-change-readonly-file t)) -(use-package visual-regexp ; Regexp replace with in-buffer display - :bind (("C-c s r" . vr/query-replace) - ("C-c s R" . vr/replace))) - (use-package rg + :disabled :hook (after-init . rg-enable-default-binding)) (provide 'setup-search) diff --git a/tools/emacs/config/setup-shells.el b/tools/emacs/config/setup-shells.el @@ -1,17 +1,17 @@ ;;; -*- lexical-binding: t; -*- -(use-package shell ; Specialized comint.el for running the shell - :custom - ;(ansi-color-for-comint-mode 'filter) - (explicit-shell-file-name "zsh") - (shell-file-name "zsh") +(use-package shell + :disabled :bind (("<f1>" . shell) (:map shell-mode-map ("<tab>" . completion-at-point))) :config + (setq-default explicit-shell-file-name "zsh" + shell-file-name "zsh") (unbind-key "C-c C-l" shell-mode-map) (bind-key "C-c C-l" #'counsel-shell-history shell-mode-map)) -(use-package eshell ; Emacs command shell +(use-package eshell + :disabled :bind* ("C-x m t" . eshell-here) :config (defun eshell-here () @@ -85,7 +85,9 @@ The EShell is renamed to match that directory to make multiple windows easier." (add-hook 'eshell-mode-hook #'with-editor-export-editor)) -(use-package em-prompt ; EShell command prompts +(use-package em-prompt + :disabled + :after eshell :defer 2 :config (defun vde/eshell-quit-or-delete-char (arg) @@ -101,19 +103,42 @@ The EShell is renamed to match that directory to make multiple windows easier." (bind-key "C-d" #'vde/eshell-quit-or-delete-char eshell-mode-map)))) -(use-package esh-mode ; EShell UI customizations - :ensure eshell - :config (setq eshell-scroll-to-bottom-on-input 'all)) +(use-package esh-mode + :disabled + :after eshell + :bind (:map eshell-mode-map + ("<tab>" . vde/esh-mode-completion-at-point)) + :config + (setq-default eshell-scroll-to-bottom-on-input 'all) + (defun vde/esh-mode-completion-at-point () + "Same as `completion-at-point' except for some commands." + (interactive) + ;; unbinding pcomplete/make gives a chance to `bash-completion' + ;; to complete make rules. Bash-completion is indeed more + ;; powerfull than `pcomplete-make'. + (cl-letf (((symbol-function 'pcomplete/make) nil)) + (completion-at-point)))) (use-package em-smart - :ensure eshell) + :disabled + :after eshell) (use-package em-dirs - :ensure eshell) + :disabled + :after eshell) -(use-package em-cmpl ; EShell TAB completion - :ensure eshell +(use-package em-cmpl + :disabled + :after eshell + :hook (eshell-mode . eshell-cmpl-initialize) :config - (add-hook 'eshell-mode-hook #'eshell-cmpl-initialize) + (defun my/eshell-bash-completion () + (let ((bash-completion-nospace t)) + (while (pcomplete-here + (nth 2 (bash-completion-dynamic-complete-nocomint + (save-excursion (eshell-bol) (point)) + (point))))))) + (when (require 'bash-completion nil t) + (setq eshell-default-completion-function #'my/eshell-bash-completion)) (add-to-list 'eshell-command-completions-alist '("gunzip" "gz\\'")) @@ -121,11 +146,13 @@ The EShell is renamed to match that directory to make multiple windows easier." '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))) (use-package em-hist ; EShell History management - :ensure eshell + :disabled + :after eshell :config (setq eshell-hist-ignoredups t)) (use-package em-term ; Handle visual commands in EShell - :ensure eshell + :disabled + :after eshell :config (add-to-list 'eshell-visual-commands "ssh") (add-to-list 'eshell-visual-commands "htop") @@ -135,7 +162,8 @@ The EShell is renamed to match that directory to make multiple windows easier." (add-to-list 'eshell-visual-commands "ncdu")) (use-package em-banner - :ensure eshell + :disabled + :after eshell :config (setq eshell-banner-message " Welcome to the Emacs @@ -148,13 +176,15 @@ The EShell is renamed to match that directory to make multiple windows easier." ")) -(use-package fish-completion ; Add Fish completion to EShell +(use-package fish-completion + :disabled :defer 2 :when (executable-find "fish") :config (add-hook 'eshell-mode-hook #'fish-completion-mode)) (use-package eshell-prompt-extras - :defer 1 + :disabled + :after eshell :custom (eshell-highlight-prompt nil) (eshell-prompt-function 'vde-theme-lambda) @@ -209,9 +239,12 @@ using either KUBECONFIG or ~/.kube/config" (use-package esh-autosuggest :defer 1 + :disabled :hook (eshell-mode . esh-autosuggest-mode)) (use-package xterm-color + :disabled + :after eshell :init (setq comint-output-filter-functions (remove 'ansi-color-process-output comint-output-filter-functions)) @@ -248,6 +281,7 @@ using either KUBECONFIG or ~/.kube/config" (add-hook 'term-mode-hook 'toggle-truncate-lines) (use-package tramp + :defer t :config (add-to-list 'tramp-remote-path "/run/current-system/sw/bin") (add-to-list 'tramp-remote-path "~/.nix-profile/bin") diff --git a/tools/emacs/config/setup-style.el b/tools/emacs/config/setup-style.el @@ -3,203 +3,101 @@ ;;; Setup of the style, from font faces to themes ;;; Code: -;; TypeFaceConfiguration -;;; ¯\_(ツ)_/¯ -(defconst font-height 130 - "Default font-height to use.") - -(use-package emacs - :bind ("C-c f r" . mu-reset-fonts) - :config - ;; Middle/Near East: שלום, السّلام عليكم - (when (member "Noto Sans Arabic" (font-family-list)) - (set-fontset-font t 'arabic "Noto Sans Arabic")) - (when (member "Noto Sans Hebrew" (font-family-list)) - (set-fontset-font t 'arabic "Noto Sans Hebrew")) - ;; Africa: ሠላም - (when (member "Noto Sans Ethiopic" (font-family-list)) - (set-fontset-font t 'ethiopic "Noto Sans Ethiopic")) - - ;; Default font is Ubuntu Mono (and Ubuntu Sans for variable-pitch) - ;; If Ubuntu Mono or Ubuntu Sans are not available, use the default Emacs face - (when (member "Ubuntu Mono" (font-family-list)) - (set-face-attribute 'default nil - :family "Ubuntu Mono" - :height font-height)) - (when (member "Ubuntu Sans" (font-family-list)) - (set-face-attribute 'variable-pitch nil - :family "Ubuntu Sans" - :height font-height - :weight 'regular)) - - (defun mu-reset-fonts () - "Reset fonts to my preferences." - (interactive) - (when when (member "Ubuntu Mono" (font-family-list)) - (set-face-attribute 'default nil - :family "Ubuntu Mono" - :height font-height)) - (when when (member "Ubuntu Sans" (font-family-list)) - (set-face-attribute 'variable-pitch nil - :family "Ubuntu Sans" - :height font-height - :weight 'regular)))) -;; -TypeFaceConfiguration - -;;; Interface -(use-package frame ; Frames - :bind ("C-c w f" . toggle-frame-fullscreen) - :init - ;; Kill `suspend-frame' - (unbind-key "C-x C-z") - :config (add-to-list 'initial-frame-alist '(fullscreen . maximized))) - -(use-package emacs - :custom - (use-file-dialog nil) - (use-dialog-box nil) - (echo-keystrokes 0.1) ; Faster echo keystrokes - (line-number-display-limit-width 10000) ;; Avoid showing ?? in the mode line when we have long lines. - (display-time-world-list '(("Europe/London" "London") - ("Europe/Paris" "Paris") - ("America/New_York" "Boston") - ("America/Los_Angeles" "San-Francisco") - ("Asia/Calcutta" "Bangalore") - ("Australia/Brisbane" "Brisbane"))) - :config - (line-number-mode 1) - (column-number-mode 1) - (global-hl-line-mode 1) - (global-unset-key (kbd "C-z")) - (global-unset-key (kbd "C-x C-z")) - (global-unset-key (kbd "C-h h"))) - -;;; Theme -(setq custom-safe-themes t) ; Treat themes as safe - -(use-package shortbrain-light-theme - :config - (load-theme 'shortbrain-light)) - -;; Show buffer position percentage starting from top -(setq mode-line-percent-position '(-3 "%o")) -(defvar mu-eyebrowse-mode-line - '(:propertize - (:eval - (when (bound-and-true-p eyebrowse-mode) - (let* ((num (eyebrowse--get 'current-slot)) - (tag (when num - (nth 2 (assoc num (eyebrowse--get 'window-configs))))) - (str (concat - " " - (if (and tag (< 0 (length tag))) - tag - (when num (int-to-string num))) - " "))) - str))) - face (:background "#81a2be" :foreground "#373b41")) - "Mode line format for Eyebrowse.") - -(put 'mu-eyebrowse-mode-line 'risky-local-variable t) - -(setq-default mode-line-format - '("%e" - mu-eyebrowse-mode-line - mode-line-front-space - mode-line-mule-info - mode-line-client - mode-line-modified - mode-line-remote - mode-line-frame-identification - mode-line-buffer-identification " " mode-line-position - (vc-mode vc-mode) - (multiple-cursors-mode mc/mode-line) - " " mode-line-modes - mode-line-end-spaces)) - -(defmacro rename-modeline (package-name mode new-name) - "Rename PACKAGE-NAME with MODE into NEW-NAME in the mode line." - `(eval-after-load ,package-name - '(defadvice ,mode (after rename-modeline activate) - (setq mode-name ,new-name)))) - -(defun generic-term-init () - (visual-line-mode -1) - (setq-local global-hl-line-mode nil) - (setq-local scroll-margin 0)) - -(add-hook 'term-mode-hook #'generic-term-init) -(add-hook 'shell-mode-hook #'generic-term-init) -(add-hook 'eshell-mode-hook #'generic-term-init) - -(use-package moody - :config - (setq x-underline-at-descent-line t) - (moody-replace-mode-line-buffer-identification) - (moody-replace-vc-mode)) - -(use-package minions ; A minor-mode menu for the mode line - :init (minions-mode) - :config - (setq - minions-mode-line-lighter "λ=" - minions-direct '(flycheck-mode))) - -(setq-default indicate-buffer-boundaries 'left) -(setq-default indicate-empty-lines +1) - -(use-package highlight - :ensure t - :pin melpa) - -(use-package highlight-numbers - :hook (prog-mode . highlight-numbers-mode)) - -(use-package symbol-overlay - :defer 4 - :bind - ("M-s h ." . symbol-overlay-put) - ("M-s h n" . symbol-overlay-jump-next) - ("M-s h p" . symbol-overlay-jump-prev) - :hook (prog-mode . symbol-overlay-mode) - :config - (setq symbol-overlay-idle-time 0.2)) - -(use-package rainbow-delimiters - :hook (prog-mode . rainbow-delimiters-mode)) - -(use-package rainbow-mode - :commands rainbow-mode - :hook (prog-mode . rainbow-mode)) - -(use-package visual-fill-column - :commands visual-fill-column-mode) - -(use-package hide-mode-line-mode - :commands hide-mode-line-mode) - -(defun set-light-theme () - "Set the light theme with some customization if needed." - (interactive) - (use-package shortbrain-light-theme - :config - (load-theme 'shortbrain-light t))) - -(defun set-dark-theme () - "Set the dark theme with some customization if needed." - (interactive) - (use-package shortbrain-theme - :config - (load-theme 'shortbrain t))) - -(defun theme-switcher () - (interactive) - (let ((current-hour (string-to-number (format-time-string "%H")))) - (if (and (> current-hour 6) (< current-hour 20)) - (set-light-theme) - (set-dark-theme)))) - -;; Run at every 3600 seconds, after 0s delay -;; (run-with-timer 0 3600 'theme-switcher) +(when nil + (progn + ;;; Interface + (use-package frame ; Frames + :bind ("C-c w f" . toggle-frame-fullscreen) + :init + ;; Kill `suspend-frame' + (unbind-key "C-x C-z") + :config (add-to-list 'initial-frame-alist '(fullscreen . maximized))) + + ;; Show buffer position percentage starting from top + + + (setq-default mode-line-format + '("%e" + mu-eyebrowse-mode-line + mode-line-front-space + mode-line-mule-info + mode-line-client + mode-line-modified + mode-line-remote + mode-line-frame-identification + mode-line-buffer-identification " " mode-line-position + (vc-mode vc-mode) + (multiple-cursors-mode mc/mode-line) + " " mode-line-modes + mode-line-end-spaces)) + + (defmacro rename-modeline (package-name mode new-name) + "Rename PACKAGE-NAME with MODE into NEW-NAME in the mode line." + `(eval-after-load ,package-name + '(defadvice ,mode (after rename-modeline activate) + (setq mode-name ,new-name)))) + + (defun generic-term-init () + (visual-line-mode -1) + (setq-local global-hl-line-mode nil) + (setq-local scroll-margin 0)) + + (add-hook 'term-mode-hook #'generic-term-init) + (add-hook 'shell-mode-hook #'generic-term-init) + (add-hook 'eshell-mode-hook #'generic-term-init) + + (setq-default indicate-buffer-boundaries 'left) + (setq-default indicate-empty-lines +1) + + (use-package highlight-numbers + :hook (prog-mode . highlight-numbers-mode)) + + (use-package symbol-overlay + :defer 4 + :bind + ("M-s h ." . symbol-overlay-put) + ("M-s h n" . symbol-overlay-jump-next) + ("M-s h p" . symbol-overlay-jump-prev) + :hook (prog-mode . symbol-overlay-mode) + :config + (setq symbol-overlay-idle-time 0.2)) + + (use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + + (use-package rainbow-mode + :commands rainbow-mode + :hook (prog-mode . rainbow-mode)) + + (use-package visual-fill-column + :commands visual-fill-column-mode) + + (use-package hide-mode-line-mode + :commands hide-mode-line-mode) + + (defun set-light-theme () + "Set the light theme with some customization if needed." + (interactive) + (use-package shortbrain-light-theme + :config + (load-theme 'shortbrain-light t))) + + (defun set-dark-theme () + "Set the dark theme with some customization if needed." + (interactive) + (use-package shortbrain-theme + :config + (load-theme 'shortbrain t))) + + (defun theme-switcher () + (interactive) + (let ((current-hour (string-to-number (format-time-string "%H")))) + (if (and (> current-hour 6) (< current-hour 20)) + (set-light-theme) + (set-dark-theme)))) + + ;; Run at every 3600 seconds, after 0s delay + ;; (run-with-timer 0 3600 'theme-switcher) + )) (provide 'setup-style) diff --git a/tools/emacs/config/setup-vcs.el b/tools/emacs/config/setup-vcs.el @@ -1,12 +1,14 @@ ;;; -*- lexical-binding: t; -*- (use-package vc-hooks ; Simple version control + :disabled :bind (("S-<f5>" . vc-revert) ("C-c v r" . vc-refresh-state)) :config ;; Always follow symlinks to files in VCS repos - (setq vc-follow-symlinks t)) + (setq-default vc-follow-symlinks t)) (use-package magit ; The best Git client out there + :disabled :bind (("C-c v c" . magit-clone) ("C-c v C" . magit-checkout) ("C-c v d" . magit-dispatch-popup) @@ -15,13 +17,11 @@ ("C-c v p" . magit-pull) ("C-c v v" . magit-status)) :config - (setq - magit-save-repository-buffers 'dontask - magit-refs-show-commit-count 'all - magit-branch-prefer-remote-upstream '("master") - magit-display-buffer-function #'magit-display-buffer-traditional - magit-completing-read-function 'ivy-completing-read - ) + (setq-default magit-save-repository-buffers 'dontask + magit-refs-show-commit-count 'all + magit-branch-prefer-remote-upstream '("master") + magit-display-buffer-function #'magit-display-buffer-traditional + magit-completing-read-function 'ivy-completing-read) (magit-define-popup-option 'magit-rebase-popup ?S "Sign using gpg" "--gpg-sign=" #'magit-read-gpg-secret-key) @@ -34,10 +34,6 @@ 'magit-insert-unpushed-to-upstream-or-recent 'replace) - (use-package magit-files - :config - (global-magit-file-mode)) - ;; Show refined hunks during diffs (set-default 'magit-diff-refine-hunk t) @@ -50,14 +46,9 @@ ;; Free C-c C-w for Eyebrowse (unbind-key "C-c C-w" git-commit-mode-map) ) (put 'magit-diff-edit-hunk-commit 'disabled nil) -(use-package magit-repos - :after magit - :commands magit-list-repositories - :config - (setq magit-repository-directories - '(("~/src" . 3)))) (use-package git-commit ; Git commit message mode + :disabled :defer 2 :init (global-git-commit-mode) :config @@ -78,20 +69,25 @@ #'git-commit-check-style-conventions)) (use-package gitconfig-mode ; Git configuration mode + :disabled :defer 2) (use-package gitignore-mode ; .gitignore mode + :disabled :defer 2) (use-package gitattributes-mode ; Git attributes mode + :disabled :defer 2) (use-package dired-git-info + :disabled :bind (:map dired-mode-map (")" . dired-git-info-mode)) :defer 2) (use-package ediff + :disabled :config (setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-split-window-function 'split-window-horizontally) diff --git a/tools/emacs/config/setup-windows.el b/tools/emacs/config/setup-windows.el @@ -1,6 +1,5 @@ ;;; -*- lexical-binding: t; -*- -;;;###autoload (defun vde/window-split-toggle () "Toggle between horizontal and vertical split with two windows." (interactive) @@ -17,21 +16,8 @@ (bind-key "C-c w t" #'vde/window-split-toggle) -(defvar vde/saved-window-configuration nil) - -(defun vde/save-wins-then-call (func &optional args) - "Save current window configuration, then call FUNC optionally with ARGS." - (interactive) - (push (current-window-configuration) vde/saved-window-configuration) - (cond - ;; We have arguments for the function - ((bound-and-true-p args) (funcall func args)) - ;; The function expects exactly one argument, and we want it to be nil - ((equal args "nil") (funcall func nil)) - ;; The function does not expect arguments - (t (funcall func)))) - (use-package eyebrowse ; Easy workspaces creation and switching + :disabled :init (eyebrowse-mode t) :config (setq @@ -41,6 +27,7 @@ eyebrowse-wrap-around t)) (use-package ace-window ; Better movements between windows + :disabled :custom (aw-keys '(?a ?u ?i ?e ?, ?c ?t ?r ?m)) (aw-scope 'frame) @@ -59,6 +46,7 @@ ("C-c w s" . ace-swap-window))) (use-package windmove + :disabled :bind (("M-<left>" . windmove-left) ("M-<down>" . windmove-down) ("M-<up>" . windmove-up)