Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

vim_config (2) Versions 2.1.0

Configures vim and installs vim plugins

Policyfile
Berkshelf
Knife
cookbook 'vim_config', '~> 2.1.0', :supermarket
cookbook 'vim_config', '~> 2.1.0'
knife supermarket install vim_config
knife supermarket download vim_config
README
Dependencies
Changelog
Quality 17%

Description

This cookbook helps you manage your vim plugins and configuration.

Update notes from previous versions

  • Downloading plugins from the official site has been deprecated. It still works (unless you let this cookbook manage your plugin folder), but is no longer documented. Use vim-scripts instead.
  • Config file modes "concatenate" and "delegate" deprecated. Still works, but undocumented.

Examples

# Install the nerdcommenter and endwise plugins via git
node.set[:vim_config][:bundles][:git] = [ "git://github.com/scrooloose/nerdcommenter.git",
                                          "git://github.com/tpope/vim-endwise.git" ] 

# Install the vim-ack plugin via mercurial
node.set[:vim_config][:bundles][:hg] = [ "https://bitbucket.org/delroth/vim-ack" ]

# Download our vimrc from github
node.set[:vim_config][:config_file_mode] = :remote_file
node.set[:vim_config][:remote_config_url] = "https://raw.github.com/promisedlandt/dotfiles/.vimrc"

# Execute
include_recipe "vim_config"

Platforms

Tested on Ubuntu and Debian. Check .kitchen.yml for the exact versions tested.

Prerequisites

Vim configuration and vim plugins would be silly without vim, but you will have to handle that installation yourself.

Git will be installed via the default git cookbook. If you do not wish this, set node[:vim_config][:skip_git_installation] = true.

In case you have queued up any plugins in mercurial repositories, mercurial will be installed. You can prevent this by setting node[:vim_config][:skip_mercurial_installation] = true.

Recipes

vim_config::default

Installs git, the plugin manager of your choice, optionally mercurial, all specified plugins and, optionally, your vimrc.

Attributes

All attributes are under the :vim_config namespace.

Attribute Description Type Default
bundle_dir Path where your plugins will be installed to String /etc/vim/bundle
force_update Delete installation_dir and bundle_dir before running anything else Boolean false
owner Owner of all files / directories created by this cookbook String root
owner_group Group of all files / directories created by this cookbook String root
plugin_manager Plugin manager to use. Currently supported are "pathogen", "unbundle" and "vundle" String pathogen
manage_plugin_folder Delete all plugin folders of plugins not installed by this cookbook Boolean false
config_file_mode Where to get config file from. See here String template
config_file_path Full path to the config file as it will end up on the file system String platform dependent
config_file_cookbook Used when config_file_mode is "cookbook". Name of the wrapper cookbook to get the config file from String nil

Plugin bundle attributes are under the [:vim_config][:bundles] namespace.

Attribute Description Type Default
git Array of URLs of plugins to install via git Array []
hg Array of URLs of plugins to install via mercurial Array []

Configuration

There are four ways to get your configuration file installed.

Via wrapper cookbook

Set node[:vim_config][:config_file_mode] = :cookbook, node[:vim_config][:config_file_template] to the name of the template file to use and node[:vim_config][:config_file_cookbook] to the name of your wrapper cookbook.

This is my preferred way of including your vimrc

An example wrapper cookbook can be found here

Via template

