---
- name: Install vim
  become: true
  apt:
    name: vim-nox
    state: installed

- name: Create directories for backup and temporary files
  file:
    path: "~/.vim/{{ item }}"
    state: directory
  with_items:
    - tmp
    - backup
    - autoload
    - colors

- name: Install solarized colorscheme
  get_url:
    url: https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim
    dest: ~/.vim/colors/solarized.vim

- name: Install vim-plug plugin manager
  get_url:
    url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    dest: ~/.vim/autoload/plug.vim

- name: Symlink vimrc
  file:
    src: "{{ role_path }}/files/vimrc"
    dest: "~/.vimrc"
    state: link

- name: Install plugins
  command: vim +PlugInstall +qall

---
- name: Install vim
  become: true
  apt:
    name: vim-nox
    state: installed

- name: Set vim as default editor
  become: true
  command: update-alternatives --set editor /usr/bin/vim.nox # TODO only on debian

- name: Create directories for backup and temporary files
  file:
    path: "~/.vim/{{ item }}"
    state: directory
  with_items:
    - tmp
    - backup
    - autoload
    - colors

- name: Install solarized colorscheme
  get_url:
    url: https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim
    dest: ~/.vim/colors/solarized.vim

- name: Install vim-plug plugin manager
  get_url:
    url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    dest: ~/.vim/autoload/plug.vim

- name: Symlink vimrc
  file:
    src: "{{ role_path }}/files/vimrc"
    dest: "~/.vimrc"
    state: link

- name: Install plugins
  command: vim +PlugInstall +qall

Set vim as default editor
Set vim as default editor
