├── .gitignore ├── README.md ├── addon-info.json ├── snippets └── chef.snippets └── syntax └── chef.vim /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | 15 | # YARD artifacts 16 | .yardoc 17 | _yardoc 18 | doc/ 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-chef 2 | ======== 3 | 4 | Vim plugins for chef (syntax highliting and autocomplete snipmate) 5 | 6 | 7 | Install with dependencies using `Vundle` 8 | =============== 9 | 10 | ``` 11 | Bundle "MarcWeber/vim-addon-mw-utils" 12 | Bundle "tomtom/tlib_vim" 13 | Bundle "garbas/vim-snipmate" 14 | Bundle "vadv/vim-chef" 15 | ``` 16 | 17 | Next: 18 | `:BundleInstall` 19 | 20 | Enable 21 | ============== 22 | Enable syntax for chef files some like this: 23 | 24 | `autocmd FileType ruby,eruby set filetype=ruby.eruby.chef` 25 | -------------------------------------------------------------------------------- /addon-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "vim-chef", 3 | "version" : "dev", 4 | "author" : "Vasilev Dmitry", 5 | "maintainer" : "Vasiliev Dmitry", 6 | "repository" : {"type": "git", "url": "git://github.com/vadv/vim-chef.git"}, 7 | "dependencies" : { 8 | "vim-snipmate": {} 9 | }, 10 | "description" : "vim snipmate for chef" 11 | } 12 | -------------------------------------------------------------------------------- /snippets/chef.snippets: -------------------------------------------------------------------------------- 1 | snippet action 2 | action :${1:nothing} 3 | 4 | snippet ignore_failure 5 | ignore_failure ${1:true} 6 | 7 | snippet provider 8 | provider Chef::Provider::${1:Package::Rubygems} 9 | 10 | snippet supports 11 | supports :status => :${1:true}, :restart => :${2:true}, :reload => :${3:true} 12 | 13 | snippet retries 14 | retries ${1:1} 15 | retry_delay ${2:2} 16 | 17 | snippet not_if 18 | not_if "${1}" 19 | 20 | snippet only_if 21 | only_if "${1}" 22 | 23 | snippet cron 24 | cron "${1:name}" do 25 | hour "${2:5}" 26 | minute "${3:0}" 27 | 28 | command "${4:/bin/true}" 29 | end 30 | 31 | snippet cronf 32 | cron "${1:name}" do 33 | hour "${2:*}" 34 | minute "${3:*}" 35 | day "${4:*}" 36 | month "${5:*}" 37 | weekday "${6:*}" 38 | command "${7:/bin/true}" 39 | user "${8:root}" 40 | mailto "${9:root@example.com}" 41 | path "${10:/bin:/usr/bin}" 42 | home "${11:/tmp}" 43 | shell "${12:/bin/bash}" 44 | end 45 | 46 | snippet deploy 47 | deploy "/my/deploy/dir" do 48 | repo "git@github.com/whoami/provideroject" 49 | revision "abc123" # or "HEAD" or "TAG_for_1.0" or (subversion) "1234" 50 | user "deploy_ninja" 51 | enable_submodules true 52 | migrate true 53 | migration_command "rake db:migrate" 54 | environment "RAILS_ENV" => "production", "OTHER_ENV" => "foo" 55 | shallow_clone true 56 | action :deploy # or :rollback 57 | restart_command "touch tmp/restart.txt" 58 | git_ssh_wrapper "wrap-ssh4git.sh" 59 | scm_provider Chef::Provider::Git # is the default, for svn: Chefhef::Provider::Subversion 60 | end 61 | 62 | snippet directory 63 | directory "${1:name}" do 64 | owner "root" 65 | group "root" 66 | mode "0755" 67 | 68 | action :create 69 | end 70 | 71 | snippet directoryf 72 | directory "${1:name}" do 73 | owner "$create{2:root}" 74 | group "${3:root}" 75 | mode "${4:0755}" 76 | path "${5:name}" 77 | recursive ${6:false} 78 | 79 | action :${7:create} 80 | end 81 | 82 | snippet env 83 | env "${1:RAILS_ENV}" do 84 | value "${2:production}" 85 | end 86 | 87 | snippet execute 88 | execute "${1:name}" do 89 | command "${2:ls -la}" 90 | creates "${3:/tmp/something}" 91 | 92 | action :${4:run} 93 | end 94 | 95 | snippet executef 96 | execute "${1:name}" do 97 | command "${2:ls -la}" 98 | creates "$ls{3:/tmp/something}" 99 | cwd "${4:/tmp}" 100 | environment ({${5:'HOME' => '/home/myhome'}}) 101 | user "${6:root}" 102 | group "${7:root}" 103 | path "${8:['/opt/bin','/opt/sbin']}" 104 | timeout ${9:3600} 105 | returns ${10:0} 106 | umask "${11:022}umask" 107 | 108 | action :${12:run} 109 | end 110 | 111 | snippet file 112 | file "${1:name}" do 113 | owner "root" 114 | group "root" 115 | mode "0644" 116 | 117 | action :create 118 | end 119 | 120 | snippet filef 121 | file "${1:name}" do 122 | path "${3:path}" 123 | backup ${4:5} 124 | owner "${5:root}" 125 | group "${6:root}" 126 | mode "${7:0644}" 127 | content "${8:content here}" 128 | 129 | action :${2:create} 130 | end 131 | 132 | snippet group 133 | group "${1:name}" do 134 | gid ${2:999} 135 | members [${3:'paco','vicente'}] 136 | 137 | action :create 138 | end 139 | 140 | snippet http_request 141 | http_request "${1:some message}" do 142 | url "${2:http://example.com/check_in}" 143 | end 144 | 145 | snippet http_requestp 146 | http_request "${1:posting data}" do 147 | action :post 148 | url "${2:http://example.com/check_in}" 149 | message ${3::some => "data"} 150 | headers (${4:\{"AUTHORIZATION" => authorization\}}) 151 | end 152 | 153 | snippet inc 154 | include_recipe "${1:example::recipe}" 155 | 156 | snippet link 157 | link "${1:/tmp/passwd}" do 158 | to "${2:/etc/passwd}" 159 | end 160 | 161 | snippet linkf 162 | link "${1:/tmp/passwd}" do 163 | to "${2:/etc/passwd}" 164 | link_type :${3:symbolic} 165 | owner "${4:root}" 166 | group "${5:root}" 167 | end 168 | 169 | snippet log 170 | log ("${1:your string to log}") { level :${2:debug} } 171 | 172 | snippet meta 173 | maintainer "${1:YOUR_COMPANY_NAME}" 174 | maintainer_email "${2:YOUR_EMAIL}" 175 | license "${3:All rights reserved}" 176 | description "${4:Installs/Configures example}" 177 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 178 | version "${5:0.0.1}" 179 | 180 | snippet notifies 181 | notifies :${1:restart}, "${2:service}[${3:name}]" 182 | 183 | snippet subscribes 184 | subscribes :${1:restart}, "${2:template}[${3:name}]" 185 | 186 | snippet pak 187 | package "${1:name}" do 188 | action :${2:install} 189 | version "${3:1.0-1}" 190 | end 191 | 192 | snippet pac 193 | package "${1:name}" do 194 | action :${2:install} 195 | version "${3:1.0-1}" 196 | end 197 | 198 | snippet cookbook_file 199 | cookbook_file "${1:/tmp/file}" do 200 | owner "${2:root}" 201 | group "${3:root}" 202 | mode "${4:0644}" 203 | source "${5:my-filename}" 204 | end 205 | 206 | snippet remote_file 207 | remote_file "${1:/tmp/remote_file}" do 208 | owner "${2:root}" 209 | group "${3:root}" 210 | mode "${4:0644}" 211 | source "${5:http://www.example.com/remote_file}" 212 | checksum "${6:sha256checksum}" 213 | end 214 | 215 | snippet remote_directory 216 | remote_directory "${1:/tmp/remote_directory_name}" do 217 | owner "${2:root}" 218 | group "${3:root}" 219 | mode "${4:0755}" 220 | source "${5:directory_name}" 221 | action :create 222 | end 223 | 224 | snippet role 225 | name "${1:role name}" 226 | description "${2:Description for the role}" 227 | env_run_lists "${3:role name}" => [ 228 | ] 229 | run_list "" 230 | default_attributes( 231 | ${4::attribute => "example"} 232 | ) 233 | 234 | snippet ruby 235 | ruby_block "${1:reload client config}" do 236 | block do 237 | ${0:Chef::Config.from_file("/Chefetc/chef/client.rb")} 238 | end 239 | end 240 | 241 | snippet git 242 | git "${1:/home/user/deployment}" do 243 | repository "${2:git@github.com:gitsite/deploymentployment.git}" 244 | reference "${3:master}" 245 | user "${4:user}" 246 | group "${5:templateest}" 247 | action :sync 248 | end 249 | 250 | snippet bash 251 | bash "${1:install something}" do 252 | user "${2:root}" 253 | cwd "${3:/tmp}" 254 | code < ${2:true}, :restart => ${3:true}, :truereload => ${4:true} 271 | action ${5:[ :enable, :start ]} 272 | end 273 | 274 | snippet servicep 275 | service "${1:name}" do 276 | pattern "${2:pattern}" 277 | supports :status => ${3:true}, :restart => ${4:true}, :reload => ${5:true} 278 | action ${6:[ :enable, :start ]} 279 | end 280 | 281 | snippet template 282 | template "${1:name}" do 283 | source "${2:source}.erb" 284 | owner "root" 285 | group "root" 286 | mode "0644" 287 | end 288 | 289 | snippet templatev 290 | template "${1:name}" do 291 | source "${2:source}.erb" 292 | owner "root" 293 | group "root" 294 | node "0644" 295 | variables( ${3::config_var => node[:configs][:config_var]} ) 296 | end 297 | 298 | snippet user 299 | user "${1:random}" do 300 | action :create 301 | comment "${2:Random User}" 302 | uid ${3:1000} 303 | gid "${4:users}" 304 | home "${5:/home/random}" 305 | shell "${6:/bin/zsh}" 306 | password "${7:\$1\$JJsvHslV\$szsCjVEroftprNn4JHtDi.}" 307 | supports :manage_home =>manage_home true 308 | end 309 | -------------------------------------------------------------------------------- /syntax/chef.vim: -------------------------------------------------------------------------------- 1 | 2 | syn keyword chefBlock file contained 3 | syn keyword chefBlock remote_directory contained 4 | syn keyword chefBlock remote_file contained 5 | syn keyword chefBlock template contained 6 | syn keyword chefBlock directory contained 7 | syn keyword chefBlock cookbook_file contained 8 | syn keyword chefBlock user contained 9 | 10 | syn keyword chefIdent owner 11 | syn keyword chefIdent comment 12 | syn keyword chefIdent uid 13 | syn keyword chefIdent gid 14 | syn keyword chefIdent home 15 | syn keyword chefIdent shell 16 | syn keyword chefIdent password 17 | syn keyword chefIdent mode 18 | syn keyword chefIdent source 19 | syn keyword chefIdent version 20 | syn keyword chefIdent ruby_string 21 | syn keyword chefIdent ignore_failure 22 | syn keyword chefIdent provider 23 | syn keyword chefIdent supports 24 | syn keyword chefIdent retries 25 | syn keyword chefIdent not_if 26 | syn keyword chefIdent only_if 27 | syn keyword chefIdent cron 28 | syn keyword chefIdent deploy 29 | syn keyword chefIdent env 30 | syn keyword chefIdent execute 31 | syn keyword chefIdent group 32 | syn keyword chefIdent http_request 33 | syn keyword chefIdent link 34 | syn keyword chefIdent log 35 | syn keyword chefIdent meta 36 | syn keyword chefIdent subscribes 37 | syn keyword chefIdent package 38 | syn keyword chefIdent role 39 | syn keyword chefIdent ruby 40 | syn keyword chefIdent git 41 | syn keyword chefIdent bash 42 | syn keyword chefIdent python 43 | syn keyword chefIdent service 44 | 45 | syn keyword chefImportant recursive 46 | syn keyword chefImportant notifies 47 | syn keyword chefImportant action 48 | syn keyword chefImportant not_if 49 | syn keyword chefImportant only_if 50 | 51 | syn keyword chefDirective include_recipe 52 | syn keyword chefDirective recipe 53 | 54 | syn keyword chefDirective node 55 | 56 | hi link chefIdent Identifier 57 | hi link chefBlock Statement 58 | hi link chefImportant Type 59 | hi link chefConstant Constant 60 | hi link chefError Error 61 | hi link chefDirective Keyword 62 | 63 | hi link chefBooleab Boolean 64 | hi link chefDirective Identifier 65 | hi link chefSpec Special 66 | --------------------------------------------------------------------------------