tools/direnv: fix direnv+flycheck integration

Also fixes direnv+flycheck for nix users by consulting direnv before
looking for flycheck executables.
This commit is contained in:
Henrik Lissner 2019-07-09 16:11:36 +02:00
parent c3c282f0a4
commit ef8cd55234
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -13,5 +13,12 @@ buffer/window/frame switch, which is less expensive."
(add-hook 'focus-in-hook #'direnv--maybe-update-environment))) (add-hook 'focus-in-hook #'direnv--maybe-update-environment)))
(add-hook 'direnv-mode-hook #'+direnv|init) (add-hook 'direnv-mode-hook #'+direnv|init)
(defun +direnv*update (&rest _)
"Update direnv. Useful to advise functions that may run
environment-sensitive logic like `flycheck-default-executable-find'. This fixes
flycheck issues with direnv and on nix."
(direnv-update-environment default-directory))
(advice-add #'flycheck-default-executable-find :before #'+direnv*update)
(when (executable-find "direnv") (when (executable-find "direnv")
(direnv-mode +1))) (direnv-mode +1)))