Created
June 25, 2017 03:58
-
-
Save oantolin/5751fbaa7b8ab4f9570893f2adfe1862 to your computer and use it in GitHub Desktop.
My smartparens configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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