├── .gitignore ├── README.md ├── debian ├── changelog ├── compat ├── control ├── copyright ├── debhelper-build-stamp ├── files ├── rules ├── vim-syntax-cfengine3.debhelper.log ├── vim-syntax-cfengine3.dirs ├── vim-syntax-cfengine3.install ├── vim-syntax-cfengine3.postinst ├── vim-syntax-cfengine3.prerm └── vim-syntax-cfengine3.substvars ├── doc ├── cf3.txt └── vim_cf3.pdf ├── ftdetect └── cf3.vim ├── ftplugin └── cf3.vim ├── registry └── vim-syntax-cfengine3.yaml ├── snippets ├── readstringarrayidx.cf ├── stdlib.cf └── template.cf ├── syntax └── cf3.vim ├── tools ├── extract_cf3BuiltIns.sh ├── extract_cf3Stdlib.sh └── extract_cf3evolve_freelib.sh └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | debian/vim-syntax-cfengine3 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | VIM files to support Cfengine 3 policy editing. 2 | 3 | - Syntax highlighting 4 | - Abbreviations 5 | - Code tidying tools 6 | - Ready to use code templates 7 | 8 | vim_cf3 files (https://github.com/neilhwatson/vim_cf3) 9 | 10 | Other CFEngine tools you might like: 11 | 12 | [Evolve Free promise library](https://github.com/evolvethinking/evolve_cfengine_freelib) is a collection of ready to use CFEngine policy. 13 | 14 | [Delta Reporting](https://github.com/evolvethinking/delta_reporting) is an open source reporting tool for CFEngine. 15 | 16 | Copyright (C) 2011 Neil H. Watson 17 | 18 | This program is free software: you can redistribute it and/or modify it under 19 | the terms of the GNU General Public License as published by the Free Software 20 | Foundation, either version 3 of the License, or (at your option) any later 21 | version. 22 | 23 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 24 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 25 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 26 | 27 | You should have received a copy of the GNU General Public License along with 28 | this program. If not, see . 29 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | vim-syntax-cfengine3 (20170815+nmu1) unstable; urgency=medium 2 | 3 | * Fix apt warning 4 | 5 | -- Michal Svamberg Tue, 15 Aug 2017 13:22:05 +0200 6 | 7 | vim-syntax-cfengine3 (20170719+nmu1) unstable; urgency=medium 8 | 9 | * Fix lintian warnings 10 | 11 | -- Michal Svamberg Wed, 19 Jul 2017 13:46:09 +0200 12 | 13 | vim-syntax-cfengine3 (20170424+nmu1) unstable; urgency=medium 14 | 15 | * Renamed files 16 | 17 | -- Michal Svamberg Mon, 24 Apr 2017 20:46:09 +0200 18 | 19 | vim-syntax-cfengine3 (20170424) unstable; urgency=medium 20 | 21 | * Upload new version 22 | 23 | -- Michal Švamberg Mon, 24 Apr 2017 20:36:14 +0200 24 | 25 | vim-syntax-cfengine3 (20140402+nmu3) unstable; urgency=medium 26 | 27 | * Non-maintainer upload. 28 | * Fix loading syntax file 29 | * Move syntax file from /usr/share/ to /var/lib/ 30 | 31 | -- Michal Švamberg Wed, 04 Feb 2015 17:03:14 +0100 32 | 33 | vim-syntax-cfengine3 (20140402+nmu1) unstable; urgency=low 34 | 35 | * get new version from 36 | * change destination path of syntax file 37 | 38 | -- Michal Švamberg Wed, 04 Feb 2015 16:16:24 +0100 39 | 40 | vim-syntax-cfengine3 (1.0.0) unstable; urgency=low 41 | 42 | * get upstream 43 | 44 | -- Michal Švamberg Thu, 25 Jun 2013 02:00:43 +0200 45 | 46 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: vim-syntax-cfengine3 2 | Section: editors 3 | Priority: optional 4 | Maintainer: Michal Svamberg 5 | Build-Depends: debhelper (>= 8.0.0) 6 | Homepage: https://github.com/neilhwatson/vim_cf3 7 | 8 | Package: vim-syntax-cfengine3 9 | Architecture: all 10 | Depends: ${misc:Depends}, vim-common, vim-addon-manager 11 | Description: CFEngine3 syntax for Vim 12 | This is CFEngine3 syntax file, it supported 13 | * syntax highlighting 14 | * abbreviations 15 | * ready to use code templates 16 | 17 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Neil H. Watson 2 | 3 | License: GPL-3.0+ 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | . 9 | This package is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | . 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | . 17 | On Debian systems, the complete text of the GNU General 18 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 19 | -------------------------------------------------------------------------------- /debian/debhelper-build-stamp: -------------------------------------------------------------------------------- 1 | vim-syntax-cfengine3 2 | -------------------------------------------------------------------------------- /debian/files: -------------------------------------------------------------------------------- 1 | vim-syntax-cfengine3_20170815+nmu1_all.deb editors optional 2 | vim-syntax-cfengine3_20170815+nmu1_amd64.buildinfo editors optional 3 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment this to turn on verbose mode. 5 | #export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ 9 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.debhelper.log: -------------------------------------------------------------------------------- 1 | dh_update_autotools_config 2 | dh_auto_configure 3 | dh_auto_build 4 | dh_auto_test 5 | dh_prep 6 | dh_installdirs 7 | dh_auto_install 8 | dh_install 9 | dh_installdocs 10 | dh_installchangelogs 11 | dh_pysupport 12 | dh_perl 13 | dh_link 14 | dh_strip_nondeterminism 15 | dh_compress 16 | dh_fixperms 17 | dh_installdeb 18 | dh_gencontrol 19 | dh_md5sums 20 | dh_builddeb 21 | dh_builddeb 22 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.dirs: -------------------------------------------------------------------------------- 1 | /usr/share/vim/ 2 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.install: -------------------------------------------------------------------------------- 1 | ftdetect/cf3.vim usr/share/vim/addons/ftdetect/ 2 | syntax/cf3.vim usr/share/vim/addons/syntax/ 3 | registry/vim-syntax-cfengine3.yaml usr/share/vim/registry/ 4 | 5 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | configure|abort-upgrade|abort-remove|abort-deconfigure) 7 | vim-addon-manager -w install cfengine3 8 | ;; 9 | *) 10 | echo "postinst called with unknown argument '$1'" >&2 11 | exit 1 12 | ;; 13 | esac 14 | 15 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | case "$1" in 4 | remove|deconfigure) 5 | vim-addon-manager -w remove cfengine3 6 | ;; 7 | upgrade) 8 | ;; 9 | 10 | failed-upgrade) 11 | ;; 12 | 13 | *) 14 | echo "prerm called with unknown argument '$1'" >&2 15 | exit 0 16 | ;; 17 | esac 18 | 19 | exit 0 20 | -------------------------------------------------------------------------------- /debian/vim-syntax-cfengine3.substvars: -------------------------------------------------------------------------------- 1 | misc:Depends= 2 | misc:Pre-Depends= 3 | -------------------------------------------------------------------------------- /doc/cf3.txt: -------------------------------------------------------------------------------- 1 | *cf3.txt* Help for vim_cf3 plugins. 2 | 3 | *cf3setup 4 | 5 | Install the provided files. 6 | .vim/ftplugin/cf3.vim 7 | .vim/syntax/cf3.vim 8 | .vim/ftdetect/cf3.vim 9 | .vim/doc/cf3.txt 10 | 11 | Add to your .vimrc file: 12 | 13 | :helptags ~/.vim/doc/ 14 | 15 | *cf3prerequisites* 16 | 17 | Eatchar and Getchar functions. Here are copies: 18 | fun! Getchar() 19 | let c = getchar() 20 | if c != 0 21 | let c = nr2char(c) 22 | endif 23 | return c 24 | endfun 25 | 26 | fun! Eatchar(pat) 27 | let c = Getchar() 28 | return (c =~ a:pat) ? '' : c 29 | endfun 30 | 31 | *cf3usage* 32 | 33 | Add "let EnableCFE3PermissionFix=1" to your .vimrc in order to enable 34 | automatic permission fixing, which removes group write and all "other" 35 | permissions from a file upon saving. 36 | 37 | *cf3abbreviations* 38 | 39 | The following expansions. Type the first, in insert mode, then space and get 40 | the second automatically. Add "let EnableCFE3KeywordAbbreviations=1" to your 41 | .vimrc to enable this behavior. 42 | 43 | = => 44 | ba bundle agent 45 | bc bundle common 46 | bu bundle 47 | cano canonify( 48 | cla classes: 49 | comma commands: 50 | comme comment => " 51 | exp expression => 52 | fil files: 53 | han handle => " 54 | ifv ifvarclass => 55 | met methods: 56 | pro processes: 57 | rep reports: 58 | sli slist => 59 | str string => 60 | sysw ${sys.workdir} 61 | ub usebundle => 62 | var vars: 63 | 64 | *cf3snippets 65 | 66 | A tech preview. Insert your snippet files. For example, in insert mode type //tmp and the skeleton template will be inserted. 67 | 68 | *cf3folds* 69 | 70 | Does basic folding of body types using markers { and }. See folds for normal commands. 71 | 72 | It may be useful to add 73 | autocmd BufRead,BufNewFile *.cf normal zR 74 | to your .vimrc in order to start up with all folds unfolded. 75 | 76 | *cf3maps* 77 | 78 | Maps, type the first, in normal mode and get the following results. 79 | 80 | *cf3quotes* 81 | 82 | ,q Wrap word in quotes. Also quotes a list of words, one per line, when 83 | visually blocked. 84 | 85 | *cf3promise* *cf3comment* *cf3handle* 86 | 87 | ,p Inserts a blank promise including blank handles and comment attributes. 88 | 89 | *cf3skeleton* *cf3template* 90 | 91 | ,k Inserts the skeleton of a self-contained Cfengine policy including a 92 | bundlesequence, inputs, a main bundle and a test bundle. 93 | 94 | = Aligns string, slist, etc and => across multiple lines to make it pretty. 95 | ,= Aligns => across multiple lines to make it pretty. 96 | 97 | *cf3Author* 98 | 99 | Neil H. Watson 100 | See Github for the lastest. 101 | https://github.com/neilhwatson/vim_cf3 102 | 103 | *cf3License* 104 | 105 | vim_cf3 files (https://github.com/neilhwatson/vim_cf3) 106 | Copyright (C) 2011 Neil H. Watson 107 | 108 | This program is free software: you can redistribute it and/or modify it under 109 | the terms of the GNU General Public License as published by the Free Software 110 | Foundation, either version 3 of the License, or (at your option) any later 111 | version. 112 | 113 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 114 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 115 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 116 | 117 | You should have received a copy of the GNU General Public License along with 118 | this program. If not, see . 119 | -------------------------------------------------------------------------------- /doc/vim_cf3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neilhwatson/vim_cf3/fe20647eb45aa2e92e0dfe1c4570fdc000c6e559/doc/vim_cf3.pdf -------------------------------------------------------------------------------- /ftdetect/cf3.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.cf set ft=cf3 2 | 3 | -------------------------------------------------------------------------------- /ftplugin/cf3.vim: -------------------------------------------------------------------------------- 1 | " Vim file plugin 2 | " This is my first attempt at a ftplugin file. Feel free to send me 3 | " corrections or improvements. I'll give you a credit. 4 | " 5 | " USAGE 6 | " There is already a vim file that uses 'cf' as a file extension. You can use 7 | " cf3 for your cf3 file extensions or identify via your vimrc file: 8 | " au BufRead,BufNewFile *.cf set ft=cf3 9 | 10 | " Check to see if DisableCF3Ftplugin is defined 11 | " If you only want the syntax plugin add "let g:DisableCF3Ftplugin=1" in 12 | " ~/.vimrc 13 | if exists("g:DisableCF3Ftplugin") 14 | finish 15 | endif 16 | 17 | 18 | " Only do this when not done yet for this buffer 19 | if exists("b:loaded_CFE3Ftplugin") 20 | finish 21 | endif 22 | let b:loaded_CFE3Ftplugin = 1 23 | 24 | let s:install_dir = expand(':p:h:h') 25 | 26 | " =============== Keyword Abbreviations =============== 27 | " enable keyword abbreviations with by adding 28 | " "let g:EnableCFE3KeywordAbbreviations=1" to your vimrc 29 | " Convenience function ToggleCFE3KeywordAbbreviations 30 | " mapped to ,i by default to toggle abbreviations on or off 31 | " 32 | function! EnableCFE3KeywordAbbreviations() 33 | iab = => 34 | iab ba bundle agent 35 | iab bc bundle common 36 | iab bu bundle 37 | iab cano canonify( "=Eatchar('\s') 38 | iab cla classes: 39 | iab comma commands: 40 | iab comme comment => "=Eatchar('\s') 41 | iab exp expression => =Eatchar('\s') 42 | iab fil files: 43 | iab han handle => "=Eatchar('\s') 44 | iab ifv ifvarclass => =Eatchar('\s') 45 | iab met methods: 46 | iab pro processes: 47 | iab rep reports: 48 | iab sli slist => { } 49 | iab str string => "=Eatchar('\s') 50 | iab sysw ${sys.workdir} 51 | iab ub usebundle => 52 | iab var vars: 53 | endfunction 54 | 55 | function! DisableCFE3KeywordAbbreviations() 56 | iunab = 57 | iunab ba 58 | iunab bc 59 | iunab bu 60 | iunab cano 61 | iunab cla 62 | iunab comma 63 | iunab comme 64 | iunab exp 65 | iunab fil 66 | iunab han 67 | iunab ifv 68 | iunab met 69 | iunab pro 70 | iunab rep 71 | iunab sli 72 | iunab str 73 | iunab sysw 74 | iunab ub 75 | iunab var 76 | endfunction 77 | 78 | " Default abbreviations off 79 | " to disable let g:EnableCFE3KeywordAbbreviations=1 in ~/.vimrc 80 | if exists('g:EnableCFE3KeywordAbbreviations') 81 | call EnableCFE3KeywordAbbreviations() 82 | endif 83 | 84 | function! ToggleCFE3KeywordAbbreviations() 85 | if !exists('b:EnableCFE3KeywordAbbreviations') 86 | let b:EnableCFE3KeywordAbbreviations=1 87 | call EnableCFE3KeywordAbbreviations() 88 | else 89 | unlet b:EnableCFE3KeywordAbbreviations 90 | call DisableCFE3KeywordAbbreviations() 91 | endif 92 | endfunction 93 | 94 | function! EnableCFE3PermissionFix() 95 | " On Save set the permissions of the edited file so others can't access 96 | :autocmd BufWritePost *.cf silent !chmod g-w,o-rwx % 97 | endfunction 98 | 99 | " Default permission fix off 100 | " To enable permission fixing in your main .vimrc 101 | " let g:EnableCFE3PermissionFix=1 102 | if exists('g:EnableCFE3PermissionFix') 103 | call EnableCFE3PermissionFix() 104 | endif 105 | 106 | " maps 107 | " Toggle KeywordAbbreviations 108 | nnoremap ,i :call ToggleCFE3KeywordAbbreviations() 109 | " Wrap WORD in double quotes 110 | nnoremap ,q dEi"pa" 111 | " Insert blank promise 112 | nnoremap ,p o""handle => "",comment => "" 113 | " quote list items 114 | vnoremap ,q :s/^\s*\(.*\)\s*$/"\1",/g 115 | 116 | " Function to align groups of => assignment lines. 117 | " Credit to 'Scripting the Vim editor, Part 2: User-defined functions' 118 | " by Damian Conway 119 | " http://www.ibm.com/developerworks/linux/library/l-vim-script-2/index.html 120 | if !exists("*CF3AlignAssignments") 121 | function CF3AlignAssignments (AOP) 122 | "Patterns needed to locate assignment operators... 123 | if a:AOP == 'vars' 124 | let ASSIGN_OP = '\(string\|int\|real\|data\|slist\|ilist\|rlist\|expression\|and\|or\|not\|volume\)*\s\+=>' 125 | else 126 | let ASSIGN_OP = '=>' 127 | endif 128 | let ASSIGN_LINE = '^\(.\{-}\)\s*\(' . ASSIGN_OP . '\)' 129 | 130 | "Locate block of code to be considered (same indentation, no blanks) 131 | let indent_pat = '^' . matchstr(getline('.'), '^\s*') . '\S' 132 | let firstline = search('^\%('. indent_pat . '\)\@!','bnW') + 1 133 | let lastline = search('^\%('. indent_pat . '\)\@!', 'nW') - 1 134 | if lastline < 0 135 | let lastline = line('$') 136 | endif 137 | 138 | "Find the column at which the operators should be aligned... 139 | let max_align_col = 0 140 | let max_op_width = 0 141 | for linetext in getline(firstline, lastline) 142 | "Does this line have an assignment in it? 143 | let left_width = match(linetext, '\s*' . ASSIGN_OP) 144 | 145 | "If so, track the maximal assignment column and operator width... 146 | if left_width >= 0 147 | let max_align_col = max([max_align_col, left_width]) 148 | 149 | let op_width = strlen(matchstr(linetext, ASSIGN_OP)) 150 | let max_op_width = max([max_op_width, op_width+1]) 151 | endif 152 | endfor 153 | 154 | "Code needed to reformat lines so as to align operators... 155 | let FORMATTER = '\=printf("%-*s%*s", max_align_col, submatch(1), 156 | \ max_op_width, submatch(2))' 157 | 158 | " Reformat lines with operators aligned in the appropriate column... 159 | for linenum in range(firstline, lastline) 160 | let oldline = getline(linenum) 161 | let newline = substitute(oldline, ASSIGN_LINE, FORMATTER, "") 162 | call setline(linenum, newline) 163 | endfor 164 | endfunction 165 | endif 166 | 167 | nnoremap ,= :call CF3AlignAssignments("null") 168 | nnoremap = :call CF3AlignAssignments("vars") 169 | 170 | " For pasting code snippets 171 | function! Pastefile( FILE ) 172 | let arg_file = s:install_dir."/snippets/".a:FILE 173 | let @" = join( readfile( arg_file ), "\n" ) 174 | put 175 | return "" 176 | endfunction 177 | 178 | nnoremap ,k :call Pastefile("template.cf")kdd 179 | nnoremap ,s :call Pastefile("stdlib.cf")kdd 180 | 181 | " TODO 182 | " Indents 183 | 184 | " CREDITS 185 | " Neil Watson 186 | " Other Cfengine information: http://watson-wilson.ca/cfengine/ 187 | " 188 | " CHANGES 189 | " Friday April 22 2022 190 | " - Added closing curly brace '}' to slist IAB in order to prevent errors when plugin is loaded by SpaceVim 191 | " 192 | " Wednesday January 09 2013 193 | " Operator alignment now works for just '=>' with ',=' or 'string, stlist ,etc 194 | " and => ' with '=' 195 | " 196 | " Wednesday October 05 2011 197 | " - Added comment and handle abbs. Assumes you have the Eatchar and Getchar 198 | " functions. 199 | " - Can now wrap words and lists in quotes. 200 | " - Insert blank promises (,p) 201 | " - Insert blank testing skeleton (,k) 202 | " 203 | " CHANGES 204 | " Monday November 21 2011 205 | " - IAB's for string, slist and usebundle. 206 | 207 | " CHANGES 208 | " Fri Apr 27 2012 209 | " Added function to align assigment operators 210 | 211 | " vim_cf3 files (https://github.com/neilhwatson/vim_cf3) 212 | " Copyright (C) 2011 Neil H. Watson 213 | " 214 | " This program is free software: you can redistribute it and/or modify it under 215 | " the terms of the GNU General Public License as published by the Free Software 216 | " Foundation, either version 3 of the License, or (at your option) any later 217 | " version. 218 | " 219 | " This program is distributed in the hope that it will be useful, but WITHOUT ANY 220 | " WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 221 | " PARTICULAR PURPOSE. See the GNU General Public License for more details. 222 | " 223 | " You should have received a copy of the GNU General Public License along with 224 | " this program. If not, see . 225 | -------------------------------------------------------------------------------- /registry/vim-syntax-cfengine3.yaml: -------------------------------------------------------------------------------- 1 | addon: cfengine3 2 | description: "Addon to highlight CFEngine3" 3 | files: 4 | - syntax/cf3.vim 5 | - ftdetect/cf3.vim 6 | -------------------------------------------------------------------------------- /snippets/readstringarrayidx.cf: -------------------------------------------------------------------------------- 1 | "dim_myarray" 2 | comment => "Read data file for parsing.", 3 | handle => "mybundle_vars_myarray", 4 | classes => if_ok( "index_myarray" ), 5 | int => readstringarrayidx( 6 | "myarray", 7 | "${ref}", 8 | "#[^\n]*", 9 | "\s*;;\s*", 10 | "100", 11 | "50k" 12 | ); 13 | 14 | index_myarray:: 15 | "myindex" 16 | comment => "Get indexes of array loaded above.", 17 | handle => "mybundle_vars_myindex", 18 | slist => getindices( "myarray" ); 19 | -------------------------------------------------------------------------------- /snippets/stdlib.cf: -------------------------------------------------------------------------------- 1 | bundle common cfengine_stdlib 2 | { 3 | vars: 4 | cfengine_3_4:: 5 | "inputs" slist => { "libraries/cfengine_stdlib.cf" }; 6 | cfengine_3_5:: 7 | "inputs" slist => { 8 | "lib/3.5/paths.cf", 9 | "lib/3.5/common.cf", 10 | "lib/3.5/commands.cf", 11 | "lib/3.5/packages.cf", 12 | "lib/3.5/files.cf", 13 | "lib/3.5/services.cf", 14 | "lib/3.5/processes.cf", 15 | "lib/3.5/storage.cf", 16 | "lib/3.5/databases.cf", 17 | "lib/3.5/monitor.cf", 18 | "lib/3.5/guest_environments.cf", 19 | "lib/3.5/bundles.cf", 20 | }; 21 | 22 | !(cfengine_3_4||cfengine_3_5):: 23 | "inputs" slist => { 24 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/paths.cf", 25 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/common.cf", 26 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/commands.cf", 27 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/packages.cf", 28 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/files.cf", 29 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/services.cf", 30 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/processes.cf", 31 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/storage.cf", 32 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/databases.cf", 33 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/monitor.cf", 34 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/guest_environments.cf", 35 | "lib/$(sys.cf_version_major).$(sys.cf_version_minor)/bundles.cf", 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /snippets/template.cf: -------------------------------------------------------------------------------- 1 | body common control 2 | { 3 | bundlesequence => { 4 | "main", 5 | }; 6 | } 7 | 8 | bundle agent main 9 | { 10 | methods: 11 | 12 | "any" usebundle => test; 13 | } 14 | 15 | bundle agent test 16 | { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /syntax/cf3.vim: -------------------------------------------------------------------------------- 1 | " vim:foldmethod=marker 2 | 3 | " Vim syntax file 4 | " Language: Cfengine version 3 5 | " Maintainer: Neil Watson 6 | " Last Change: Jun 02 2018 7 | " Location: 8 | " 9 | " TODO: 10 | " - would be great to know current promise type 11 | " 12 | " This is my first attempt at a syntax file. Feel free to send me corrections 13 | " or improvements. I'll give you a credit. 14 | " 15 | " USAGE 16 | " There is already a vim file that uses 'cf' as a file extension. You can use 17 | " cf3 for your cf3 file extensions or identify via your vimrc file: 18 | " au BufRead,BufNewFile *.cf set ft=cf3 19 | " 20 | " For version 5.x: Clear all syntax items 21 | " For version 6.x: Quit when a syntax file was already loaded 22 | 23 | if version < 600 " {{{ 24 | syntax clear 25 | elseif exists ("b:current_syntax") 26 | finish 27 | endif 28 | 29 | syn case ignore 30 | 31 | syn match cf3BundleParams /(\w\+\(,\s*\w\+\)*)/hs=s+1,he=e-1 contained 32 | syn match cf3BundleName /\s\+\w\+\s*/ contained nextgroup=cf3BundleParams 33 | 34 | syn keyword cf3BundleTypes agent common server knowledge monitor edit_line contained nextgroup=cf3BundleName skipwhite 35 | syn keyword cf3BundleTypes edit_xml contained nextgroup=cf3BundleName skipwhite 36 | syn match cf3Bundle /^\s*bundle\s\+/ nextgroup=Cf3BundleTypes skipwhite 37 | 38 | syn keyword cf3BodyTypes action classes contain acl changes contained nextgroup=cf3BundleName skipwhite 39 | syn keyword cf3BodyTypes copy_from delete depth_search contained nextgroup=cf3BundleName skipwhite 40 | syn keyword cf3BodyTypes edit_defaults file_select password contained nextgroup=cf3BundleName skipwhite 41 | syn keyword cf3BodyTypes link_from perms rename tcp_ip contained nextgroup=cf3BundleName skipwhite 42 | syn keyword cf3BodyTypes package_method process_count package_module contained nextgroup=cf3BundleName skipwhite 43 | syn keyword cf3BodyTypes process_select service_method contained nextgroup=cf3BundleName skipwhite 44 | syn keyword cf3BodyTypes mount volume printfile match_value contained nextgroup=cf3BundleName skipwhite 45 | syn keyword cf3BodyTypes association select_region delete_select contained nextgroup=cf3BundleName skipwhite 46 | syn keyword cf3BodyTypes insert_select location edit_field replace_with contained nextgroup=cf3BundleName skipwhite 47 | syn keyword cf3BodyTypes common database_server environment_resources contained nextgroup=cf3BundleName skipwhite 48 | syn match cf3Body /^\s*body\s\+/ nextgroup=Cf3BodyTypes skipwhite 49 | 50 | syn match cf3BodyControl /^\s*body\s\+\(common\|agent\|server\)\s\+control/ 51 | syn match cf3BodyControl /^\s*body\s\+\(monitor\|runagent\)\s\+control/ 52 | syn match cf3BodyControl /^\s*body\s\+\(executor\|knowledge\|hub\)\s\+control/ 53 | syn match cf3BodyControl /^\s*body\s\+\(reporter\|file\)\s\+control/ 54 | 55 | syn match cf3Action /\<\(vars\|classes\|reports\|meta\|users\):/ 56 | syn match cf3Action /\<\(commands\|databases\|files\|interfaces\|methods\|packages\|storage\):/ 57 | syn match cf3Action /\<\(access\|measurements\|roles\|topics\|occurrences\|defaults\):/ 58 | syn match cf3Action /\<\(control\|guest_environments\|outputs\|processes\|services\|things\):/ 59 | syn match cf3Action /\<\(delete_lines\|field_edits\|insert_lines\|replace_patterns\):/ 60 | 61 | syn match cf3Class /[^ "\t:#]\+::/ 62 | syn region cf3ClassBlock start=/\[%CFEngine/ end=/%\]/ contains=Cf3Class 63 | 64 | syn keyword TODO todo TODO FIXME TBD NOTE contained 65 | syn match cf3Comment /#.*/ contains=TODO 66 | 67 | syn match cf3Identifier /=>/ 68 | 69 | " Escape sequences in regexes 70 | syn match cf3Esc /\\\\[sSdD+][\+\*]*/ contained 71 | " Array indexes contained in []. Does not seems to be working. 72 | syn region cf3Array start=/\(\\\)\@]/ contains=cf3BuiltIns,cf3Stdlib 246 | syn match cf3Function /\<\w\+[,;()]/ contains=cf3BuiltIns,cf3Stdlib,cf3Evolve_freelib 247 | 248 | syn keyword cf3ControlAttr bundlesequence cache_system_functions goal_categories contained 249 | syn keyword cf3ControlAttr ignore_missing_bundles ignore_missing_inputs inputs contained 250 | syn keyword cf3ControlAttr version lastseenexpireafter output_prefix domain contained 251 | syn keyword cf3ControlAttr require_comments host_licenses_paid site_classes contained 252 | syn keyword cf3ControlAttr syslog_host syslog_port fips_mode protocol_version contained 253 | syn keyword cf3ControlAttr package_module contained 254 | syn keyword cf3MethodAttr usebundle useresult inherit contained 255 | syn keyword cf3CommonAttr action classes if unless ifvarclass handle depends_on comment policy with meta contained 256 | syn keyword cf3ClassesAttr and dist expression not or persistence scope select_class xor contained 257 | syn keyword cf3CommandsAttr args contain module contained 258 | syn keyword cf3ProcessesAttr process_count process_select contained 259 | syn keyword cf3ProcessesAttr process_stop restart_class signals contained 260 | syn keyword cf3PackagesAttr package_architectures package_method package_policy contained 261 | syn keyword cf3PackagesAttr package_select package_version package_module contained 262 | syn keyword cf3GuestEnvAttr environment_host environment_interface contained 263 | syn keyword cf3GuestEnvAttr environment_resources environment_state contained 264 | syn keyword cf3GuestEnvAttr environment_type contained 265 | syn keyword cf3TopicsAttr association synonyms generalizations contained 266 | syn keyword cf3ServicesAttr service_policy service_dependencies service_method contained 267 | syn keyword cf3DatabasesAttr database_server database_type contained 268 | syn keyword cf3DatabasesAttr database_operation database_columns contained 269 | syn keyword cf3DatabasesAttr database_rows registry_exclude contained 270 | syn keyword cf3DefaultsAttr if_match_regex contained 271 | syn keyword cf3StorageAttr mount volume contained 272 | syn keyword cf3FilesAttr acl changes copy_from create delete depth_search contained 273 | syn keyword cf3FilesAttr edit_defaults edit_line edit_template edit_xml file_select contained 274 | syn keyword cf3FilesAttr link_from move_obstructions pathtype perms contained 275 | syn keyword cf3FilesAttr rename repository template_method template_data touch transformer contained 276 | syn keyword cf3AccessAttr admit_ips admit_hostnames admit_keys admit deny deny_ips deny_hostnames deny_keys maproot contained 277 | syn keyword cf3AccessAttr ifencrypted resource_type contained 278 | syn keyword cf3MeasurementsAttr stream_type data_type history_type contained 279 | syn keyword cf3MeasurementsAttr units match_value contained 280 | syn keyword cf3ReportsAttr friend_pattern intermittency lastseen contained 281 | syn keyword cf3ReportsAttr printfile report_to_file showstate contained 282 | syn keyword cf3ReportsAttr bundle_return_value_index contained 283 | 284 | " Bodies 285 | syn keyword cf3EditLineAttr replace_with edit_field whitespace_policy location contained 286 | syn keyword cf3EditLineAttr insert_select insert_type expand_scalars not_matching contained 287 | syn keyword cf3EditLineAttr delete_select select_region contained 288 | syn keyword cf3EditFieldAttr allow_blank_fields extend_fields field_operation contained 289 | syn keyword cf3EditFieldAttr field_separator field_value select_field contained 290 | syn keyword cf3EditFieldAttr start_fields_from_zero value_separator contained 291 | syn keyword cf3ReplaceWithAttr occurrences replace_value contained 292 | syn keyword cf3SelectRegionAttr include_start_delimiter include_end_delimiter contained 293 | syn keyword cf3SelectRegionAttr select_start select_end contained 294 | syn keyword cf3ProcCountAttr in_range_define match_range out_of_range_define contained 295 | syn keyword cf3ProcSelectAttr command pid ppid pgid priority process_owner contained 296 | syn keyword cf3ProcSelectAttr process_result rsize status stime_range ttime_range contained 297 | syn keyword cf3ProcSelectAttr tty threads vsize contained 298 | syn keyword cf3EditDefAttr edit_backup empty_file_before_editing max_file_size recognize_join contained 299 | syn keyword cf3LocationAttr before_after first_last select_line_matching contained 300 | syn keyword cf3BodyFileSelectAttr leaf_name path_name search_mode search_size search_owners contained 301 | syn keyword cf3BodyFileSelectAttr search_groups search_bsdflags ctime mtime atime contained 302 | syn keyword cf3BodyFileSelectAttr exec_regex exec_program file_types issymlinkto file_result contained 303 | syn keyword cf3BodyClassesAttr promise_repaired repair_failed repair_denied contained 304 | syn keyword cf3BodyClassesAttr repair_timeout promise_kept cancel_kept cancel_repaired contained 305 | syn keyword cf3BodyClassesAttr cancel_notkept kept_returncodes repaired_returncodes contained 306 | syn keyword cf3BodyClassesAttr failed_returncodes persist_time scope timer_policy contained 307 | syn keyword cf3BodyLinkFromAttr copy_patterns link_children link_type source contained 308 | syn keyword cf3BodyLinkFromAttr when_linking_children when_no_source contained 309 | syn keyword cf3BodyPermsAttr bsdflags groups mode owners rxdirs contained 310 | syn keyword cf3BodyACLAttr aces acl_directory_inherit acl_method acl_type specify_inherit_aces contained 311 | syn keyword cf3BodyDepthSearchAttr depth exclude_dirs include_basedir include_dirs contained 312 | syn keyword cf3BodyDepthSearchAttr rmdeadlinks traverse_links xdev contained 313 | syn keyword cf3BodyDeleteAttr dirlinks rmdirs contained 314 | syn keyword cf3BodyRenameAttr disable disable_mode disable_suffix newname rotate contained 315 | syn keyword cf3BodyChangesAttr hash report_changes update_hashes report_diffs contained 316 | syn keyword cf3BodyPackageModuleAttr default_options query_installed_ifelapsed contained 317 | syn keyword cf3BodyPackageModuleAttr query_updates_ifelapsed contained 318 | syn keyword cf3BodyPackageMethodAttr package_add_command package_arch_regex contained 319 | syn keyword cf3BodyPackageMethodAttr package_changes package_delete_command contained 320 | syn keyword cf3BodyPackageMethodAttr package_delete_convention package_file_repositories contained 321 | syn keyword cf3BodyPackageMethodAttr package_installed_regex package_list_arch_regex contained 322 | syn keyword cf3BodyPackageMethodAttr package_list_command package_list_name_regex contained 323 | syn keyword cf3BodyPackageMethodAttr package_list_update_command package_list_update_ifelapsed contained 324 | syn keyword cf3BodyPackageMethodAttr package_list_version_regex package_name_convention contained 325 | syn keyword cf3BodyPackageMethodAttr package_name_regex package_noverify_regex contained 326 | syn keyword cf3BodyPackageMethodAttr package_noverify_returncode package_patch_arch_regex contained 327 | syn keyword cf3BodyPackageMethodAttr package_patch_command package_patch_installed_regex contained 328 | syn keyword cf3BodyPackageMethodAttr package_patch_list_command package_patch_name_regex contained 329 | syn keyword cf3BodyPackageMethodAttr package_patch_version_regex package_update_command contained 330 | syn keyword cf3BodyPackageMethodAttr package_verify_command package_version_regex contained 331 | syn keyword cf3BodyPackageMethodAttr package_version_less_command package_version_equal_command contained 332 | syn keyword cf3BodyPackageMethodAttr package_multiline_start contained 333 | syn keyword cf3BodyActionAttr action_policy ifelapsed expireafter log_string contained 334 | syn keyword cf3BodyActionAttr log_level log_kept log_priority log_repaired contained 335 | syn keyword cf3BodyActionAttr log_failed value_kept value_repaired value_notkept contained 336 | syn keyword cf3BodyActionAttr audit background report_level contained 337 | syn keyword cf3BodyActionAttr measurement_class contained 338 | syn keyword cf3BodyContainAttr useshell umask exec_owner exec_group exec_timeout contained 339 | syn keyword cf3BodyContainAttr chdir chroot preview no_output contained 340 | syn keyword cf3BodyCopyFromAttr source servers collapse_destination_dir contained 341 | syn keyword cf3BodyCopyFromAttr compare copy_backup encrypt check_root contained 342 | syn keyword cf3BodyCopyFromAttr copylink_patterns copy_size findertype contained 343 | syn keyword cf3BodyCopyFromAttr linkcopy_patterns link_type force_update contained 344 | syn keyword cf3BodyCopyFromAttr force_ipv4 portnumber preserve protocol_version purge contained 345 | syn keyword cf3BodyCopyFromAttr stealth timeout trustkey type_check verify contained 346 | syn keyword cf3BodyVolumeAttr check_foreign freespace sensible_size contained 347 | syn keyword cf3BodyVolumeAttr sensible_count scan_arrivals contained 348 | syn keyword cf3BodyMountAttr edit_fstab mount_type mount_source contained 349 | syn keyword cf3BodyMountAttr mount_server mount_options unmount contained 350 | syn keyword cf3BodyServiceMethodAttr service_type service_args contained 351 | syn keyword cf3BodyServiceMethodAttr service_autostart_policy service_dependence_chain contained 352 | syn keyword cf3BodyDatabaseServerAttr db_server_owner db_server_password contained 353 | syn keyword cf3BodyDatabaseServerAttr db_server_host db_server_type contained 354 | syn keyword cf3BodyDatabaseServerAttr db_server_connection_db contained 355 | syn keyword cf3BodyEnvResourcesAttr env_cpus env_memory env_disk contained 356 | syn keyword cf3BodyEnvResourcesAttr env_baseline env_spec_file env_spec contained 357 | syn keyword cf3BodyMatchValueAttr select_line_matching select_line_number contained 358 | syn keyword cf3BodyMatchValueAttr extraction_regex track_growing_file contained 359 | syn keyword cf3BodyServiceMethodAttr service_type service_args service_bundle contained 360 | syn keyword cf3BodyServiceMethodAttr service_autostart_policy service_dependence_chain contained 361 | syn keyword cf3BodyEnvInterfaceAttr env_addresses env_name env_network contained 362 | syn keyword cf3BodyServerControlAttr allowallconnects allowconnects allowlegacyconnects contained 363 | syn keyword cf3BodyServerControlAttr allowusers auditing bindtointerface contained 364 | syn keyword cf3BodyServerControlAttr cfruncommand denybadclocks denyconnects contained 365 | syn keyword cf3BodyServerControlAttr dynamicaddresses hostnamekeys keycacheTTL contained 366 | syn keyword cf3BodyServerControlAttr logallconnections logencryptedtransfers contained 367 | syn keyword cf3BodyServerControlAttr maxconnections port serverfacility contained 368 | syn keyword cf3BodyServerControlAttr skipverify trustkeysfrom contained 369 | syn keyword cf3BodyAgentControlAttr abortclasses abortbundleclasses addclasses contained 370 | syn keyword cf3BodyAgentControlAttr agentaccess agentfacility alwaysvalidate contained 371 | syn keyword cf3BodyAgentControlAttr auditing binarypaddingchar bindtointerface contained 372 | syn keyword cf3BodyAgentControlAttr hashupdates childlibpath checksum_alert_time contained 373 | syn keyword cf3BodyAgentControlAttr defaultcopytype dryrun editbinaryfilesize contained 374 | syn keyword cf3BodyAgentControlAttr editfilesize environment exclamation expireafter contained 375 | syn keyword cf3BodyAgentControlAttr files_single_copy files_auto_define hostnamekeys contained 376 | syn keyword cf3BodyAgentControlAttr ifelapsed inform intermittency max_children contained 377 | syn keyword cf3BodyAgentControlAttr maxconnections mountfilesystems nonalphanumfiles contained 378 | syn keyword cf3BodyAgentControlAttr repchar refresh_processes default_repository contained 379 | syn keyword cf3BodyAgentControlAttr secureinput sensiblecount sensiblesize contained 380 | syn keyword cf3BodyAgentControlAttr skipidentify suspiciousnames syslog verbose contained 381 | syn keyword cf3BodyAgentControlAttr track_value timezone default_timeout contained 382 | syn keyword cf3BodyExecutorControlAttr splaytime mailfrom mailsubject mailto smtpserver contained 383 | syn keyword cf3BodyExecutorControlAttr mailmaxlines schedule executorfacility contained 384 | syn keyword cf3BodyExecutorControlAttr exec_command contained 385 | syn keyword cf3BodyEditDefsAttr edit_backup empty_file_before_editing contained 386 | syn keyword cf3BodyEditDefsAttr max_file_size recognize_join inherit contained 387 | syn keyword cf3BodyDeleteSelectAttr delete_if_startwith_from_list contained 388 | syn keyword cf3BodyDeleteSelectAttr delete_if_not_startwith_from_list contained 389 | syn keyword cf3BodyDeleteSelectAttr delete_if_match_from_list contained 390 | syn keyword cf3BodyDeleteSelectAttr delete_if_not_match_from_list contained 391 | syn keyword cf3BodyDeleteSelectAttr delete_if_contains_from_list contained 392 | syn keyword cf3BodyDeleteSelectAttr delete_if_not_contains_from_list contained 393 | syn keyword cf3BodyInsertSelectAttr insert_if_startwith_from_list contained 394 | syn keyword cf3BodyInsertSelectAttr insert_if_not_startwith_from_list contained 395 | syn keyword cf3BodyInsertSelectAttr insert_if_match_from_list contained 396 | syn keyword cf3BodyInsertSelectAttr insert_if_not_match_from_list contained 397 | syn keyword cf3BodyInsertSelectAttr insert_if_contains_from_list contained 398 | syn keyword cf3BodyInsertSelectAttr insert_if_not_contains_from_list contained 399 | syn keyword cf3BodyMonitorControlAttr forgetrate monitorfacility histograms contained 400 | syn keyword cf3BodyMonitorControlAttr tcpdump tcpdumpcommand contained 401 | syn keyword cf3BodyPrintfileAttr file_to_print number_of_lines contained 402 | 403 | syn cluster cf3AttrCluster contains=cf3CommonAttr,cf3ClassesAttr,cf3Identifier, 404 | syn cluster cf3AttrCluster add=cf3ProcessesAttr,cf3FilesAttr,cf3ReportsAttr 405 | syn cluster cf3AttrCluster add=cf3PackagesAttr,cf3GuestEnvAttr,cf3TopicsAttr 406 | syn cluster cf3AttrCluster add=cf3StorageAttr,cf3AccessAttr,cf3MeasurementsAttr 407 | syn cluster cf3AttrCluster add=cf3EditLineAttr,cf3EditFieldAttr,cf3ReplaceWithAttr 408 | syn cluster cf3AttrCluster add=cf3SelectRegionAttr,cf3ProcCountAttr,cf3ProcSelectAttr 409 | syn cluster cf3AttrCluster add=cf3EditDefAttr,cf3LocationAttr,cf3CommandsAttr,cf3BodyFileSelectAttr 410 | syn cluster cf3AttrCluster add=cf3ControlAttr,cf3MethodAttr,cf3BodyClassesAttr 411 | syn cluster cf3AttrCluster add=cf3ServicesAttr,cf3DatabasesAttr,cf3DefaultsAttr 412 | 413 | syn cluster cf3AttrCluster add=cf3BodyLinkFromAttr,cf3BodyPermsAttr,cf3BodyACLAttr 414 | syn cluster cf3AttrCluster add=cf3BodyDepthSearchAttr,cf3BodyDeleteAttr,cf3BodyRenameAttr 415 | syn cluster cf3AttrCluster add=cf3BodyChangesAttr,cf3BodyPackageMethodAttr,cf3BodyActionAttr 416 | syn cluster cf3AttrCluster add=cf3BodyPackageModuleAttr 417 | syn cluster cf3AttrCluster add=cf3BodyContainAttr,cf3BodyCopyFromAttr,cf3BodyVolumeAttr 418 | syn cluster cf3AttrCluster add=cf3BodyMountAttr,cf3BodyServiceMethodAttr,cf3BodyDatabaseServerAttr 419 | syn cluster cf3AttrCluster add=cf3BodyEnvResourcesAttr,cf3BodyMatchValueAttr,cf3BodyServiceMethodAttr 420 | syn cluster cf3AttrCluster add=cf3BodyEnvInterfaceAttr,cf3BodyServerControlAttr,cf3BodyEditDefsAttr 421 | syn cluster cf3AttrCluster add=cf3BodyAgentControlAttr,cf3BodyExecutorControlAttr 422 | syn cluster cf3AttrCluster add=cf3BodyDeleteSelectAttr,cf3BodyInsertSelectAttr 423 | syn cluster cf3AttrCluster add=cf3BodyMonitorControlAttr,cf3BodyPrintfileAttr 424 | syn match cf3Attributes /\w\+\s*=>/ contains=@cf3AttrCluster 425 | 426 | " }}} 427 | 428 | if version >= 508 || !exists("did_cfg_syn_inits") " {{{ 429 | if version < 508 430 | let did_cfg_syn_inits = 1 431 | command -nargs=+ HiLink hi link 432 | else 433 | command -nargs=+ HiLink hi def link 434 | endif 435 | 436 | hi cf3Context ctermfg=DarkGreen 437 | hi cf3Arrows ctermfg=DarkCyan 438 | hi cf3Type ctermfg=Magenta 439 | hi Identifier ctermfg=Blue 440 | hi Function ctermfg=DarkGreen 441 | hi Library ctermfg=DarkGrey 442 | hi cf3ClassBlock ctermfg=Yellow 443 | 444 | HiLink cf3Bundle Statement 445 | HiLink cf3BundleTypes Statement 446 | HiLink cf3BundleName Function 447 | HiLink cf3BundleParams Identifier 448 | 449 | HiLink cf3Body Statement 450 | HiLink cf3BodyTypes Statement 451 | HiLink cf3Comment Comment 452 | 453 | HiLink cf3BodyControl Statement 454 | HiLink cf3BodyControlTypes Statement 455 | HiLink cf3BodyControlName Statement 456 | 457 | HiLink cf3Action Underlined 458 | HiLink cf3Class cf3Context 459 | 460 | HiLink cf3String String 461 | HiLink cf3BuiltIns Function 462 | HiLink cf3Evolve_freelib Function 463 | HiLink cf3Stdlib Library 464 | 465 | HiLink cf3Identifier cf3Arrows 466 | HiLink cf3Esc Special 467 | HiLink cf3Array Special 468 | HiLink cf3Var Identifier 469 | 470 | HiLink cf3Type cf3Type 471 | HiLink cf3CommonAttr Statement 472 | HiLink cf3ClassesAttr Statement 473 | HiLink cf3CommandsAttr Statement 474 | HiLink cf3ProcessesAttr Statement 475 | HiLink cf3FilesAttr Statement 476 | HiLink cf3MethodAttr cf3Type 477 | HiLink cf3PackagesAttr Statement 478 | HiLink cf3ControlAttr Statement 479 | HiLink cf3GuestEnvAttr Statement 480 | HiLink cf3TopicsAttr Statement 481 | HiLink cf3ServicesAttr Statement 482 | HiLink cf3DatabasesAttr Statement 483 | HiLink cf3DefaultsAttr Statement 484 | HiLink cf3StorageAttr Statement 485 | HiLink cf3AccessAttr Statement 486 | HiLink cf3MeasurementsAttr Statement 487 | HiLink cf3ReportsAttr Statement 488 | 489 | HiLink cf3EditLineAttr Statement 490 | HiLink cf3EditFieldAttr Statement 491 | HiLink cf3ReplaceWithAttr Statement 492 | HiLink cf3SelectRegionAttr Statement 493 | HiLink cf3ProcCountAttr Statement 494 | HiLink cf3ProcSelectAttr Statement 495 | HiLink cf3EditDefAttr Statement 496 | HiLink cf3LocationAttr Statement 497 | HiLink cf3BodyFileSelectAttr Statement 498 | HiLink cf3BodyClassesAttr Statement 499 | HiLink cf3BodyLinkFromAttr Statement 500 | HiLink cf3BodyPermsAttr Statement 501 | HiLink cf3BodyACLAttr Statement 502 | HiLink cf3BodyDepthSearchAttr Statement 503 | HiLink cf3BodyDeleteAttr Statement 504 | HiLink cf3BodyRenameAttr Statement 505 | HiLink cf3BodyChangesAttr Statement 506 | HiLink cf3BodyPackageMethodAttr Statement 507 | HiLink cf3BodyPackageModuleAttr Statement 508 | HiLink cf3BodyActionAttr Statement 509 | HiLink cf3BodyContainAttr Statement 510 | HiLink cf3BodyCopyFromAttr Statement 511 | HiLink cf3BodyVolumeAttr Statement 512 | HiLink cf3BodyMountAttr Statement 513 | HiLink cf3BodyServiceMethodAttr Statement 514 | HiLink cf3BodyDatabaseServerAttr Statement 515 | HiLink cf3BodyEnvResourcesAttr Statement 516 | HiLink cf3BodyMatchValueAttr Statement 517 | HiLink cf3BodyServiceMethodAttr Statement 518 | HiLink cf3BodyEnvInterfaceAttr Statement 519 | HiLink cf3BodyServerControlAttr Statement 520 | HiLink cf3BodyAgentControlAttr Statement 521 | HiLink cf3BodyExecutorControlAttr Statement 522 | HiLink cf3BodyEditDefsAttr Statement 523 | HiLink cf3BodyInsertSelectAttr Statement 524 | HiLink cf3BodyDeleteSelectAttr Statement 525 | HiLink cf3BodyMonitorControlAttr Statement 526 | HiLink cf3BodyPrintfileAttr Statement 527 | 528 | delcommand HiLink 529 | endif 530 | let b:current_syntax = "cf3" 531 | 532 | " }}} 533 | 534 | " Folding {{{ 535 | 536 | function! CF3Folds() 537 | let line = getline(v:lnum) 538 | 539 | " Don't include blank lines in previous fold {{{ 540 | if line =~? '\v^\s*$' 541 | return '-1' 542 | endif 543 | " }}} 544 | 545 | " Don't include comments in the previous fold {{{ 546 | if line =~? '\v^\s*#.*$' 547 | return '-1' 548 | endif 549 | " }}} 550 | 551 | " Fold bodies/bundles {{{ 552 | let body_types = [ 553 | \"^bundle", 554 | \"^body" 555 | \ ] 556 | for type in body_types 557 | if line =~ type 558 | return ">1" 559 | endif 560 | endfor 561 | " }}} 562 | 563 | " Fold promises {{{ 564 | let promise_types = [ 565 | \"meta:", 566 | \"vars:", 567 | \"defaults:", 568 | \"classes:", 569 | \"users:", 570 | \"files:", 571 | \"packages:", 572 | \"guest_environments:", 573 | \"methods:", 574 | \"processes:", 575 | \"services:", 576 | \"commands:", 577 | \"storage:", 578 | \"databases:", 579 | \"access:", 580 | \"roles:", 581 | \"measurements:", 582 | \"reports:", 583 | \ ] 584 | for promise_type in promise_types 585 | if line =~ promise_type 586 | return ">2" 587 | endif 588 | endfor 589 | " }}} 590 | 591 | " TODO: 592 | " - fold lists 593 | " - include trailing }'s in fdl 1 594 | 595 | " If nothing matches, keep the previous foldlevel 596 | return '=' 597 | 598 | endfunction 599 | 600 | setlocal foldmethod=expr 601 | setlocal foldexpr=CF3Folds() 602 | 603 | " }}} 604 | 605 | " CREDITS 606 | " Neil Watson 607 | " Aleksey Tsalolikhin 608 | " John Coleman of Yale U 609 | " Matt Lesko 610 | " Ivan Pesin 611 | " Zach Himsel 612 | " 613 | " vim_cf3 files (https://github.com/neilhwatson/vim_cf3) 614 | " Copyright (C) 2011 Neil H. Watson 615 | " 616 | " This program is free software: you can redistribute it and/or modify it under 617 | " the terms of the GNU General Public License as published by the Free Software 618 | " Foundation, either version 3 of the License, or (at your option) any later 619 | " version. 620 | " 621 | " This program is distributed in the hope that it will be useful, but WITHOUT ANY 622 | " WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 623 | " PARTICULAR PURPOSE. See the GNU General Public License for more details. 624 | " 625 | " You should have received a copy of the GNU General Public License along with 626 | " this program. If not, see . 627 | -------------------------------------------------------------------------------- /tools/extract_cf3BuiltIns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Loic Pefferkorn 4 | 5 | # Extract functions from CFEngine documentation. Should be run 6 | # inside CFEngine/documentation repository, in reference/functions directory: 7 | # 8 | # git clone https://github.com/cfengine/documentation.git 9 | # cd documentation/reference/functions 10 | # ~/path/to/tools/extract_cf3BuiltIns.sh 11 | 12 | #find $1 -type f -name '*.markdown' -printf "%f "|\ 13 | #sed -e 's/.markdown//g'|\ 14 | #awk '{count=split($0, tab); asort(tab);for (i=0;i<=count;i++) { if (i % 6 == 0) printf "MARK";printf "%s ", tab[i]}} END{print "contained"}'|\ 15 | #sed 's/MARK/contained\nsyn keyword cf3BuiltIns\t/g'|tail -n +2 16 | 17 | find . -type f -name '*.markdown' -exec basename {} .markdown \; |\ 18 | gsed -re 's/^(.*)intrealstring(.*)/\1int\2\n\1real\2\n\1string\2/' | sort | xargs |\ 19 | awk '{count=split($0,tab); for(i=0;i 4 | 5 | # Extract functions from CFEngine stdlib documentation. Should be run 6 | # inside CFEngine masterfiles repository: 7 | # 8 | # git clone https://github.com/cfengine/masterfiles.git 9 | # cd masterfiles 10 | # ~/path/to/tools/extract_cf3Stdlib.sh 11 | 12 | find . -path "./lib*" -type f -name '*.cf' | xargs cat | grep -E '^(bundle|body)'| sort | uniq\ 13 | |awk '{gsub(/\(.+/, "", $3);printf " %s", $3}'\ 14 | |awk '{count=split($0, tab); asort(tab);for (i=0;i<=count;i++) { if (i % 6 ==0) printf "MARK";printf "%s ", tab[i]}} END{ print "contained"}'\ 15 | |sed 's/MARK/contained\nsyn keyword cf3Stdlib\t/g'|tail -n +2 16 | -------------------------------------------------------------------------------- /tools/extract_cf3evolve_freelib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Extract functions from Evolve Thinking's free promise libary. Should be run 4 | # inside masterfiles: 5 | # 6 | # git clone https://github.com/evolvethinking/evolve_cfengine_freelib.git 7 | # cd evolve_cfengine_freelib 8 | # ~/path/to/tools/extract_cf3evolve_freelib.sh 9 | 10 | find . -type f -name 'evolve_freelib.cf' | xargs cat\ 11 | | awk '/^(bundle|body)/ {gsub(/\(.*/, "", $3);printf " %s", $3}'\ 12 | | awk '{count=split($0, tab); asort(tab);for (i=0;i<=count;i++) { if (i % 6 ==0) printf "MARK";printf "%s ", tab[i]}} END{ print "contained"}'|\ 13 | sed 's/MARK/contained\nsyn keyword cf3Evolve_freelib\t/g'|tail -n +2 14 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " Minimal vimrc 2 | set smartindent 3 | set autoindent 4 | syntax on 5 | filetype plugin indent on 6 | 7 | :helptags ~/.vim/doc/ 8 | " enable vim_cf3 plugin abbreviations 9 | let g:EnableCFE3KeywordAbbreviations=1 10 | 11 | fun! Getchar() 12 | let c = getchar() 13 | if c != 0 14 | let c = nr2char(c) 15 | endif 16 | return c 17 | endfun 18 | 19 | fun! Eatchar(pat) 20 | let c = Getchar() 21 | return (c =~ a:pat) ? '' : c 22 | endfun 23 | --------------------------------------------------------------------------------