Add new module for parentheses
This commit is contained in:
parent
dd52b1855a
commit
39311e0643
1
init.el
1
init.el
@ -107,6 +107,7 @@
|
|||||||
(init-packages/init '(editing
|
(init-packages/init '(editing
|
||||||
emacs
|
emacs
|
||||||
helm
|
helm
|
||||||
|
parentheses
|
||||||
version-control
|
version-control
|
||||||
workflow))
|
workflow))
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
(setq init-packages/editing-packages
|
(setq init-packages/editing-packages
|
||||||
|
|
||||||
'(rainbow-mode
|
'(rainbow-mode
|
||||||
rainbow-delimiters
|
|
||||||
highlight-parentheses
|
|
||||||
whole-line-or-region
|
whole-line-or-region
|
||||||
duplicate-thing
|
duplicate-thing
|
||||||
volatile-highlights
|
volatile-highlights
|
||||||
@ -43,6 +41,7 @@
|
|||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
;; Expand region - intelligent select.
|
;; Expand region - intelligent select.
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
|
|
||||||
(use-package expand-region
|
(use-package expand-region
|
||||||
:defer t
|
:defer t
|
||||||
:bind (("C-'" . er/expand-region)))
|
:bind (("C-'" . er/expand-region)))
|
||||||
@ -62,20 +61,6 @@
|
|||||||
(use-package volatile-highlights)
|
(use-package volatile-highlights)
|
||||||
(volatile-highlights-mode t)
|
(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.
|
;; Use UTF-8.
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
@ -89,7 +74,7 @@
|
|||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
|
|
||||||
;; Kill whole line when point at beginning of line.
|
;; 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.
|
;; Replace selected rather than inserting text at point.
|
||||||
(delete-selection-mode)
|
(delete-selection-mode)
|
||||||
@ -183,7 +168,7 @@
|
|||||||
'(python-mode slim-mode haml-mode)
|
'(python-mode slim-mode haml-mode)
|
||||||
"Modes for which auto-indenting is suppressed.")
|
"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
|
"Threshold (# chars) over which indentation does not
|
||||||
automatically occur.")
|
automatically occur.")
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
;; Helm settings ----------------------------------------------------------
|
;; Helm settings ----------------------------------------------------------
|
||||||
|
|
||||||
(setq
|
(setq-default
|
||||||
;; Open helm buffer inside current window, not occupy whole other window.
|
;; Open helm buffer inside current window, not occupy whole other window.
|
||||||
helm-split-window-in-side-p t
|
helm-split-window-in-side-p t
|
||||||
;; Move to end or beginning of list when reaching top or bottom of list.
|
;; Move to end or beginning of list when reaching top or bottom of list.
|
||||||
@ -114,7 +114,7 @@
|
|||||||
;; ------------------------------------------------------------------------
|
;; ------------------------------------------------------------------------
|
||||||
|
|
||||||
(projectile-global-mode)
|
(projectile-global-mode)
|
||||||
(setq projectile-completion-system 'helm)
|
(setq-default projectile-completion-system 'helm)
|
||||||
(helm-projectile-on)
|
(helm-projectile-on)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
113
modules/parentheses.el
Normal file
113
modules/parentheses.el
Normal 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)
|
||||||
|
|
||||||
|
)
|
Reference in New Issue
Block a user