diff options
author | David Morgan <djm_uk@protonmail.com> | 2021-08-17 12:49:19 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2021-08-17 12:49:19 +0100 |
commit | d0db5660caa836755ea8c99471d816484ea9e837 (patch) | |
tree | c7d0456a58e450abaf34b489b0b31c58ddbc8557 /.emacs.d/lisp/init-smartparens.el | |
parent | c92b18514728245850d31531ce224a74eddfc5a6 (diff) | |
download | dotfiles-d0db5660caa836755ea8c99471d816484ea9e837.tar.gz |
Add new .emacs.d
Diffstat (limited to '.emacs.d/lisp/init-smartparens.el')
-rw-r--r-- | .emacs.d/lisp/init-smartparens.el | 47 |
1 files changed, 47 insertions, 0 deletions
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 |