From b5968b2016c42b9dabc8547ed4b21dfa299a0cec Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 1 Apr 2023 15:06:47 -0400 Subject: [PATCH] ENH search for hlint binary properly in flycheck --- etc/conf.org | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/etc/conf.org b/etc/conf.org index 0fbe384..eae0a79 100644 --- a/etc/conf.org +++ b/etc/conf.org @@ -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.