Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My smartparens configuration
(use-package smartparens
:diminish smartparens-mode
:init
(smartparens-global-mode)
:config
(require 'smartparens-config)
(add-hook 'eval-expression-minibuffer-setup-hook #'smartparens-mode)
(custom-set-variables
'(sp-base-key-bindings 'sp)
'(sp-override-key-bindings
'(("C-S-<left>" . sp-backward-slurp-sexp)
("C-S-<right>" . sp-backward-barf-sexp)
("C-M-t" . sp-transpose-sexp)
("C-S-k" . sp-kill-hybrid-sexp)
("C-c C-<right>" . sp-slurp-hybrid-sexp)
("C-(" . sp-rewrap-sexp)
("C-M-<backspace>" . sp-splice-sexp-killing-around)
("C-S-<backspace>" . nil))))
;; markdown
(defun sp--markdown-skip-asterisk (ms mb me)
(save-excursion
(goto-char mb)
(save-match-data (looking-at "^\\* "))))
(sp-with-modes 'markdown-mode
(sp-local-pair "*" "*"
:unless '(sp-point-after-word-p sp-point-at-bol-p)
:skip-match 'sp--markdown-skip-asterisk)
(sp-local-pair "**" "**")
(sp-local-pair "_" "_" :unless '(sp-point-after-word-p)))
;; haskell
(add-to-list 'sp-no-reindent-after-kill-modes 'haskell-mode)
;;; org-mode
(defun sp--org-skip-asterisk (ms mb me)
(or (and (= (line-beginning-position) mb)
(eq 32 (char-after (1+ mb))))
(and (= (1+ (line-beginning-position)) me)
(eq 32 (char-after me)))))
(defun sp--org-inside-LaTeX (id action context)
(org-inside-LaTeX-fragment-p))
(sp-with-modes 'org-mode
(sp-local-pair "*" "*"
:unless '(sp-point-after-word-p sp--org-inside-LaTeX sp-point-at-bol-p)
:skip-match 'sp--org-skip-asterisk)
(sp-local-pair "/" "/" :unless '(sp-point-after-word-p sp--org-inside-LaTeX))
(sp-local-pair "~" "~" :unless '(sp-point-after-word-p sp--org-inside-LaTeX))
(sp-local-pair "=" "=" :unless '(sp-point-after-word-p sp--org-inside-LaTeX))
(sp-local-pair "\\[" "\\]")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment