+;; Ansible inventory files
+(when (memq 'ansible-inventory-generic-mode generic-extras-enable-list)
+
+(define-generic-mode ansible-inventory-generic-mode
+ '(?#)
+ nil
+ '(("^\\s-*\\(\\[.*\\]\\)" 1 font-lock-constant-face)
+ ("^\\s-*\\([^ \n\r]*\\)" 1 font-lock-function-name-face)
+ ;; Variable assignments must be x=y, so highlight as warning if
+ ;; the value is missing.
+ ("\\s-\\([^ =\n\r]+\\)[\n\r ]" 1 font-lock-warning-face)
+ ;; Variable assignments: x=y
+ ("\\([^ =\n\r]+\\)=\\([^ \n\r]*\\)"
+ (1 font-lock-variable-name-face)
+ (2 font-lock-keyword-face)))
+ '("inventory")
+ (list
+ (function
+ (lambda ()
+ (setq imenu-generic-expression
+ '((nil "^\\s-*\\[\\(.*\\)\\]" 1)
+ ("*Variables*" "\\s-+\\([^ =\n\r]+\\)=" 1))))))
+ "Generic mode for Ansible inventory files."))
+