diff --git a/layers/+config-files/cfengine/README.org b/layers/+config-files/cfengine/README.org new file mode 100644 index 000000000..240da93a5 --- /dev/null +++ b/layers/+config-files/cfengine/README.org @@ -0,0 +1,118 @@ +#+TITLE: CFEngine layer +#+HTML_HEAD_EXTRA: + +#+CAPTION: logo +# The maximum height of the logo should be 200 pixels. +[[file:./img/agent.png]] + +* Table of Contents :TOC_4_org:noexport: + - [[Description][Description]] + - [[Install & Configuration][Install & Configuration]] + - [[Key bindings][Key bindings]] + +* Description +This layer makes working with CFEngine policy easier: + - Syntax highlighting + - On the fly syntax checks + - Auto completion + +* Install & Configuration + +Add =cfengine= to the =dotspacemacs-configuration-layers= in your =~/.spacemacs= +to use this layer. + +For working with CFEngine policy I highly recommend the =syntax-checking=, and +=auto-completion= layers. + +Here is an example: + +#+begin_src emacs-lisp + (defun dotspacemacs/layers () + "Configuration Layers declaration. + You should not put any user code in this function besides modifying the variable + values." + (setq-default + dotspacemacs-configuration-layers + '( + ;; ---------------------------------------------------------------- + ;; Example of useful layers you may want to use right away. + ;; Uncomment some layer names and press (Vim style) or + ;; (Emacs style) to install them. + ;; ---------------------------------------------------------------- + + ;; ---------------------------------------------------------------- + ;; CFEngine Related Layers + ;; ---------------------------------------------------------------- + cfengine + syntax-checking + auto-completion + + ;; ---------------------------------------------------------------- + ;; Other Userful Layers + ;; ---------------------------------------------------------------- + git + github + markdown + org + spell-checking + ) + + ;; Delete whitespace while saving buffer. Possible values are `all' + ;; to aggressively delete empty line and long sequences of whitespace, + ;; `trailing' to delete only the whitespace at end of lines, `changed'to + ;; delete only whitespace for changed lines or `nil' to disable cleanup. + ;; (default nil) + ;; + ;; ---------------------------------------------------------------- + ;; This is conservative, if you want to cleanup traling whitespace + ;; left by the efforts from others consider setting it to `trailing'. + ;; ---------------------------------------------------------------- + dotspacemacs-whitespace-cleanup 'changed + + ;; ----------------------------------------------------------------) + + (defun dotspacemacs/user-config () + "Configuration function for user code. + This function is called at the very end of Spacemacs initialization after + layers configuration. You are free to put any user code." + + ;; ---------------------------------------------------------------- + ;; Enable line numbering for CFEngine policy files + ;; ---------------------------------------------------------------- + (add-hook 'cfengine3-mode-hook + (lambda () + (linum-mode 1))) + + ;; ---------------------------------------------------------------- + ;; "Easy template" for quickly inserting cfengine3 code blocks in + ;; org-mode. Simply type = "value", + comment => "Indented 2 spaces from promiser"; + } +#+end_src + +* Key bindings + +| Key Binding | Description | +|-------------+-----------------------| +| ~ m j~ | Reformats JSON string | diff --git a/layers/+config-files/cfengine/config.el b/layers/+config-files/cfengine/config.el new file mode 100644 index 000000000..11274c71a --- /dev/null +++ b/layers/+config-files/cfengine/config.el @@ -0,0 +1,15 @@ +;; Figure out which cfengine mode (cfengine2 or cfengine3) to use for =.cf= +;; files based on file content. +;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode)) +(add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine3-mode)) + +;; Perhaps we should bind this to something some day. +;; (global-set-key [(control f4)] 'cfengine3-reformat-json-string) + +;; Enable eldoc-mode for cfengine +;; This puts function prototypes into the minibuffer when hovering +;; over the function. +(add-hook 'cfengine3-mode-hook 'eldoc-mode) + +;; Enable auto completion for cfengine +(spacemacs|defvar-company-backends cfengine3-mode) diff --git a/layers/+config-files/cfengine/img/agent.png b/layers/+config-files/cfengine/img/agent.png new file mode 100644 index 000000000..d5b7dc92c Binary files /dev/null and b/layers/+config-files/cfengine/img/agent.png differ diff --git a/layers/+config-files/cfengine/packages.el b/layers/+config-files/cfengine/packages.el new file mode 100644 index 000000000..bf969b602 --- /dev/null +++ b/layers/+config-files/cfengine/packages.el @@ -0,0 +1,47 @@ +;;; packages.el --- cfengine layer packages file for Spacemacs. +;; +;; Copyright (c) 2012-2016 Sylvain Benner & Contributors +;; +;; Author: Nick Anderson +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +;;; Commentary: + +;; See the Spacemacs documentation and FAQs for instructions on how to implement +;; a new layer: +;; +;; SPC h SPC layers RET +;; +;; +;; Briefly, each package to be installed or configured by this layer should be +;; added to `cfengine-packages'. Then, for each package PACKAGE: +;; +;; - If PACKAGE is not referenced by any other Spacemacs layer, define a +;; function `cfengine/init-PACKAGE' to load and initialize the package. + +;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so +;; define the functions `cfengine/pre-init-PACKAGE' and/or +;; `cfengine/post-init-PACKAGE' to customize the package as it is loaded. + +(setq cfengine-packages + '( + flycheck + company)) + ;; cfengine3-mode is included in emacs itself. + +(defun cfengine/init-cfengine() + (use-package cfengine3-mode + :init + (progn + (spacemacs/set-leader-keys-for-major-mode 'cfengine3-mode + "j" 'cfengine3-reformat-json-string)))) + +(defun cfengine/post-init-company () + (spacemacs|add-company-hook cfengine3-mode)) + +(defun cfengine/post-init-flycheck () + (spacemacs/add-flycheck-hook 'cfengine3-mode-hook))