2015-08-11 18:00:16 +00:00
|
|
|
;;; packages.el --- Spell Checking Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-08-11 18:00:16 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq spell-checking-packages
|
|
|
|
'(
|
2015-10-20 13:05:24 +00:00
|
|
|
auto-dictionary
|
2015-08-11 18:00:16 +00:00
|
|
|
flyspell
|
2016-05-06 14:50:56 +00:00
|
|
|
flyspell-correct
|
2017-07-02 13:48:06 +00:00
|
|
|
(flyspell-correct-ivy :toggle (configuration-layer/layer-used-p 'ivy))
|
|
|
|
(flyspell-correct-helm :toggle (configuration-layer/layer-used-p 'helm))
|
|
|
|
(flyspell-correct-popup :toggle (and (not (configuration-layer/layer-used-p 'ivy))
|
|
|
|
(not (configuration-layer/layer-used-p 'helm))))
|
2018-11-20 19:55:37 +00:00
|
|
|
(flyspell-popup :toggle enable-flyspell-auto-completion)
|
|
|
|
))
|
2015-08-11 18:00:16 +00:00
|
|
|
|
2015-10-20 13:05:24 +00:00
|
|
|
(defun spell-checking/init-auto-dictionary ()
|
|
|
|
(use-package auto-dictionary
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-11-01 16:27:44 +00:00
|
|
|
:if spell-checking-enable-auto-dictionary
|
2015-10-20 13:05:24 +00:00
|
|
|
:init
|
2015-11-02 11:50:35 +00:00
|
|
|
(progn
|
|
|
|
(add-hook 'flyspell-mode-hook 'auto-dictionary-mode)
|
|
|
|
;; Select the buffer local dictionary if it was set, otherwise
|
|
|
|
;; auto-dictionary will replace it with a guessed one at each activation.
|
|
|
|
;; https://github.com/nschum/auto-dictionary-mode/issues/5
|
2015-11-03 04:02:01 +00:00
|
|
|
(defun spacemacs//adict-set-local-dictionary ()
|
|
|
|
"Set the local dictionary if not nil."
|
|
|
|
(when (and (fboundp 'adict-change-dictionary)
|
|
|
|
ispell-local-dictionary)
|
|
|
|
(adict-change-dictionary ispell-local-dictionary)))
|
2015-11-02 11:50:35 +00:00
|
|
|
(add-hook 'auto-dictionary-mode-hook
|
2015-11-03 04:02:01 +00:00
|
|
|
'spacemacs//adict-set-local-dictionary 'append))))
|
2015-10-20 13:05:24 +00:00
|
|
|
|
2015-08-11 18:00:16 +00:00
|
|
|
(defun spell-checking/init-flyspell ()
|
|
|
|
(use-package flyspell
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-10-20 13:05:24 +00:00
|
|
|
:commands (spell-checking/change-dictionary)
|
2015-08-11 18:00:16 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-08-26 21:34:34 +00:00
|
|
|
(spacemacs|define-transient-state spell-checking
|
|
|
|
:title "Spell Checking Transient State"
|
|
|
|
:doc "
|
2019-06-12 15:41:09 +00:00
|
|
|
Spell Commands^^ Add To Dictionary^^ Other
|
|
|
|
--------------^^---------- -----------------^^------------- -----^^---------------------------
|
|
|
|
[_b_] check whole buffer [_B_] add word to dict (buffer) [_t_] toggle spell check
|
|
|
|
[_d_] change dictionary [_G_] add word to dict (global) [_q_] exit
|
|
|
|
[_n_] next spell error [_S_] add word to dict (session) [_Q_] exit and disable spell check
|
|
|
|
[_c_] correct before point
|
|
|
|
[_s_] correct at point"
|
2018-08-26 21:34:34 +00:00
|
|
|
:on-enter (flyspell-mode)
|
|
|
|
:bindings
|
2018-09-13 20:13:33 +00:00
|
|
|
("B" spacemacs/add-word-to-dict-buffer)
|
2018-08-26 21:34:34 +00:00
|
|
|
("b" flyspell-buffer)
|
|
|
|
("d" spell-checking/change-dictionary)
|
2018-09-13 20:13:33 +00:00
|
|
|
("G" spacemacs/add-word-to-dict-global)
|
2018-08-26 21:34:34 +00:00
|
|
|
("n" flyspell-goto-next-error)
|
2018-12-10 17:32:43 +00:00
|
|
|
("c" flyspell-correct-wrapper)
|
2018-08-26 21:34:34 +00:00
|
|
|
("Q" flyspell-mode :exit t)
|
|
|
|
("q" nil :exit t)
|
2018-09-13 20:13:33 +00:00
|
|
|
("S" spacemacs/add-word-to-dict-session)
|
2019-06-12 15:41:09 +00:00
|
|
|
("s" flyspell-correct-at-point)
|
2018-08-26 21:34:34 +00:00
|
|
|
("t" spacemacs/toggle-spelling-checking))
|
|
|
|
|
|
|
|
(spacemacs/set-leader-keys "S." 'spacemacs/spell-checking-transient-state/body)
|
2015-12-09 11:29:19 +00:00
|
|
|
(spell-checking/add-flyspell-hook 'text-mode-hook)
|
2015-12-17 19:38:21 +00:00
|
|
|
(when spell-checking-enable-by-default
|
|
|
|
(add-hook 'prog-mode-hook 'flyspell-prog-mode))
|
2015-10-15 11:10:06 +00:00
|
|
|
|
2015-08-11 18:00:16 +00:00
|
|
|
(spacemacs|add-toggle spelling-checking
|
|
|
|
:status flyspell-mode
|
2015-11-02 11:50:35 +00:00
|
|
|
:on (if (derived-mode-p 'prog-mode)
|
|
|
|
(flyspell-prog-mode)
|
|
|
|
(flyspell-mode))
|
|
|
|
:off (progn
|
|
|
|
(flyspell-mode-off)
|
|
|
|
;; Also disable auto-dictionary when disabling spell-checking.
|
|
|
|
(when (fboundp 'auto-dictionary-mode) (auto-dictionary-mode -1)))
|
|
|
|
:documentation "Enable automatic spell checking."
|
2015-09-08 01:16:15 +00:00
|
|
|
:evil-leader "tS")
|
2015-10-15 11:10:06 +00:00
|
|
|
|
2016-04-03 04:12:28 +00:00
|
|
|
(spacemacs/declare-prefix "S" "spelling")
|
2018-09-13 20:13:33 +00:00
|
|
|
(spacemacs/declare-prefix "Sa" "add word to dict")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2018-09-13 20:13:33 +00:00
|
|
|
"Sab" 'spacemacs/add-word-to-dict-buffer
|
|
|
|
"Sag" 'spacemacs/add-word-to-dict-global
|
|
|
|
"Sas" 'spacemacs/add-word-to-dict-session
|
2015-11-02 21:18:11 +00:00
|
|
|
"Sb" 'flyspell-buffer
|
2015-10-20 13:05:24 +00:00
|
|
|
"Sd" 'spell-checking/change-dictionary
|
2019-06-12 15:41:09 +00:00
|
|
|
"Sn" 'flyspell-goto-next-error
|
|
|
|
"Ss" 'flyspell-correct-at-point))
|
2016-04-03 04:12:28 +00:00
|
|
|
:config (spacemacs|diminish flyspell-mode " Ⓢ" " S")))
|
2015-08-11 18:00:16 +00:00
|
|
|
|
2016-05-06 14:50:56 +00:00
|
|
|
(defun spell-checking/init-flyspell-correct ()
|
|
|
|
(use-package flyspell-correct
|
2018-10-05 06:35:35 +00:00
|
|
|
:commands (flyspell-correct-at-point
|
|
|
|
flyspell-correct-wrapper)
|
2016-05-06 14:50:56 +00:00
|
|
|
:init
|
2018-10-05 06:35:35 +00:00
|
|
|
(spacemacs/set-leader-keys "Sc" #'flyspell-correct-wrapper)))
|
2016-06-06 08:41:17 +00:00
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-ivy ()
|
2016-12-22 13:29:17 +00:00
|
|
|
(use-package flyspell-correct-ivy
|
|
|
|
:commands (flyspell-correct-ivy)
|
|
|
|
:init
|
|
|
|
(setq flyspell-correct-interface #'flyspell-correct-ivy)))
|
2016-06-06 08:41:17 +00:00
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-helm ()
|
2016-12-09 03:29:52 +00:00
|
|
|
(use-package flyspell-correct-helm
|
2016-12-22 13:29:17 +00:00
|
|
|
:commands (flyspell-correct-helm)
|
|
|
|
:init
|
|
|
|
(setq flyspell-correct-interface #'flyspell-correct-helm)))
|
2016-06-06 08:41:17 +00:00
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-correct-popup ()
|
2016-12-22 13:29:17 +00:00
|
|
|
(use-package flyspell-correct-popup
|
|
|
|
:commands (flyspell-correct-popup)
|
|
|
|
:init
|
|
|
|
(setq flyspell-correct-interface #'flyspell-correct-popup)))
|
2016-06-02 02:52:05 +00:00
|
|
|
|
|
|
|
(defun spell-checking/init-flyspell-popup ()
|
|
|
|
(use-package flyspell-popup
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-06-02 02:52:05 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-06-02 03:00:02 +00:00
|
|
|
(setq flyspell-popup-correct-delay 0.8)
|
2016-06-02 02:52:05 +00:00
|
|
|
(add-hook 'flyspell-mode-hook 'flyspell-popup-auto-correct-mode))))
|