diff --git a/contrib/ansible/README.md b/contrib/ansible/README.md new file mode 100644 index 000000000000..06b3f9e25556 --- /dev/null +++ b/contrib/ansible/README.md @@ -0,0 +1,35 @@ +# Ansible contribution layer for Spacemacs + +![ansible](img/ansible.png) + + +**Table of Contents** + +- [Ansible contribution layer for Spacemacs](#ansible-contribution-layer-for-spacemacs) + - [Description](#description) + - [Install](#install) + - [Key bindings](#key-bindings) + + + +## Description + +This layer add support for Ansible-flavored YAML buffers. + +## Install + +To use this contribution add it to your `~/.spacemacs` + +```elisp +(setq-default dotspacemacs-configuration-layers '(ansible) +"List of contribution to load." +) +``` + +## Key bindings + +Key Binding | Description +--------------|------------------------------------------------------------ +` m a ?` | looks up documentation using [`ansible-doc`][ansible-doc] + +[ansible-doc]: https://github.com/lunaryorn/ansible-doc.el diff --git a/contrib/ansible/config.el b/contrib/ansible/config.el new file mode 100644 index 000000000000..c703ae425f44 --- /dev/null +++ b/contrib/ansible/config.el @@ -0,0 +1,16 @@ +;;; funcs.el --- Ansible Layer extensions File for Spacemacs +;; +;; Copyright (c) 2012-2014 Sylvain Benner +;; Copyright (c) 2015 Brian Hicks & Contributors +;; +;; Author: Brian Hicks +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +;; detect filenames compatible with Ansible's recommended layout. +;; http://docs.ansible.com/playbooks_best_practices.html#directory-layout +(setq ansible/ansible-filename-re + "\\(site\.yml\\|roles/.+\.yml\\|group_vars/.+\\|host_vars/.+\\)") diff --git a/contrib/ansible/funcs.el b/contrib/ansible/funcs.el new file mode 100644 index 000000000000..5d88f89c8057 --- /dev/null +++ b/contrib/ansible/funcs.el @@ -0,0 +1,24 @@ +;;; funcs.el --- Ansible Layer extensions File for Spacemacs +;; +;; Copyright (c) 2012-2014 Sylvain Benner +;; Copyright (c) 2015 Brian Hicks & Contributors +;; +;; Author: Brian Hicks +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 +(defun ansible/ansible-should-enable? () + (and (stringp buffer-file-name) + (string-match ansible/ansible-filename-re buffer-file-name))) + +(defun ansible/ansible-maybe-enable () + (when (ansible/ansible-should-enable?) + (ansible 1))) + +(defun ansible/ansible-doc-maybe-enable () + (when (ansible/ansible-should-enable?) + (ansible-doc-mode 1) + (evil-leader/set-key-for-mode 'yaml-mode + "ma?" 'ansible-doc))) diff --git a/contrib/ansible/img/ansible.png b/contrib/ansible/img/ansible.png new file mode 100644 index 000000000000..3d12c5f2d7bf Binary files /dev/null and b/contrib/ansible/img/ansible.png differ diff --git a/contrib/ansible/packages.el b/contrib/ansible/packages.el new file mode 100644 index 000000000000..c791ce0f10f8 --- /dev/null +++ b/contrib/ansible/packages.el @@ -0,0 +1,40 @@ +;;; extensions.el --- Ansible Layer extensions File for Spacemacs +;; +;; Copyright (c) 2012-2014 Sylvain Benner +;; Copyright (c) 2015 Brian Hicks & Contributors +;; +;; Author: Brian Hicks +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 +(defvar ansible-packages '(yaml-mode + ansible + ansible-doc)) + +(defun ansible/init-yaml-mode () + (use-package yaml-mode + :defer t)) + +(defun ansible/init-ansible () + (use-package ansible + :defer t + :init (progn + (eval-after-load 'yaml-mode + '(add-hook 'yaml-mode-hook 'ansible/ansible-maybe-enable)) + + ;; ansible-mode requires ac-user-dictionary-files. If the + ;; config is using company-mode this variable will not be + ;; set, so we set it to a dummy value. + ;; + ;; Tracking here: + ;; https://github.com/k1LoW/emacs-ansible/issues/2 + (when (member 'company-mode dotspacemacs-configuration-layers) + (setq ac-user-dictionary-files '()))))) + +(defun ansible/init-ansible-doc () + (use-package ansible-doc + :defer t + :init (eval-after-load 'yaml-mode + '(add-hook 'yaml-mode-hook 'ansible/ansible-doc-maybe-enable))))