From 5af60f7cf9dbe7a7572faa1ad367ddf05339fa2c Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Mon, 11 Apr 2022 21:04:41 -0700 Subject: [PATCH] Expand Ansible functionality Doing a lot of Ansible for my day job lately, so now we can hook up the documentation directly, and use a poly-ansible to switch between Jinja and YAML syntax. --- ha-org.org | 1 - ha-programming.org | 31 ++++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ha-org.org b/ha-org.org index 28bdc0a..559aa74 100644 --- a/ha-org.org +++ b/ha-org.org @@ -415,7 +415,6 @@ Here is a sequence diagram example to show how is looks/works: #+begin_src plantuml :file ha-org-plantuml-example.png :exports file :results file @startuml !include https://raw.githubusercontent.com/ptrkcsk/one-dark-plantuml-theme/v1.0.0/theme.puml - ' See details at https://plantuml.com/ ' See details at https://plantuml.com/sequence-diagram Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response diff --git a/ha-programming.org b/ha-programming.org index a5f963a..aa6ee81 100644 --- a/ha-programming.org +++ b/ha-programming.org @@ -329,17 +329,42 @@ Using the [[https://github.com/seagle0128/doom-modeline][Doom Modeline]] to add #+END_SRC * Languages Simple to configure languages go here. More advanced stuff will go in their own files… eventually. -** YAML and Jinja +** Ansible Doing a lot of [[https://github.com/yoshiki/yaml-mode][YAML work]], but this project needs a new maintainer. #+BEGIN_SRC emacs-lisp (use-package yaml-mode - :mode "\\.ya?ml\\'") + :mode (rx ".y" (optional "a") "ml" string-end)) #+END_SRC Ansible uses Jinja, so we install the [[https://github.com/paradoxxxzero/jinja2-mode][jinja2-mode]]: #+BEGIN_SRC emacs-lisp (use-package jinja2-mode - :mode (rx ".j2" eol)) + :mode (rx ".j2" string-end)) +#+END_SRC + +Do I consider all YAML files an Ansible file needing [[https://github.com/k1LoW/emacs-ansible][ansible-mode]]? +#+BEGIN_SRC emacs-lisp + (use-package ansible + ;; :hook (yaml-mode . ansible-mode) + :config + (ha-leader "t y" 'ansible)) +#+END_SRC + +However, let’s have all YAML able to access Ansible’s documentation using the [[https://github.com/emacsorphanage/ansible-doc][ansible-doc]] project: +#+BEGIN_SRC emacs-lisp + (use-package ansible-doc + :hook (yaml-mode . ansible-doc-mode) + :config + (ha-local-leader :keymaps 'yaml-mode-map + "d" '(:ignore t :which-key "docs") + "d d" 'ansible-doc)) +#+END_SRC + +The [[https://github.com/emacsmirror/poly-ansible][poly-ansible]] project uses [[https://polymode.github.io/][polymode]], gluing [[https://github.com/paradoxxxzero/jinja2-mode][jinja2-mode]] into [[https://github.com/yoshiki/yaml-mode][yaml-mode]]. +#+BEGIN_SRC emacs-lisp +(use-package poly-ansible + :straight (:host github :repo "emacsmirror/poly-ansible") + :hook (yaml-mode . poly-ansible-mode)) #+END_SRC ** Emacs Lisp