2021-02-21 02:59:11 +00:00
|
|
|
;; -*- lexical-binding: t; -*-
|
|
|
|
|
2021-02-20 18:47:46 +00:00
|
|
|
;; General text editing configuration
|
|
|
|
|
|
|
|
;; Better isearch
|
|
|
|
(use-package ctrlf
|
|
|
|
:config
|
|
|
|
(ctrlf-mode 1))
|
|
|
|
|
|
|
|
;; "pair" management, where pairs are parentheses, braces, etc.
|
|
|
|
(use-package smartparens
|
2021-02-23 17:14:20 +00:00
|
|
|
:init
|
|
|
|
(leader-def-key "s" '(nil :which-key "smartparens"))
|
2021-02-20 18:47:46 +00:00
|
|
|
:config
|
|
|
|
(require 'smartparens-config)
|
|
|
|
(smartparens-global-mode)
|
|
|
|
(defun sp-wrap-double-quote ()
|
|
|
|
(interactive)
|
|
|
|
(sp-wrap-with-pair "\""))
|
|
|
|
(defun sp-wrap-single-quote ()
|
|
|
|
(interactive)
|
|
|
|
(sp-wrap-with-pair "'"))
|
2021-05-12 15:02:33 +00:00
|
|
|
(defun sp-after-equals-p (_id action _context)
|
|
|
|
(when (memq action '(insert navigate))
|
|
|
|
(sp--looking-back-p "=>" 2)))
|
|
|
|
;; Enable ES6 arrow functions in web mode
|
|
|
|
(defun sp-after-equals-skip-p (ms mb _me)
|
|
|
|
(when (eq ms ">")
|
|
|
|
(save-excursion
|
|
|
|
(goto-char mb)
|
|
|
|
(sp--looking-back-p "=" 1))))
|
|
|
|
|
|
|
|
(sp-local-pair '(web-mode) "<" nil
|
|
|
|
:unless '(:add sp-after-equals-p)
|
|
|
|
:skip-match 'sp-after-equals-skip-p)
|
2021-02-20 18:47:46 +00:00
|
|
|
:hook
|
|
|
|
(prog-mode . smartparens-strict-mode)
|
2021-02-21 21:09:39 +00:00
|
|
|
(eshell-mode . smartparens-strict-mode)
|
2021-02-20 18:47:46 +00:00
|
|
|
:general
|
|
|
|
;; Wrapping
|
|
|
|
(leader-map
|
|
|
|
"s(" #'sp-wrap-round
|
|
|
|
"s{" #'sp-wrap-curly
|
|
|
|
"s'" #'sp-wrap-single-quote
|
|
|
|
"s\"" #'sp-wrap-double-quote
|
|
|
|
"sW" #'sp-unwrap-sexp
|
|
|
|
"sl" #'sp-next-sexp
|
|
|
|
"sh" #'sp-backward-sexp
|
|
|
|
"sj" #'sp-down-sexp
|
|
|
|
"sk" #'sp-backward-up-sexp
|
|
|
|
"sL" #'sp-forward-symbol
|
|
|
|
"sH" #'sp-backward-symbol
|
|
|
|
"s^" #'sp-beginning-of-sexp
|
|
|
|
"s$" #'sp-end-of-sexp
|
|
|
|
"st" #'sp-transpose-sexp
|
|
|
|
"su" #'undo-tree-undo
|
|
|
|
"sy" #'sp-copy-sexp
|
|
|
|
"sd" #'sp-kill-sexp
|
|
|
|
"ss" #'sp-forward-slurp-sexp
|
|
|
|
"sS" #'sp-backward-slurp-sexp
|
|
|
|
"sb" #'sp-forward-barf-sexp
|
|
|
|
"sB" #'sp-backward-barf-sexp
|
|
|
|
"sv" #'sp-select-next-thing
|
|
|
|
"sV" #'sp-select-previous-thing)
|
|
|
|
(normal "g(" #'sp-wrap-round
|
|
|
|
"g[" #'sp-wrap-square
|
|
|
|
"g{" #'sp-wrap-curly
|
|
|
|
"g\"" #'sp-wrap-double-quote
|
|
|
|
"g'" #'sp-wrap-single-quote))
|
|
|
|
|
|
|
|
(use-package evil-smartparens
|
|
|
|
:after (evil smartparens)
|
|
|
|
:hook (smartparens-enabled . evil-smartparens-mode))
|
|
|
|
|
|
|
|
;; Automagical indent
|
|
|
|
(use-package aggressive-indent
|
2021-02-21 03:02:45 +00:00
|
|
|
:hook ((lisp-mode . aggressive-indent-mode)
|
|
|
|
(emacs-lisp-mode . aggressive-indent-mode)
|
|
|
|
(clojure-mode . aggressive-indent-mode)))
|
|
|
|
|
2021-02-21 03:03:33 +00:00
|
|
|
;; Highlight indent level for whitespace-sensitive languages
|
|
|
|
(use-package highlight-indent-guides
|
|
|
|
:commands highlight-indent-guides-mode
|
|
|
|
:custom
|
|
|
|
(highlight-indent-guides-method 'character)
|
|
|
|
(highlight-indent-guides-auto-character-face-perc 7)
|
|
|
|
(highlight-indent-guides-responsive 'stack)
|
|
|
|
(highlight-indent-guides-auto-stack-character-face-perc 10))
|
2021-02-20 18:47:46 +00:00
|
|
|
|
2021-02-22 22:06:50 +00:00
|
|
|
;; Handy mode for prose writing and reading
|
|
|
|
(use-package olivetti
|
|
|
|
:general
|
|
|
|
("C-c o" #'olivetti-mode))
|
|
|
|
|
2021-02-24 21:51:25 +00:00
|
|
|
;; Multiple cursors
|
|
|
|
(use-package evil-multiedit
|
|
|
|
:defer 2
|
|
|
|
:config
|
|
|
|
(evil-multiedit-default-keybinds))
|
|
|
|
|
2021-02-27 05:14:21 +00:00
|
|
|
;; Don't choke on files with long lines
|
|
|
|
(use-package so-long
|
|
|
|
:straight (:type built-in)
|
|
|
|
:demand t
|
|
|
|
:config
|
|
|
|
(global-so-long-mode))
|
|
|
|
|
2021-03-02 01:29:16 +00:00
|
|
|
;; Polite white-space trimming
|
|
|
|
(use-package ws-butler
|
|
|
|
:hook (prog-mode . ws-butler-mode))
|
|
|
|
|
2021-03-03 14:28:20 +00:00
|
|
|
;; Inc/dec numbers
|
|
|
|
(use-package evil-numbers
|
|
|
|
:straight (:host github :repo "juliapath/evil-numbers")
|
|
|
|
:general
|
|
|
|
(normal "g+" #'evil-numbers/inc-at-pt)
|
|
|
|
(normal "g-" #'evil-numbers/dec-at-pt)
|
|
|
|
(normal "g M-+" #'evil-numbers/inc-at-pt-incremental)
|
|
|
|
(normal "g M--" #'evil-numbers/dec-at-pt-incremental))
|
|
|
|
|
2021-02-20 18:47:46 +00:00
|
|
|
(provide 'init-editing)
|