setup-cockpit/roles/vim/tasks/main.yml

114 lines
2.8 KiB
YAML

---
- name: Install packages (Archlinux)
become: true
pacman:
name:
- vim
- python-pylint
- python-black
- ansible-lint
- base-devel
- flake8
- mypy
- shellcheck
- cmake
- clang
when:
ansible_facts['distribution'] == 'Archlinux'
- name: Install packages (Debian)
become: true
apt:
name:
- vim
- build-essential
- python3-dev
- pylint3
- ansible-lint
- flake8
- mypy
- shellcheck
- cmake
- clang
when:
ansible_facts['distribution'] == 'Debian'
# some Arch derivatives don't have the shellcheck package (arch32, archarm)
- name: Run shellcheck script
script: scripts/shellcheck_binary_fix.sh
register: shellcheck_script
when: ansible_facts['distribution'] == 'Archlinux'
changed_when: "'there is nothing to do' not in shellcheck_script.stdout"
- name: Make sure needed directories exist
file: path={{ item.path }} state=directory mode={{ item.mode }}
with_items:
- {path: '~/.vim', mode: '0755'}
- {path: '~/.vim/autoload', mode: '0750'}
- name: Check if colors is a symlink
stat:
path: ~/.vim/colors
follow: false
register: colors_dir
- name: Remove colors symlink
file:
path: ~/.vim/colors
state: absent
when: colors_dir.stat.exists and colors_dir.stat.islnk
- name: Copy configs
copy: src={{ item.src }} dest={{ item.dest }} mode=0644
with_items:
- {src: 'flake8', dest: '~/.flake8'}
- {src: 'pylintrc', dest: '~/.pylintrc'}
- {src: 'vimrc', dest: '~/.vimrc'}
- {src: 'colors', dest: '~/.vim/'}
- name: Check if vim-plug is installed
stat:
path: ~/.vim/autoload/plug.vim
register: vimplug
- name: Install vim-plug
get_url:
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
dest: ~/.vim/autoload/plug.vim
mode: 0644
when: not vimplug.stat.exists
- name: Upgrade vim-plug
command:
cmd: vim +PlugUpgrade +qall
stdin: '\n' # On error needs user input to continue
register: result
changed_when: "'vim-plug is already up-to-date' not in result.stdout"
- name: Install plugins
command:
cmd: vim +PlugInstall +qall
stdin: '\n' # On error needs user input to continue
register: result
changed_when: "'Resolving deltas' in result.stdout"
- name: Update plugins
command:
cmd: vim +PlugUpdate +qall
stdin: '\n' # On error needs user input to continue
register: result
changed_when: "'files changed' in result.stdout"
- name: Update Coc plugins
command:
cmd: vim +CocUpdate +qall
stdin: '\n' # On error needs user input to continue
register: result
changed_when: "'Updated' in result.stdout"
- name: Upgrade Black
command:
cmd: vim +BlackUpgrade +qall
stdin: '\n' # On error needs user input to continue
# TODO: changed_when
changed_when: false