feat(emacs-lisp): no doc warnings with flymake

This commit is contained in:
Jeetaditya Chatterjee 2023-08-05 23:14:43 +05:30
parent e47accb773
commit 2e67ad18e9
No known key found for this signature in database
GPG key ID: 4A1E5568BA34D124
2 changed files with 44 additions and 34 deletions

View file

@ -290,15 +290,25 @@ Essentially, this means in any elisp file that either:
This generally applies to your private config (`doom-user-dir') or Doom's source This generally applies to your private config (`doom-user-dir') or Doom's source
\(`doom-emacs-dir')." \(`doom-emacs-dir')."
:since "3.0.0" :since "3.0.0"
(unless (and (bound-and-true-p flycheck-mode) (unless (and (or (bound-and-true-p flycheck-mode)
(bound-and-true-p flymake-mode))
(not (+emacs-lisp--in-package-buffer-p))) (not (+emacs-lisp--in-package-buffer-p)))
(setq +emacs-lisp-non-package-mode nil)) (setq +emacs-lisp-non-package-mode nil))
(when (derived-mode-p 'emacs-lisp-mode) (when (derived-mode-p 'emacs-lisp-mode)
(add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t)) (add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t))
(if (not +emacs-lisp-non-package-mode) (if (not +emacs-lisp-non-package-mode)
(if (modulep! :checkers syntax +flymake)
;; flymake
(progn
(add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t))
;; flycheck
(when (get 'flycheck-disabled-checkers 'initial-value) (when (get 'flycheck-disabled-checkers 'initial-value)
(setq-local flycheck-disabled-checkers (get 'flycheck-disabled-checkers 'initial-value)) (setq-local flycheck-disabled-checkers (get 'flycheck-disabled-checkers 'initial-value))
(kill-local-variable 'flycheck-emacs-lisp-check-form)) (kill-local-variable 'flycheck-emacs-lisp-check-form)))
(if (modulep! :checkers syntax +flymake)
;; flymake
(remove-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc t)
;; flycheck
(with-memoization (get 'flycheck-disabled-checkers 'initial-value) (with-memoization (get 'flycheck-disabled-checkers 'initial-value)
flycheck-disabled-checkers) flycheck-disabled-checkers)
(setq-local flycheck-emacs-lisp-check-form (setq-local flycheck-emacs-lisp-check-form
@ -322,7 +332,7 @@ This generally applies to your private config (`doom-user-dir') or Doom's source
0 0 (error-message-string e))))) 0 0 (error-message-string e)))))
,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form)))) ,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form))))
flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc
flycheck-disabled-checkers)))) flycheck-disabled-checkers)))))
;; ;;

View file

@ -95,11 +95,11 @@ See `+emacs-lisp-non-package-mode' for details.")
;; Ensure straight sees modifications to installed packages ;; Ensure straight sees modifications to installed packages
#'+emacs-lisp-init-straight-maybe-h) #'+emacs-lisp-init-straight-maybe-h)
;; UX: Flycheck's two emacs-lisp checkers produce a *lot* of false positives ;; UX: Both Flycheck's and Flymake's two
;; in non-packages (like Emacs configs or elisp scripts), so I disable ;; emacs-lisp checkers produce a *lot* of false positives in non-packages
;; `emacs-lisp-checkdoc' and set `byte-compile-warnings' to a subset of the ;; (like Emacs configs or elisp scripts), so I disable `checkdoc' (`emacs-lisp-checkdoc', `elisp-flymake-checkdoc')
;; original in the flycheck instance (see `+emacs-lisp-linter-warnings'). ;; and set `byte-compile-warnings' to a subset that makes more sense (see `+emacs-lisp-linter-warnings')
(add-hook 'flycheck-mode-hook #'+emacs-lisp-non-package-mode) (add-hook! '(flycheck-mode-hook flymake-mode-hook) #'+emacs-lisp-non-package-mode)
;; Enhance elisp syntax highlighting, by highlighting Doom-specific ;; Enhance elisp syntax highlighting, by highlighting Doom-specific
;; constructs, defined symbols, and truncating :pin's in `package!' calls. ;; constructs, defined symbols, and truncating :pin's in `package!' calls.