Refactor tools/direnv
This commit is contained in:
parent
5a8fb81739
commit
7afa8a7e90
1 changed files with 11 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; tools/direnv/config.el -*- lexical-binding: t; -*-
|
;;; tools/direnv/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(defvar +direnv--keywords
|
(defvar +direnv-keywords
|
||||||
'("direnv_layout_dir" "PATH_add" "path_add" "log_status" "log_error" "has"
|
'("direnv_layout_dir" "PATH_add" "path_add" "log_status" "log_error" "has"
|
||||||
"join_args" "expand_path" "dotenv" "user_rel_path" "find_up" "source_env"
|
"join_args" "expand_path" "dotenv" "user_rel_path" "find_up" "source_env"
|
||||||
"watch_file" "source_up" "direnv_load" "MANPATH_add" "load_prefix" "layout"
|
"watch_file" "source_up" "direnv_load" "MANPATH_add" "load_prefix" "layout"
|
||||||
|
@ -12,22 +12,18 @@
|
||||||
;;; Packages
|
;;; Packages
|
||||||
|
|
||||||
(use-package! direnv
|
(use-package! direnv
|
||||||
:after-call after-find-file dired-initial-position-hook
|
:hook (before-hack-local-variables . direnv--maybe-update-environment)
|
||||||
|
:hook (flycheck-before-syntax-check . direnv--maybe-update-environment)
|
||||||
|
:hook (direnv-envrc-mode . +direnv-envrc-fontify-keywords-h)
|
||||||
:config
|
:config
|
||||||
;; Fontify special .envrc keywords; it's a good indication of whether or not
|
(add-to-list 'direnv-non-file-modes 'vterm-mode)
|
||||||
;; we've typed them correctly.
|
|
||||||
(add-hook! 'direnv-envrc-mode-hook
|
|
||||||
(defun +direnv-envrc-fontify-keywords-h ()
|
|
||||||
(font-lock-add-keywords
|
|
||||||
nil `((,(regexp-opt +direnv--keywords 'symbols)
|
|
||||||
(0 font-lock-keyword-face))))))
|
|
||||||
|
|
||||||
(defadvice! +direnv-update-a (&rest _)
|
(defun +direnv-envrc-fontify-keywords-h ()
|
||||||
"Update direnv. Useful to advise functions that may run
|
"Fontify special .envrc keywords; it's a good indication of whether or not
|
||||||
environment-sensitive logic like `flycheck-default-executable-find'. This fixes
|
we've typed them correctly."
|
||||||
flycheck issues with direnv and on nix."
|
(font-lock-add-keywords
|
||||||
:before #'flycheck-default-executable-find
|
nil `((,(regexp-opt +direnv-keywords 'symbols)
|
||||||
(direnv--maybe-update-environment))
|
(0 font-lock-keyword-face)))))
|
||||||
|
|
||||||
(defadvice! +direnv--fail-gracefully-a (&rest _)
|
(defadvice! +direnv--fail-gracefully-a (&rest _)
|
||||||
"Don't try to use direnv if the executable isn't present."
|
"Don't try to use direnv if the executable isn't present."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue