---
- hosts: localhost
  vars:
    repo: https://github.com/erynofwales/dotfiles.git
    local_repo: ~/.dotfiles
    dotfiles:
      - Xdefaults
      - emacs
      - emacs.d
      - env
      - gdbinit
      - gitconfig
      - gitignore
      - gvimrc
      - hgrc
      - indent.pro
      - muttrc
      - nethackrc
      - profile
      - rc
      - screenrc
    nvim_conifg: ~/.config/nvim
    vim_bundles:
      Vundle.vim: https://github.com/gmarik/Vundle.vim.git
  tasks:
    - name: Pull dotfiles
      git: repo={{ repo }} dest={{ local_repo }}

    - name: Link dotfiles
      file: src={{ local_repo }}/{{ item }} dest=~/.{{ item }} state=link
      with_items: "{{ dotfiles }}"

    - name: Link ~/bin
      file: src={{ local_repo }}/bin dest=~/bin state=link

    # Don't show last login when I open a terminal
    - name: Touch .hushlogin
      file: path=~/.hushlogin state=touch

    # Setup neovim
    - name: Create ~/.config
      file: path=~/.config state=directory
    - name: Symlink vim dir for neovim
      file: src={{ local_repo }}/vim dest={{ nvim_config }}
    - name: Symlink vimrc for neovim
      file: src={{ local_repo }}/vimrc dest={{ nvim_config }}/init.vim

    # Setup vim bundles
    - name: Get Vim bundles
      git: repo={{ item[1] }} dest={{ local_repo }}/vim/bundle/{{ item[0] }}
      with_items: "{{ vim_bundles }}"
    - name: Install bundles registered in vim
      command: vim +PluginInstall +qall
