dev: adding chezmoi module from pr6633
This commit is contained in:
parent
4cf23e4327
commit
a94da3866f
4 changed files with 124 additions and 0 deletions
68
modules/tools/chezmoi/README.org
Normal file
68
modules/tools/chezmoi/README.org
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# -*- mode: doom-docs-org -*-
|
||||||
|
#+title: :tools chezmoi
|
||||||
|
#+subtitle: Manage your dotfiles with chezmoi inside Emacs
|
||||||
|
#+created: May 05, 2022
|
||||||
|
#+since: 22.05
|
||||||
|
|
||||||
|
* Description :unfold:
|
||||||
|
This module provides convenience functions for interacting with the [[https://chezmoi.io][chezmoi]]
|
||||||
|
dotfile management system via Emacs.
|
||||||
|
|
||||||
|
** Maintainers
|
||||||
|
- [[doom-user:][@abougouffa]]
|
||||||
|
|
||||||
|
** Module flags
|
||||||
|
/This module has no flags./
|
||||||
|
|
||||||
|
** Packages
|
||||||
|
- [[doom-package:][chezmoi]]
|
||||||
|
|
||||||
|
** TODO Hacks
|
||||||
|
#+begin_quote
|
||||||
|
🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]]
|
||||||
|
#+end_quote
|
||||||
|
|
||||||
|
** TODO Changelog
|
||||||
|
# This section will be machine generated. Don't edit it by hand.
|
||||||
|
/This module does not have a changelog yet./
|
||||||
|
|
||||||
|
* Installation
|
||||||
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
||||||
|
|
||||||
|
This module requires [[https://chezmoi.io][chezmoi]].
|
||||||
|
|
||||||
|
* TODO Usage
|
||||||
|
#+begin_quote
|
||||||
|
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
||||||
|
#+end_quote
|
||||||
|
|
||||||
|
This module facilitate editing dotfiles managed by ~chezmoi~.
|
||||||
|
|
||||||
|
This module provides a set of Emacs commands that are equivalent to ~chezmoi~
|
||||||
|
commands, including:
|
||||||
|
|
||||||
|
| Command | chezmoi equivalent |
|
||||||
|
|--------------+--------------------|
|
||||||
|
| find-file | chezmoi edit |
|
||||||
|
| save-buffer | chezmoi apply |
|
||||||
|
| diff | chezmoi diff |
|
||||||
|
| ediff | chezmoi merge |
|
||||||
|
| magit-status | chezmoi git status |
|
||||||
|
|
||||||
|
More information can be found on the [[https://github.com/tuh8888/chezmoi.el][chezmoi.el]] GitHub page.
|
||||||
|
|
||||||
|
* TODO Configuration
|
||||||
|
#+begin_quote
|
||||||
|
🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
|
||||||
|
#+end_quote
|
||||||
|
|
||||||
|
* Troubleshooting
|
||||||
|
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
||||||
|
|
||||||
|
* Frequently asked questions
|
||||||
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
||||||
|
|
||||||
|
* TODO Appendix
|
||||||
|
#+begin_quote
|
||||||
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
||||||
|
#+end_quote
|
46
modules/tools/chezmoi/config.el
Normal file
46
modules/tools/chezmoi/config.el
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
;;; tools/chezmoi/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(use-package! chezmoi
|
||||||
|
:commands (chezmoi-write
|
||||||
|
chezmoi-magit-status
|
||||||
|
chezmoi-diff
|
||||||
|
chezmoi-ediff
|
||||||
|
chezmoi-find
|
||||||
|
chezmoi-write-files
|
||||||
|
chezmoi-open-other
|
||||||
|
chezmoi-template-buffer-display
|
||||||
|
chezmoi-mode)
|
||||||
|
:config
|
||||||
|
;; Company integration
|
||||||
|
(when (featurep! :completion company)
|
||||||
|
(defun +chezmoi--company-backend-h ()
|
||||||
|
(require 'chezmoi-company)
|
||||||
|
(if chezmoi-mode
|
||||||
|
(add-to-list 'company-backends 'chezmoi-company-backend)
|
||||||
|
(delete 'chezmoi-company-backend 'company-backends)))
|
||||||
|
|
||||||
|
(add-hook 'chezmoi-mode-hook #'+chezmoi--company-backend-h))
|
||||||
|
|
||||||
|
;; Integrate with evil mode by toggling template display when entering insert mode.
|
||||||
|
(when (featurep! :editor evil)
|
||||||
|
(defun +chezmoi--evil-insert-state-enter-h ()
|
||||||
|
"Run after evil-insert-state-entry."
|
||||||
|
(chezmoi-template-buffer-display nil (point))
|
||||||
|
(remove-hook 'after-change-functions #'chezmoi-template--after-change 1))
|
||||||
|
|
||||||
|
(defun +chezmoi--evil-insert-state-exit-h ()
|
||||||
|
"Run after evil-insert-state-exit."
|
||||||
|
(chezmoi-template-buffer-display nil)
|
||||||
|
(chezmoi-template-buffer-display t)
|
||||||
|
(add-hook 'after-change-functions #'chezmoi-template--after-change nil 1))
|
||||||
|
|
||||||
|
(defun +chezmoi--evil-h ()
|
||||||
|
(if chezmoi-mode
|
||||||
|
(progn
|
||||||
|
(add-hook 'evil-insert-state-entry-hook #'+chezmoi--evil-insert-state-enter-h nil 1)
|
||||||
|
(add-hook 'evil-insert-state-exit-hook #'+chezmoi--evil-insert-state-exit-h nil 1))
|
||||||
|
(progn
|
||||||
|
(remove-hook 'evil-insert-state-entry-hook #'+chezmoi--evil-insert-state-enter-h 1)
|
||||||
|
(remove-hook 'evil-insert-state-exit-hook #'+chezmoi--evil-insert-state-exit-h 1))))
|
||||||
|
|
||||||
|
(add-hook 'chezmoi-mode-hook #'+chezmoi--evil-h)))
|
5
modules/tools/chezmoi/doctor.el
Normal file
5
modules/tools/chezmoi/doctor.el
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
;;; tools/chezmoi/doctor.el
|
||||||
|
|
||||||
|
(unless (executable-find "chezmoi")
|
||||||
|
(warn! "Couldn't find the chezmoi binary."))
|
5
modules/tools/chezmoi/packages.el
Normal file
5
modules/tools/chezmoi/packages.el
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
;; -*- no-byte-compile: t; -*-
|
||||||
|
;;; tools/chezmoi/packages.el
|
||||||
|
|
||||||
|
(package! chezmoi
|
||||||
|
:pin "781783c483bc8fcdba3a230bb774c3a8a5ebe396")
|
Loading…
Add table
Add a link
Reference in a new issue