class qdii::vim {
  File {
    ensure => file,
    owner  => 'qdii',
    group  => 'qdii',
    mode   => '0600',
  }
  package { 'vim':
    ensure => 'latest',
    name => 'vim',
  }
  file { 'neovim_config':
    ensure => directory,
    path   => "$qdii::homedir/.config/nvim",
  }

  if $qdii::at_work {
    file { 'vimrc_google':
      ensure =>  file,
      path   => "$qdii::homedir/.vimrc",
      source => 'puppet:///modules/qdii/dotfiles/vimrc_google',
    }
    file { 'hgrc_google':
      ensure =>  file,
      path   => "$qdii::homedir/.hgrc",
      source => 'puppet:///modules/qdii/dotfiles/hgrc_google',
    }
    file { 'neovim_vimrc_google':
      ensure  => file,
      path    => "$qdii::homedir/.config/nvim/init.vim",
      source  => 'puppet:///modules/qdii/dotfiles/vimrc_google',
      require => File['neovim_config'],
    }
  } else {
    file { 'vimrc':
      ensure => file,
      path   => "$qdii::homedir/.vimrc",
      source => 'puppet:///modules/qdii/dotfiles/vimrc',
    }
    file { 'neovim_vimrc':
      ensure => file,
      path   => "$qdii::homedir/.config/nvim/init.vim",
      source => 'puppet:///modules/qdii/dotfiles/vimrc',
      require => File['neovim_config'],
    }
  }
  if $::operatingsystem == 'Archlinux' {
    package { 'powerline-vim':
      ensure => 'latest',
      name   => 'powerline-vim'
    }
  }
  file { 'vim_config_directory':
    ensure => directory,
    path   => "$qdii::homedir/.vim",
    owner  => 'qdii',
  }
  -> file { 'vim_bundle_config_directory':
    ensure => directory,
    path   => "$qdii::homedir/.vim/bundle",
    owner  => 'qdii',
  }
  -> file { 'vundle_directory':
    ensure => directory,
    path   => "$qdii::homedir/.vim/bundle/Vundle.vim",
    owner  => 'qdii',
  }
  -> vcsrepo { "${qdii::homedir}/.vim/bundle/Vundle.vim":
    ensure   => latest,
    provider => git,
    source   => 'https://github.com/VundleVim/Vundle.vim.git',
    user     => 'qdii',
  }
  file { 'vim_root_config_directory':
    ensure => directory,
    path   => "/root/.vim",
    owner  => 'root',
  }
  -> file { 'vim_root_bundle_config_directory':
    ensure => directory,
    path   => "/root/.vim/bundle",
    owner  => 'root',
  }
  -> file { 'vundle_root_directory':
    ensure => directory,
    path   => "/root/.vim/bundle/Vundle.vim",
    owner  => 'root',
  }
  -> vcsrepo { '/root/.vim/bundle/Vundle.vim':
    ensure   => latest,
    provider => git,
    source   => 'https://github.com/VundleVim/Vundle.vim.git',
    user     => 'root',
  }
}
