Snippets

Peter Oliver Ansible polymode for Emacs

Created by Peter Oliver last modified
;; Copyright Peter Oliver 2015.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;; Because of https://github.com/vspinu/polymode/issues/75, this mode
;; works poorly.  Syntax highlighting goes awry from chunk to chunk, as
;; does indentation.
;; 
;; Ideally, these modes could be made to work reasonably then sent upstream
;; to be included in polymode.

(require 'polymode)

(defcustom pm-inner/jinja2
  (pm-hbtchunkmode "Jinja2"
                   :mode 'jinja2-mode
                   :head-reg "{[%{#][+-]?"
                   :tail-reg "[+-]?[%}#]}"
                   :head-mode 'body
                   :head-adjust-face nil)
  "Jinja2 chunk."
  :group 'innermodes
  :type 'object)

(defcustom pm-poly/ansible
  (pm-polymode-one "Ansible"
                   :hostmode 'pm-host/yaml
                   :innermode 'pm-inner/jinja2)
  "Ansible typical configuration"
  :group 'polymodes
  :type 'object)

(define-polymode poly-ansible-mode pm-poly/ansible)

(add-to-list 'auto-mode-alist '("/ansible/.*\\.ya?ml$" . poly-ansible-mode))

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.