Skip to content

Commit

Permalink
Add vim cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
rosenfeld committed May 5, 2011
0 parents commit 8e8e9bd
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 0 deletions.
39 changes: 39 additions & 0 deletions vim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Description
===========

Installs vim.

Requirements
============

`vim` must be a valid package name that installs VIM - Vi IMproved.

Attributes
==========

* `node[:vim][:extra_packages]` - An array of extra packages related to vim to install (like plugins). Empty array by default.

Usage
=====

Put `recipe[vim]` in a run list, or `include_recipe 'vim'` to ensure that vim is installed on your systems.

If you would like to install additional vim plugin packages, include their package names in the `node[:vim][:extra_packages]` attribute. Verify that your operating sytem has the package available.

License and Author
==================

Author:: Joshua Timberman <joshua@opscode.com>

Copyright 2010, Opscode, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
20 changes: 20 additions & 0 deletions vim/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Cookbook Name:: vim
# Attributes:: default
#
# Copyright 2010, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default[:vim][:extra_packages] = []
38 changes: 38 additions & 0 deletions vim/files/default/vimrc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax on
set background=dark
colorscheme koehler
"improve autocomplete menu color
highlight Pmenu ctermbg=blue ctermfg=gray gui=bold guibg=blue guifg=gray

filetype plugin indent on

" remember cursor position
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search

set wildmode=list:longest "make cmdline tab completion similar to bash
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~,.git,*.class,*.jar "stuff to ignore when tab completing


set number

set expandtab
set autoindent
set shiftwidth=2
set tabstop=2

set laststatus=2
"set statusline=%f
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P


" edit file expanding path to directory of the current file
nmap ,f :e <C-R>=expand("%:p:h") . "/" <CR>
nmap ,t :tabe <C-R>=expand("%:p:h") . "/" <CR>
nmap ,s :split <C-R>=expand("%:p:h") . "/" <CR>

29 changes: 29 additions & 0 deletions vim/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "vim",
"description": "Installs vim and optional extra packages.",
"long_description": "Description\n===========\n\nInstalls vim.\n\nRequirements\n============\n\n`vim` must be a valid package name that installs VIM - Vi IMproved.\n\nAttributes\n==========\n\n* `node[:vim][:extra_packages]` - An array of extra packages related to vim to install (like plugins). Empty array by default.\n\nUsage\n=====\n\nPut `recipe[vim]` in a run list, or `include_recipe 'vim'` to ensure that vim is installed on your systems.\n\nIf you would like to install additional vim plugin packages, include their package names in the `node[:vim][:extra_packages]` attribute. Verify that your operating sytem has the package available.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman <joshua@opscode.com>\n\nCopyright 2010, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
"platforms": {
},
"dependencies": {
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
},
"version": "1.0.0"
}
6 changes: 6 additions & 0 deletions vim/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs vim and optional extra packages."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.0.0"
32 changes: 32 additions & 0 deletions vim/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Cookbook Name:: vim
# Recipe:: default
#
# Copyright 2010, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

package "vim"

cookbook_file("/etc/vim/vimrc.local"){ source "vimrc.local" }

node[:vim][:extra_packages].each do |vimpkg|
package vimpkg
end

update_editor = lambda { execute "update-alternatives --set editor /usr/bin/vim.basic" }
ruby_block("Update editor alternatives to vim") do
block &update_editor
not_if { File.identical? '/etc/alternatives/vi', '/usr/bin/vim.basic' }
end

0 comments on commit 8e8e9bd

Please sign in to comment.