2017-08-28 15:33:56 +01:00
|
|
|
;;; parentheses.el --- Module file for managing parentheses packages.
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2017 Wojciech Kozlowski
|
|
|
|
;;
|
2018-02-04 17:18:18 +00:00
|
|
|
;; Author: Wojciech Kozlowski <wk@wojciechkozlowski.eu>
|
2017-08-28 15:33:56 +01:00
|
|
|
;; Created: 28 Aug 2017
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This module sets up configuration for packages that manage parentheses in
|
|
|
|
;; code and text.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
;;; Required packages:
|
|
|
|
|
2017-09-02 13:45:42 +01:00
|
|
|
(setq emodule/parentheses-packages
|
2017-08-28 15:33:56 +01:00
|
|
|
|
2017-09-02 08:16:56 +01:00
|
|
|
'(highlight-parentheses
|
|
|
|
rainbow-delimiters
|
2017-08-28 15:33:56 +01:00
|
|
|
smartparens)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Configuration:
|
|
|
|
|
2017-09-02 13:45:42 +01:00
|
|
|
(defun emodule/parentheses-init ()
|
2017-08-28 15:33:56 +01:00
|
|
|
|
|
|
|
;; --------------------------------------------------------------------------
|
2017-09-02 08:16:56 +01:00
|
|
|
;; Highlight parentheses - this package does not use faces for colours,
|
|
|
|
;; instead it uses the `hl-parens-colors' variable. This can be set in the
|
|
|
|
;; theme file, but the mode has to be reloaded whenever the theme changes.
|
2017-08-28 15:33:56 +01:00
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
|
2017-09-02 08:16:56 +01:00
|
|
|
(use-package highlight-parentheses
|
2017-08-28 15:33:56 +01:00
|
|
|
:defer t
|
|
|
|
:init
|
2017-09-02 08:16:56 +01:00
|
|
|
(add-hook 'prog-mode-hook 'highlight-parentheses-mode))
|
2017-08-28 15:33:56 +01:00
|
|
|
|
|
|
|
;; --------------------------------------------------------------------------
|
2017-09-02 08:16:56 +01:00
|
|
|
;; Rainbow delimiters - colours are set by theme.
|
2017-08-28 15:33:56 +01:00
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
|
2017-09-02 08:16:56 +01:00
|
|
|
(use-package rainbow-delimiters
|
2017-08-28 15:33:56 +01:00
|
|
|
:defer t
|
|
|
|
:init
|
2017-09-02 08:16:56 +01:00
|
|
|
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
|
|
|
|
|
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
;; Smartparens highlighting.
|
|
|
|
;; --------------------------------------------------------------------------
|
2017-08-28 15:33:56 +01:00
|
|
|
|
|
|
|
(use-package smartparens
|
2017-08-28 22:17:11 +01:00
|
|
|
:init
|
|
|
|
(smartparens-global-mode t)
|
|
|
|
(show-smartparens-global-mode t)
|
2017-08-28 15:33:56 +01:00
|
|
|
:config
|
|
|
|
(require 'smartparens-config)
|
|
|
|
|
|
|
|
;; Key-bindings -----------------------------------------------------------
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
|
|
|
|
|
2017-08-28 18:44:38 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "C-M-u") 'sp-backward-up-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-S-u") 'sp-up-sexp)
|
|
|
|
|
2017-08-28 15:33:56 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "C-M-d") 'sp-down-sexp)
|
2017-08-28 18:44:38 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "C-M-S-d") 'sp-backward-down-sexp)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-S-a") 'sp-beginning-of-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-S-e") 'sp-end-of-sexp)
|
2017-08-28 15:33:56 +01:00
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-t") 'sp-transpose-sexp)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-n") 'sp-next-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-p") 'sp-previous-sexp)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-<right>") 'sp-forward-slurp-sexp)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-<left>") 'sp-forward-barf-sexp)
|
|
|
|
|
2017-08-28 22:19:38 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "M-D") 'sp-splice-sexp)
|
2017-08-28 18:44:38 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "C-S-d") 'sp-splice-sexp-killing-forward)
|
2017-08-28 15:33:56 +01:00
|
|
|
(define-key smartparens-mode-map (kbd "C-M-<backspace>") 'sp-splice-sexp-killing-backward)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-around)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-]") 'sp-select-next-thing-exchange)
|
|
|
|
(define-key smartparens-mode-map (kbd "C-M-]") 'sp-select-next-thing)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "M-F") 'sp-forward-symbol)
|
|
|
|
(define-key smartparens-mode-map (kbd "M-B") 'sp-backward-symbol)
|
|
|
|
|
|
|
|
(define-key smartparens-mode-map (kbd "C-c f")
|
|
|
|
(lambda () (interactive) (sp-beginning-of-sexp 2)))
|
|
|
|
(define-key smartparens-mode-map (kbd "C-c b")
|
|
|
|
(lambda () (interactive) (sp-beginning-of-sexp -2)))
|
|
|
|
|
|
|
|
;; rst-mode
|
|
|
|
(sp-with-modes 'rst-mode
|
|
|
|
(sp-local-pair "`" nil :actions nil)
|
|
|
|
(sp-local-pair "``" "``"))
|
2017-09-02 08:16:56 +01:00
|
|
|
|
2017-08-28 15:33:56 +01:00
|
|
|
;; Smartparens custom settings --------------------------------------------
|
|
|
|
|
|
|
|
(setq-default
|
|
|
|
;; Jump to closing parenthesis when closing symbol is typed.
|
2017-08-28 22:19:38 +01:00
|
|
|
sp-autoskip-closing-pair t
|
2017-08-28 15:33:56 +01:00
|
|
|
;; Do not automatically reindent anything.
|
|
|
|
sp-navigate-reindent-after-up nil
|
|
|
|
sp-navigate-reindent-after-up-in-string nil
|
|
|
|
;; Do not highlight space between parentheses.
|
|
|
|
sp-highlight-pair-overlay nil))
|
|
|
|
|
|
|
|
)
|