feat!(cli): load project .doomrc instead of ci.el

BREAKING CHANGE: Before, 'doom ci' would load
$GIT_WORKING_TREE/.github/ci.el, to give users/projects an opportunity
to provide project-local configuration for bin/doom (mainly for CI/CD).
Now, this ci.el file is no longer loaded and instead, *all* bin/doom
sessions will walk up the file tree and load the first .doomrc it finds.

This gives bin/doom users a more general place configure all of its
commands, and not just 'doom ci' commands.

Extras:
- Adds .doomrc to auto-mode-alist (so that it starts in
  emacs-lisp-mode).
This commit is contained in:
Henrik Lissner 2022-08-07 18:54:48 +02:00
parent 422baedad7
commit 9b8ed397e8
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
4 changed files with 18 additions and 20 deletions

View file

@ -1,6 +1,7 @@
;;; ci.el -*- lexical-binding: t; no-byte-compile: t; -*- ;;; .doomrc --- doom runtime config -*- mode: emacs-lisp; lexical-binding: t; -*-
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(require 'doom) ; be silent, byte-compiler
(after! doom-cli-ci (after! doom-cli-ci
;;; Commit linter types ;;; Commit linter types
@ -50,4 +51,4 @@
:match "\\.org$" :match "\\.org$"
:map #'file-name-base))) :map #'file-name-base)))
;;; ci.el ends here ;;; .doomrc ends here

View file

@ -198,8 +198,8 @@ SEE ALSO:
silently fail on missing files, but --strict-load won't. silently fail on missing files, but --strict-load won't.
Warning: files loaded this way load too late to define new commands. To Warning: files loaded this way load too late to define new commands. To
define commands, do so from `$DOOMDIR'/cli.el or `$DOOMDIR'/init.el define commands, do so from `$DOOMDIR'/cli.el, `$DOOMDIR'/init.el, or a
instead." .doomrc file in the current project tree."
(when color? (when color?
(setq doom-print-backend (if (eq color? :yes) 'ansi))) (setq doom-print-backend (if (eq color? :yes) 'ansi)))
(when pager (when pager
@ -299,7 +299,17 @@ SEE ALSO:
(load! cli-file path t))))) (load! cli-file path t)))))
(doom-log "Loading $DOOMDIR/cli.el") (doom-log "Loading $DOOMDIR/cli.el")
(load! cli-file doom-private-dir t)))) (load! cli-file doom-private-dir t))
;; Allow per-project Doom settings in .doom files.
(let (doomrc)
(cond
((setq doomrc (getenv "DOOMRC"))
(load! doomrc))
((setq doomrc (locate-dominating-file default-directory ".doomrc"))
(load! ".doomrc" doomrc)))
(when doomrc
(print! "Loaded doomrc: %s" doomrc)))))
;; ;;

View file

@ -247,20 +247,6 @@ Note: warnings are not considered failures.")
;;; Commands ;;; Commands
;;; doom ci ;;; doom ci
(defcli! (:before ci) (&args _)
(when-let*
((repo-root
(if-let* ((result (sh! "git" "rev-parse" "--show-toplevel"))
((zerop (car result))))
(cdr result)
default-directory))
(local-config
(car (or (doom-glob repo-root "ci.el")
(doom-glob doom-private-dir "ci.el")))))
(defgroup! :prefix '(doom ci)
(load local-config nil t t))
(print! (item "Loaded %S") local-config)))
(defcli! ci (&args _) (defcli! ci (&args _)
"Commands that automate development processes." "Commands that automate development processes."
:partial t) :partial t)

View file

@ -143,7 +143,8 @@ If RETURN-P, return the message as a string instead of displaying it."
(float-time (time-subtract (current-time) before-init-time)))))) (float-time (time-subtract (current-time) before-init-time))))))
;; Add support for additional file extensions. ;; Add support for additional file extensions.
(dolist (entry '(("/LICENSE\\'" . text-mode) (dolist (entry '(("/\\.doomrc\\'" . emacs-lisp-mode)
("/LICENSE\\'" . text-mode)
("\\.log\\'" . text-mode) ("\\.log\\'" . text-mode)
("rc\\'" . conf-mode) ("rc\\'" . conf-mode)
("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode))) ("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode)))