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,39 +290,49 @@ Essentially, this means in any elisp file that either:
This generally applies to your private config (`doom-user-dir') or Doom's source
\(`doom-emacs-dir')."
:since "3.0.0"
(unless (and (bound-and-true-p flycheck-mode)
(not (+emacs-lisp--in-package-buffer-p)))
(unless (and (or (bound-and-true-p flycheck-mode)
(bound-and-true-p flymake-mode))
(not (+emacs-lisp--in-package-buffer-p)))
(setq +emacs-lisp-non-package-mode nil))
(when (derived-mode-p 'emacs-lisp-mode)
(add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t))
(if (not +emacs-lisp-non-package-mode)
(when (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))
(with-memoization (get 'flycheck-disabled-checkers 'initial-value)
flycheck-disabled-checkers)
(setq-local flycheck-emacs-lisp-check-form
(prin1-to-string
`(progn
(setq doom-modules ',doom-modules
doom-disabled-packages ',doom-disabled-packages
byte-compile-warnings ',+emacs-lisp-linter-warnings)
(condition-case e
(progn
(require 'doom)
(require 'doom-cli)
(require 'doom-start))
(error
(princ
(format "%s:%d:%d:Error:Failed to load Doom: %s\n"
(or ,(ignore-errors
(file-name-nondirectory
(buffer-file-name (buffer-base-buffer))))
(car command-line-args-left))
0 0 (error-message-string e)))))
,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form))))
flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc
flycheck-disabled-checkers))))
(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)
(setq-local flycheck-disabled-checkers (get 'flycheck-disabled-checkers 'initial-value))
(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)
flycheck-disabled-checkers)
(setq-local flycheck-emacs-lisp-check-form
(prin1-to-string
`(progn
(setq doom-modules ',doom-modules
doom-disabled-packages ',doom-disabled-packages
byte-compile-warnings ',+emacs-lisp-linter-warnings)
(condition-case e
(progn
(require 'doom)
(require 'doom-cli)
(require 'doom-start))
(error
(princ
(format "%s:%d:%d:Error:Failed to load Doom: %s\n"
(or ,(ignore-errors
(file-name-nondirectory
(buffer-file-name (buffer-base-buffer))))
(car command-line-args-left))
0 0 (error-message-string e)))))
,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form))))
flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc
flycheck-disabled-checkers)))))
;;

View file

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