Set node[:vim_config][:config_file_mode] to :template (or don't set it at all, since :template is the default).

Then fork this cookbook and copy your vimrc into templates/default/vimrc.local.erb.

Via remote file

Set node[:vim_config][:config_file_mode] to :remote_file, then set node[:vim_config][:remote_config_url] to the URL of your vimrc.

Via Chef attributes

Set node[:vim_config][:config_file_mode] to :attributes, then set node[:vim_config][:vimrc][:config][:system_wide] to the configuration you want system wide (i.e. in /etc/vimrc), and / or set node[:vim_config][:vimrc][:config][:user_specific] to a hash, with the key being the username you want to set the config for and the value being the config.

The config needs to be an array, with each element representing one line in the config file and empty strings for blank lines.

If you want to indent e.g. a function, add a hash within the array, with the key being the function name and the body being again an array of strings.

Don't forget to close your function after the hash, this is not automated.

Example:

node.set[:vim_config] = {
  "config_file_mode" => "attributes",
  "vimrc" => {
    "config" => {
      "system_wide" => [
        "syntax on",
        "set number"
      ],
      "user_specific" => {
        "testuser" => [
          'set statusline=%<%f%h%m%r%=format=%{&fileformat}\ file=%{&fileencoding}\ enc=%{&encoding}\ %b\ 0x%B\ %l,%c%V\ %P',
          "set iskeyword=@,48-57,_,192-255",
          "",
          {
            "function! JavaScriptFold()" => [
              "setl foldmethod=syntax",
              "setl foldlevelstart=1",
              "syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend",

              { "function! FoldText()" => "return substitute(getline(v:foldstart), '{.*', '{...}', '')" },
              "endfunction",
              "setl foldtext=FoldText()"
            ]
          },
          "endfunction"
        ]
      }
    }
  }
}

include_recipe "vim_config::default"

Plugins

Plugins will be installed into a "bundle" directory under your installation directory by default. Feel free to change this by setting node[:vim_config][:bundle_dir].

Plugin Manager

Set the plugin manager in node[:vim_config][:plugin_manager]. One of :pathogen, :unbundle or :vundle.

The selected plugin manager will be installed automatically, but you will have to manually edit your vimrc according to your plugin manager's instructions.

Git

Fill the node[:vim_config][:bundles][:git] array with URLs to git repositories of plugins you want to use, e.g.

default_attributes  vim_config: { bundles: { 
                                           git: [ "git://github.com/scrooloose/nerdcommenter.git",
                                                  "git://github.com/tpope/vim-endwise.git" ] 
}}

Mercurial

Fill the node[:vim_config][:bundles][:hg] array with URLs to mercurial repositories of plugins you want to use, e.g.

default_attributes  vim_config: { bundles: { 
  hg: [ "https://bitbucket.org/delroth/vim-ack" ] 
}}

This needs the mercurial LWRP, so make sure to include the mercurial cookbook.

Resources / Providers

If you prefer this cookbook to not manage your stuff, you can just use the LWRPs to manage your plugins.

vim_config_git

Installs a vim plugin from a git source.

Actions

Name Description default?
create Downloads and installs the plugin default
delete Deletes the plugin folder

Attributes

Attribute Description Type Default
repository URL to the repository String name
reference branch String master

Examples

# Let's install syntastic
vim_config_git "https://github.com/scrooloose/syntastic"

# Let's install the "shellslash_fix" branch of syntastic
vim_config_git "https://github.com/scrooloose/syntastic" do
  reference "shellslash_fix"
end

vim_config_mercurial

Installs a vim plugin from a mercurial source

Actions

Name Description default?
create Downloads and installs the plugin default
delete Deletes the plugin folder

Attributes

Attribute Description Type Default
repository URL to the repository String name
reference branch String, Integer tip

Examples

# Let's install gundo
vim_config_mercurial "http://bitbucket.org/sjl/gundo.vim"

# Let's install the "nonexistentexample" branch of gundo
vim_config_mercurial "http://bitbucket.org/sjl/gundo.vim" do
  reference "nonexistentexample"
end

Acknowledgments

It all clicked for me when I read Tammer Saleh's "The Modern Vim Config with Pathogen".

The article got me started with pathogen, using this script to manage my plugins.

All handling of the plugins from vim.org is copied and only slightly modified from that script, which was created by Daniel C.

Creating config files from Chef attributes was contributed by Alukardd.

Dependent cookbooks

git >= 0.0.0
mercurial >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

2.1.0 (2015-04-26)

  • Finally add "name" in metadata. Ready for use with Chef 12
  • You can now set your config files in Chef attributes thanks to Alukardd
  • Vundle git URL updated thanks to nathanph

2.0.0 (2013-12-27)

New features

  • Ability to let the cookbook manage your plugin folder, deleting all plugins that are not installed via this cookbook
  • Support for CentOS
  • Delete action for LWRPs

Backward compatibility breakages

  • Downloading plugins from the offical site has been deprecated. It will be removed in a future version, barring the shutdown of vim-scripts
  • Configuration file modes "concatenate" and "delegate" deprecated

1.0.0 (2012-12-29)

New features

  • Vundle added as plugin manager
  • Automatic installation of git / mercurial (as needed)
  • Read vimrc from wrapper cookbook

Backward compatibility breakages

  • Plugin manager now needs to be specified, will no longer fall back to pathogen if no option is given
  • git / mercurial will now be automatically installed, check README if you do not want this

0.0.3 (2012-12-28)

New features

  • Support for Mercurial plugin sources

Collaborator Number Metric
            

2.1.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

2.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

2.1.0 failed this metric

FC007: Ensure recipe dependencies are reflected in cookbook metadata: vim_config/recipes/_development.rb:39
FC007: Ensure recipe dependencies are reflected in cookbook metadata: vim_config/recipes/_development.rb:40
FC064: Ensure issues_url is set in metadata: vim_config/metadata.rb:1
FC065: Ensure source_url is set in metadata: vim_config/metadata.rb:1
FC066: Ensure chef_version is set in metadata: vim_config/metadata.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: vim_config/providers/git.rb:9
FC085: Resource using new_resource.updated_by_last_action to converge resource: vim_config/providers/git.rb:21
FC085: Resource using new_resource.updated_by_last_action to converge resource: vim_config/providers/mercurial.rb:10
FC085: Resource using new_resource.updated_by_last_action to converge resource: vim_config/providers/mercurial.rb:22
FC085: Resource using new_resource.updated_by_last_action to converge resource: vim_config/providers/vim.rb:10
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

2.1.0 passed this metric

Testing File Metric
            

2.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

2.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number