diff --git a/conf-lisp/smartparens.el b/conf-lisp/smartparens.el index a8c8061..5034de9 100644 --- a/conf-lisp/smartparens.el +++ b/conf-lisp/smartparens.el @@ -30,10 +30,14 @@ Used when enabling smartparens-mode." (goto-char beg)))) (use-package smartparens - :config + :init (require 'smartparens-config) (require 'cl-lib) + ;; :custom-face + ;; (sp-show-pair-match-face ((t (:foreground "White")))) + + :config ;; enable sp in minibuffer as well ;; maybe, see: https://github.com/Fuco1/smartparens/issues/33: ;; (sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil) @@ -44,6 +48,9 @@ Used when enabling smartparens-mode." (add-something-to-mode-hooks '(rust emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'smartparens-mode) + (add-something-to-mode-hooks + '(emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'electric-pair-mode) + ;; also in some select prog modes ;; (add-something-to-mode-hooks ;; '(perl ruby c c++ sh makefile config-general yaml go) (smartparens-mode t)) @@ -82,57 +89,6 @@ respectively." ;;(add-hook 'smartparens-enabled-hook #'tvd-disable-par-and-pair) ;;(add-hook 'smartparens-enabled-hook #'turn-on-smartparens-strict-mode) - ;; auto wrapping w/o region - (define-key smartparens-mode-map (kbd "C-c (") 'wrap-with-parens) - (define-key smartparens-mode-map (kbd "C-c [") 'wrap-with-brackets) - (define-key smartparens-mode-map (kbd "C-c {") 'wrap-with-braces) - (define-key smartparens-mode-map (kbd "C-c '") 'wrap-with-single-quotes) - (define-key smartparens-mode-map (kbd "C-c \"") 'wrap-with-double-quotes) - (define-key smartparens-mode-map (kbd "C-c `") 'wrap-with-back-quotes) - - ;; modification - (define-key smartparens-mode-map (kbd "C-k") 'sp-kill-hybrid-sexp) - (define-key smartparens-mode-map (kbd "C-") 'sp-forward-slurp-sexp) - (define-key smartparens-mode-map (kbd "C-") 'sp-forward-barf-sexp) - - ;; movement - ;; Also Check: https://github.com/Fuco1/smartparens/wiki/Working-with-expressions - ;; (look for "quick summary for each navigation function") - ;; - ;; Jump after the next balanced expression. If inside one and - ;; there is no forward exp., jump after its closing pair. - (define-key smartparens-mode-map (kbd "C-M-") 'sp-forward-sexp) - ;; Jump before the previous balanced expression. If inside one - ;; and there is no previous exp., jump before its opening pair. - (define-key smartparens-mode-map (kbd "C-M-") 'sp-backward-sexp) - ;; Jump up one level from the current balanced expression. This - ;; means skipping all the enclosed expressions within this and - ;; then jumping after the closing pair. - (define-key smartparens-mode-map (kbd "C-M-") 'sp-up-sexp) - ;; Jump after the opening pair of next balanced expression. This - ;; effectively descends one level down in the "expression - ;; hierarchy". If there is no expression to descend to, jump - ;; after current expression's opening pair. This can be used to - ;; quickly navigate to the beginning of current balanced - ;; expression. - (define-key smartparens-mode-map (kbd "C-M-") 'sp-down-sexp) - ;; Jump to the beginning of following balanced expression. If - ;; there is no following expression on the current level, jump - ;; one level up backward, effectively doing sp-backward-up-sexp. - (define-key smartparens-mode-map (kbd "C-S-") 'sp-next-sexp) - ;; Jump to the end of the previous balanced expression. If there - ;; is no previous expression on the current level, jupm one level - ;; up forward, effectively doing sp-up-sexp. - (define-key smartparens-mode-map (kbd "C-S-") 'sp-previous-sexp) - - ;; comment the whole sexp - (define-key smartparens-mode-map (kbd ";") 'tvd-lisp-comment) - - ;; replace my global setting - ;; FIXME: fhceck/fix M! - (define-key smartparens-mode-map (kbd "M-") 'sp-forward-symbol) - (define-key smartparens-mode-map (kbd "M-") 'sp-backward-symbol) - (when (fboundp 'defhydra) (defhydra hydra-smartparens (:hint nil) " @@ -189,8 +145,59 @@ _k_: kill (C-k) _s_: split _{_: wrap with { } ("C-" sp-backward-barf-sexp) ("C-" sp-backward-slurp-sexp)) - (define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body) - )) + (define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body)) + + :bind (:map smartparens-mode-map + ;; auto wrapping w/o region + ( "C-c (" . 'wrap-with-parens) + ( "C-c [" . 'wrap-with-brackets) + ( "C-c {" . 'wrap-with-braces) + ( "C-c '" . 'wrap-with-single-quotes) + ( "C-c \"" . 'wrap-with-double-quotes) + ( "C-c `" . 'wrap-with-back-quotes) + + ;; modification + ("C-k" . 'sp-kill-hybrid-sexp) + ("C-" . 'sp-forward-slurp-sexp) + ("C-" . 'sp-forward-barf-sexp) + + ;; movement + ;; Also Check: https://github.com/Fuco1/smartparens/wiki/Working-with-expressions + ;; (look for "quick summary for each navigation function") + ;; + ;; Jump after the next balanced expression. If inside one and + ;; there is no forward exp., jump after its closing pair. + ("C-M-" . 'sp-forward-sexp) + ;; Jump before the previous balanced expression. If inside one + ;; and there is no previous exp., jump before its opening pair. + ("C-M-" . 'sp-backward-sexp) + ;; Jump up one level from the current balanced expression. This + ;; means skipping all the enclosed expressions within this and + ;; then jumping after the closing pair. + ("C-M-" . 'sp-up-sexp) + ;; Jump after the opening pair of next balanced expression. This + ;; effectively descends one level down in the "expression + ;; hierarchy". If there is no expression to descend to, jump + ;; after current expression's opening pair. This can be used to + ;; quickly navigate to the beginning of current balanced + ;; expression. + ("C-M-" . 'sp-down-sexp) + ;; Jump to the beginning of following balanced expression. If + ;; there is no following expression on the current level, jump + ;; one level up backward, effectively doing sp-backward-up-sexp. + ("C-S-" . 'sp-next-sexp) + ;; Jump to the end of the previous balanced expression. If there + ;; is no previous expression on the current level, jupm one level + ;; up forward, effectively doing sp-up-sexp. + ("C-S-" . 'sp-previous-sexp) + + ;; comment the whole sexp + (";" . 'tvd-lisp-comment) + + ;; replace my global setting + ;; FIXME: fhceck/fix M! + ("M-" . 'sp-forward-symbol) + ("M-" . 'sp-backward-symbol))) ;;; Parens config goes here as well diff --git a/init.el b/init.el index f52913c..d1b9c01 100644 --- a/init.el +++ b/init.el @@ -164,7 +164,7 @@ '(custom-safe-themes '("7f1d414afda803f3244c6fb4c2c64bea44dac040ed3731ec9d75275b9e831fe5" default)) '(package-selected-packages - '(tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move)) + '(howm tiny tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move)) '(safe-local-variable-values '((ruby-indent-level 4))) '(warning-suppress-types '((comp))))