Add new module for parentheses

This commit is contained in:
Wojciech Kozlowski 2017-08-28 15:33:56 +01:00
parent dd52b1855a
commit 39311e0643
4 changed files with 119 additions and 20 deletions

View File

@ -107,6 +107,7 @@
(init-packages/init '(editing
emacs
helm
parentheses
version-control
workflow))

View File

@ -18,8 +18,6 @@
(setq init-packages/editing-packages
'(rainbow-mode
rainbow-delimiters
highlight-parentheses
whole-line-or-region
duplicate-thing
volatile-highlights
@ -43,6 +41,7 @@
;; --------------------------------------------------------------------------
;; Expand region - intelligent select.
;; --------------------------------------------------------------------------
(use-package expand-region
:defer t
:bind (("C-'" . er/expand-region)))
@ -62,20 +61,6 @@
(use-package volatile-highlights)
(volatile-highlights-mode t)
;; --------------------------------------------------------------------------
;; Parentheses highlighting.
;; --------------------------------------------------------------------------
(use-package rainbow-delimiters
:defer t
:init
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(use-package highlight-parentheses
:defer t
:init
(add-hook 'prog-mode-hook 'show-paren-mode)
(add-hook 'prog-mode-hook 'highlight-parentheses-mode))
;; --------------------------------------------------------------------------
;; Use UTF-8.
;; --------------------------------------------------------------------------
@ -89,7 +74,7 @@
;; --------------------------------------------------------------------------
;; Kill whole line when point at beginning of line.
(setq kill-whole-line t)
(setq-default kill-whole-line t)
;; Replace selected rather than inserting text at point.
(delete-selection-mode)
@ -183,7 +168,7 @@
'(python-mode slim-mode haml-mode)
"Modes for which auto-indenting is suppressed.")
(defvar yank-advised-indent-threshold 1000
(defvar yank-advised-indent-threshold 10000
"Threshold (# chars) over which indentation does not
automatically occur.")

View File

@ -49,7 +49,7 @@
;; Helm settings ----------------------------------------------------------
(setq
(setq-default
;; Open helm buffer inside current window, not occupy whole other window.
helm-split-window-in-side-p t
;; Move to end or beginning of list when reaching top or bottom of list.
@ -114,7 +114,7 @@
;; ------------------------------------------------------------------------
(projectile-global-mode)
(setq projectile-completion-system 'helm)
(setq-default projectile-completion-system 'helm)
(helm-projectile-on)
)

113
modules/parentheses.el Normal file
View File

@ -0,0 +1,113 @@
;;; parentheses.el --- Module file for managing parentheses packages.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
;; Author: Wojciech Kozlowski <wojciech.kozlowski@vivaldi.net>
;; 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:
(setq init-packages/parentheses-packages
'(rainbow-delimiters
highlight-parentheses
smartparens)
)
;; Configuration:
(defun init-packages/init-parentheses ()
;; --------------------------------------------------------------------------
;; Rainbow delimiters - colours are set by theme.
;; --------------------------------------------------------------------------
(use-package rainbow-delimiters
:defer t
:init
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
;; --------------------------------------------------------------------------
;; 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.
;; --------------------------------------------------------------------------
(use-package highlight-parentheses
:defer t
:init
(add-hook 'prog-mode-hook 'highlight-parentheses-mode))
(use-package smartparens
: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)
(define-key smartparens-mode-map (kbd "C-M-d") 'sp-down-sexp)
(define-key smartparens-mode-map (kbd "C-M-a") 'sp-backward-down-sexp)
(define-key smartparens-mode-map (kbd "C-S-d") 'sp-beginning-of-sexp)
(define-key smartparens-mode-map (kbd "C-S-a") 'sp-end-of-sexp)
(define-key smartparens-mode-map (kbd "C-M-e") 'sp-up-sexp)
(define-key smartparens-mode-map (kbd "C-M-u") 'sp-backward-up-sexp)
(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)
(define-key smartparens-mode-map (kbd "M-D") 'sp-splice-sexp)
(define-key smartparens-mode-map (kbd "C-M-D") 'sp-splice-sexp-killing-forward)
(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 "``" "``"))
;; Smartparens custom settings --------------------------------------------
(setq-default
;; Jump to closing parenthesis when closing symbol is typed.
sp-autoskip-closing-pair 'always
;; 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))
(smartparens-global-mode t)
(show-smartparens-global-mode t)
)