feat: Add Smartparens
This commit is contained in:
@@ -135,6 +135,8 @@ As with the rest of the config, these are largely adapted from Doom's ([cite:@li
|
|||||||
|
|
||||||
- ~syd-«NAME»-initialise~, where ~modules/«NAME» ∈ modules/*.el~ :: Instead of using top-level side-effects, (bar e.g. ~use-package~ invocations) should be wrapped in this kind of initialisation procedure.
|
- ~syd-«NAME»-initialise~, where ~modules/«NAME» ∈ modules/*.el~ :: Instead of using top-level side-effects, (bar e.g. ~use-package~ invocations) should be wrapped in this kind of initialisation procedure.
|
||||||
|
|
||||||
|
- ~«NAME»-h~ :: Procedure defined specifically to be added to a hook.
|
||||||
|
|
||||||
* Tasks
|
* Tasks
|
||||||
|
|
||||||
** Begin setting up doomless Emacs
|
** Begin setting up doomless Emacs
|
||||||
|
|||||||
@@ -17,4 +17,5 @@
|
|||||||
(require 'syd-display-startup-time)
|
(require 'syd-display-startup-time)
|
||||||
(require 'syd-evil)
|
(require 'syd-evil)
|
||||||
(require 'syd-keybinds)
|
(require 'syd-keybinds)
|
||||||
|
(require 'syd-smartparens)
|
||||||
(require 'syd-ui)
|
(require 'syd-ui)
|
||||||
|
|||||||
55
users/crumb/programs/emacs/modules/syd-smartparens.el
Normal file
55
users/crumb/programs/emacs/modules/syd-smartparens.el
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
;;; syd-smartparens.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Smartparens, most importantly to me, automatically closes opened delimiters.
|
||||||
|
;; It additionally offers a lot of Paredit-like functionality, but we do not yet
|
||||||
|
;; use any of it.
|
||||||
|
;; FIXME: If the first buffer visited is the eval minibuffer, smartparens is not
|
||||||
|
;; activated.
|
||||||
|
(use-package smartparens
|
||||||
|
:hook (on-first-buffer . smartparens-global-mode)
|
||||||
|
:custom
|
||||||
|
;; Overlays are too distracting and not terribly helpful. show-parens does
|
||||||
|
;; this for us already (and is faster), so...
|
||||||
|
((sp-highlight-pair-overlay nil)
|
||||||
|
(sp-highlight-wrap-overlay nil)
|
||||||
|
(sp-highlight-wrap-tag-overlay nil)
|
||||||
|
|
||||||
|
;; The default is 100. because smartparen's scans are relatively expensive
|
||||||
|
;; (especially with large pair lists for some modes), we reduce it, as a
|
||||||
|
;; better compromise between performance and accuracy.
|
||||||
|
(sp-max-prefix-length 25)
|
||||||
|
|
||||||
|
;; No pair has any business being longer than 4 characters; if they must, set
|
||||||
|
;; it buffer-locally. It's less work for smartparens.
|
||||||
|
(sp-max-pair-length 4))
|
||||||
|
:config
|
||||||
|
;; load default config
|
||||||
|
(require 'smartparens-config)
|
||||||
|
;; Silence some harmless but annoying echo-area spam
|
||||||
|
(dolist (key '(:unmatched-expression :no-matching-tag))
|
||||||
|
(setf (alist-get key sp-message-alist) nil))
|
||||||
|
|
||||||
|
(defun syd-init-smartparens-in-eval-expression-h ()
|
||||||
|
"Enable `smartparens-mode' in the minibuffer for `eval-expression'. This
|
||||||
|
includes everything that calls `read--expression', e.g. `edebug-eval-expression'
|
||||||
|
Only enable it if `smartparens-global-mode' is on."
|
||||||
|
(when smartparens-global-mode
|
||||||
|
(smartparens-mode 1)))
|
||||||
|
|
||||||
|
(add-hook 'eval-expression-minibuffer-setup-hook
|
||||||
|
#'syd-init-smartparens-in-eval-expression-h)
|
||||||
|
|
||||||
|
(defun syd-init-smartparens-in-minibuffer-maybe-h ()
|
||||||
|
"Enable `smartparens' for non-`eval-expression' commands. Only enable
|
||||||
|
`smartparens-mode' if `smartparens-global-mode' is on."
|
||||||
|
(when (and smartparens-global-mode (memq this-command '(evil-ex)))
|
||||||
|
(smartparens-mode 1)))
|
||||||
|
|
||||||
|
(add-hook 'minibuffer-setup-hook #'syd-init-smartparens-in-minibuffer-maybe-h)
|
||||||
|
|
||||||
|
;; You're likely writing lisp in the minibuffer, therefore, disable these
|
||||||
|
;; quote pairs, which lisps doesn't use for strings:
|
||||||
|
(sp-local-pair '(minibuffer-mode minibuffer-inactive-mode) "'" nil :actions nil)
|
||||||
|
(sp-local-pair '(minibuffer-mode minibuffer-inactive-mode) "`" nil :actions nil))
|
||||||
|
|
||||||
|
(provide 'syd-smartparens)
|
||||||
Reference in New Issue
Block a user