ENH search for hlint binary properly in flycheck

This commit is contained in:
Nathan Dwarshuis 2023-04-01 15:06:47 -04:00
parent 773e23b81f
commit b5968b2016
1 changed files with 19 additions and 7 deletions

View File

@ -737,6 +737,24 @@ Since flyspell mode is enabled in so many buffers, use a short modeline alias.
*** syntax checking
Flycheck will highlight and explain syntax errors in code and formatting. See each language below for external tools that need to be installed to make flycheck work to the fullest.
#+BEGIN_SRC emacs-lisp
(defun nd/flycheck-executable-find (exe)
"Find EXE like `flycheck-default-executable-find' with exceptions.
These exceptions mostly apply to finding binaries in environments
where the PATH is not obvious"
(cond
;; hlint should be installed in the compiler-tools directory for each
;; GHC version; since flycheck has no idea what this means, intervene
;; manually
((equal exe "hlint")
(or (->> "stack path --compiler-tools-bin 2> /dev/null"
(shell-command-to-string)
(s-trim)
(list)
(locate-file exe))
(flycheck-default-executable-find exe)))
(t (flycheck-default-executable-find exe))))
(use-package flycheck
:straight t
:hook
@ -747,6 +765,7 @@ Flycheck will highlight and explain syntax errors in code and formatting. See ea
mode-enabled)
flycheck-idle-change-delay 2
flycheck-error-list-minimum-level 'warning
flycheck-executable-find #'nd/flycheck-executable-find
flycheck-navigation-minimum-level 'warning)
(delight 'flycheck-mode "ϕ" "flycheck"))
#+END_SRC
@ -1113,13 +1132,6 @@ I have also found this to be much simpler and conflicting with other packages su
;; unnecessary to see on the modeline
(delight 'subword-mode nil "subword"))
#+END_SRC
**** hlint
This is an additional syntax checker and requires the =hlint= binary.
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'haskell
(flycheck-add-next-checker 'haskell-stack-ghc '(t . haskell-hlint)))
#+END_SRC
**** helper functions
Other helper functions that make haskell even more fun.