feature/{syntax-checker,spellcheck} -> tools/fly{check,spell}
This commit is contained in:
parent
88f50bbdec
commit
69ed1a4a99
46 changed files with 147 additions and 110 deletions
44
modules/tools/flycheck/autoload.el
Normal file
44
modules/tools/flycheck/autoload.el
Normal file
|
@ -0,0 +1,44 @@
|
|||
;;; tools/flycheck/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +flycheck-show-popup (errors)
|
||||
"TODO"
|
||||
(if (and EMACS26+
|
||||
(featurep! +childframe)
|
||||
(display-graphic-p))
|
||||
(flycheck-posframe-show-posframe errors)
|
||||
(flycheck-popup-tip-show-popup errors)))
|
||||
|
||||
(defun +flycheck-cleanup-popup ()
|
||||
"TODO"
|
||||
(when (display-graphic-p)
|
||||
(flycheck-popup-tip-delete-popup)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode +flycheck-popup-mode
|
||||
"TODO"
|
||||
:lighter nil
|
||||
:group 'doom
|
||||
(require 'flycheck-popup-tip)
|
||||
(let ((hooks '(post-command-hook focus-out-hook)))
|
||||
(cond
|
||||
;; Use our display function and remember the old one but only if we haven't
|
||||
;; yet configured it, to avoid activating twice.
|
||||
((and +flycheck-popup-mode
|
||||
(not (eq flycheck-display-errors-function
|
||||
#'+flycheck-show-popup)))
|
||||
(setq flycheck-popup-tip-old-display-function
|
||||
flycheck-display-errors-function
|
||||
flycheck-display-errors-function
|
||||
#'+flycheck-show-popup)
|
||||
(dolist (hook hooks)
|
||||
(add-hook hook #'+flycheck-cleanup-popup nil t)))
|
||||
;; Reset the display function and remove ourselves from all hooks but only
|
||||
;; if the mode is still active.
|
||||
((and (not +flycheck-popup-mode)
|
||||
(eq flycheck-display-errors-function
|
||||
#'+flycheck-show-popup))
|
||||
(setq flycheck-display-errors-function
|
||||
flycheck-popup-tip-old-display-function
|
||||
flycheck-popup-tip-old-display-function nil)
|
||||
(dolist (hook hooks)
|
||||
(remove-hook hook '+flycheck-cleanup-popup t))))))
|
45
modules/tools/flycheck/config.el
Normal file
45
modules/tools/flycheck/config.el
Normal file
|
@ -0,0 +1,45 @@
|
|||
;;; tools/flycheck/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +flycheck-on-escape t
|
||||
"If non-nil, flycheck will recheck the current buffer when pressing ESC/C-g.")
|
||||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
|
||||
(def-package! flycheck
|
||||
:commands (flycheck-list-errors flycheck-buffer)
|
||||
:after-call (doom-enter-buffer-hook after-find-file)
|
||||
:config
|
||||
;; Emacs feels snappier without checks on newline
|
||||
(setq flycheck-check-syntax-automatically (delq 'new-line flycheck-check-syntax-automatically))
|
||||
|
||||
(defun +flycheck|buffer ()
|
||||
"Flycheck buffer on ESC in normal mode."
|
||||
(when (and flycheck-mode +flycheck-on-escape)
|
||||
(ignore-errors (flycheck-buffer))
|
||||
nil))
|
||||
(add-hook 'doom-escape-hook #'+flycheck|buffer t)
|
||||
|
||||
(after! evil
|
||||
(setq-hook! 'evil-insert-state-entry-hook
|
||||
flycheck-idle-change-delay 1.75)
|
||||
(setq-hook! 'evil-insert-state-exit-hook
|
||||
flycheck-idle-change-delay (default-value 'flycheck-idle-change-delay)))
|
||||
|
||||
(global-flycheck-mode +1))
|
||||
|
||||
|
||||
(def-package! flycheck-popup-tip
|
||||
:commands (flycheck-popup-tip-show-popup flycheck-popup-tip-delete-popup)
|
||||
:init (add-hook 'flycheck-mode-hook #'+flycheck-popup-mode)
|
||||
:config (setq flycheck-popup-tip-error-prefix "✕ "))
|
||||
|
||||
|
||||
(def-package! flycheck-posframe
|
||||
:when (and EMACS26+ (featurep! +childframe))
|
||||
:commands flycheck-posframe-show-posframe
|
||||
:config
|
||||
(setq flycheck-posframe-warning-prefix "⚠ "
|
||||
flycheck-posframe-info-prefix "··· "
|
||||
flycheck-posframe-error-prefix "✕ "))
|
7
modules/tools/flycheck/packages.el
Normal file
7
modules/tools/flycheck/packages.el
Normal file
|
@ -0,0 +1,7 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/flycheck/packages.el
|
||||
|
||||
(package! flycheck)
|
||||
(package! flycheck-popup-tip)
|
||||
(when (and EMACS26+ (featurep! +childframe))
|
||||
(package! flycheck-posframe))
|
69
modules/tools/flyspell/config.el
Normal file
69
modules/tools/flyspell/config.el
Normal file
|
@ -0,0 +1,69 @@
|
|||
;;; tools/flyspell/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar-local +flyspell-immediately t
|
||||
"If non-nil, spellcheck the current buffer upon starting `flyspell-mode'.
|
||||
|
||||
Since spellchecking can be slow in some buffers, this can be disabled with:
|
||||
|
||||
(setq-hook! 'TeX-mode-hook +flyspell-immediately nil)")
|
||||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
|
||||
(after! ispell
|
||||
(setq-default ispell-dictionary "english")
|
||||
|
||||
(cond ((executable-find "aspell")
|
||||
(setq ispell-program-name "aspell"
|
||||
ispell-extra-args '("--sug-mode=ultra" "--run-together"))
|
||||
|
||||
(setq-hook! 'text-mode-hook
|
||||
ispell-extra-args (remove "--run-together" ispell-extra-args)))
|
||||
|
||||
((executable-find "hunspell")
|
||||
(setq ispell-program-name "hunspell"
|
||||
;; Don't use `ispell-cmd-args', it isn't respected with hunspell.
|
||||
;; Hack ispell-local-dictionary-alist instead.
|
||||
ispell-dictionary-alist
|
||||
`((,ispell-local-dictionary
|
||||
"[[:alpha:]]"
|
||||
"[^[:alpha:]]"
|
||||
"[']"
|
||||
nil
|
||||
("-d" ,ispell-local-dictionary)
|
||||
nil
|
||||
utf-8)))))
|
||||
|
||||
(add-to-list 'ispell-extra-args "--dont-tex-check-comments")
|
||||
|
||||
(defun +flyspell*setup-ispell-extra-args (orig-fun &rest args)
|
||||
(let ((ispell-extra-args (remove "--run-together" ispell-extra-args)))
|
||||
(ispell-kill-ispell t)
|
||||
(apply orig-fun args)
|
||||
(ispell-kill-ispell t)))
|
||||
(advice-add #'ispell-word :around #'+flyspell*setup-ispell-extra-args)
|
||||
(advice-add #'flyspell-auto-correct-word :around #'+flyspell*setup-ispell-extra-args))
|
||||
|
||||
|
||||
;; `flyspell' (built-in)
|
||||
(setq flyspell-issue-welcome-flag nil)
|
||||
|
||||
(defun +flyspell|immediately ()
|
||||
"Spellcheck the buffer when `flyspell-mode' is enabled."
|
||||
(when (and flyspell-mode +flyspell-immediately)
|
||||
(flyspell-buffer)))
|
||||
(add-hook 'flyspell-mode-hook #'+flyspell|immediately)
|
||||
|
||||
|
||||
(def-package! flyspell-correct
|
||||
:commands (flyspell-correct-word-generic
|
||||
flyspell-correct-previous-word-generic)
|
||||
:config
|
||||
(cond ((featurep! :completion helm)
|
||||
(require 'flyspell-correct-helm))
|
||||
((featurep! :completion ivy)
|
||||
(require 'flyspell-correct-ivy))
|
||||
((require 'flyspell-correct-popup)
|
||||
(setq flyspell-popup-correct-delay 0.8)
|
||||
(define-key popup-menu-keymap [escape] #'keyboard-quit))))
|
9
modules/tools/flyspell/packages.el
Normal file
9
modules/tools/flyspell/packages.el
Normal file
|
@ -0,0 +1,9 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/flyspell/packages.el
|
||||
|
||||
(package! flyspell-correct)
|
||||
(cond ((featurep! :completion ivy)
|
||||
(package! flyspell-correct-ivy))
|
||||
((featurep! :completion helm)
|
||||
(package! flyspell-correct-helm))
|
||||
((package! flyspell-correct-popup)))
|
Loading…
Add table
Add a link
Reference in a new issue