diff --git a/roles/vim/files/colors/apprentice.vim b/roles/neovim/files/colors/apprentice.vim similarity index 100% rename from roles/vim/files/colors/apprentice.vim rename to roles/neovim/files/colors/apprentice.vim diff --git a/roles/vim/files/colors/monokai.vim b/roles/neovim/files/colors/monokai.vim similarity index 100% rename from roles/vim/files/colors/monokai.vim rename to roles/neovim/files/colors/monokai.vim diff --git a/roles/vim/files/colors/wombat256.vim b/roles/neovim/files/colors/wombat256.vim similarity index 100% rename from roles/vim/files/colors/wombat256.vim rename to roles/neovim/files/colors/wombat256.vim diff --git a/roles/vim/files/flake8 b/roles/neovim/files/flake8 similarity index 100% rename from roles/vim/files/flake8 rename to roles/neovim/files/flake8 diff --git a/roles/vim/files/pylintrc b/roles/neovim/files/pylintrc similarity index 100% rename from roles/vim/files/pylintrc rename to roles/neovim/files/pylintrc diff --git a/roles/vim/files/vimrc b/roles/neovim/files/vimrc similarity index 100% rename from roles/vim/files/vimrc rename to roles/neovim/files/vimrc diff --git a/roles/neovim/meta/main.yml b/roles/neovim/meta/main.yml index 4a6f3c0..edef5f0 100644 --- a/roles/neovim/meta/main.yml +++ b/roles/neovim/meta/main.yml @@ -1,4 +1,3 @@ --- dependencies: - role: check-sudo - - role: vim diff --git a/roles/vim/scripts/shellcheck_binary_fix.sh b/roles/neovim/scripts/shellcheck_binary_fix.sh similarity index 100% rename from roles/vim/scripts/shellcheck_binary_fix.sh rename to roles/neovim/scripts/shellcheck_binary_fix.sh diff --git a/roles/neovim/tasks/main.yml b/roles/neovim/tasks/main.yml index 504fcbd..795fd6b 100644 --- a/roles/neovim/tasks/main.yml +++ b/roles/neovim/tasks/main.yml @@ -3,8 +3,19 @@ become: true pacman: name: + - vim - python-pynvim - neovim + - python-pylint + - python-black + - ansible-lint + - base-devel + - flake8 + - mypy + - shellcheck + - cmake + - clang + - npm when: ansible_facts['distribution'] == 'Archlinux' @@ -12,11 +23,29 @@ become: true apt: name: + - vim - python3-pynvim - neovim + - build-essential + - python3-dev + - pylint3 + - ansible-lint + - flake8 + - mypy + - shellcheck + - cmake + - clang + - npm 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: Install neovim with pip for Debian pip: name: neovim @@ -34,7 +63,74 @@ path: ~/.config/nvim state: directory -- name: Copy neovim config - copy: - src: init.vim - dest: ~/.config/nvim/init.vim +- 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 }} + with_items: + - {src: 'init.vim', dest: '~/.config/nvim/init.vim'} + - {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 + command: curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + 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 + register: result + # TODO: changed_when + +- name: Install hdl-checker + pip: + name: hdl-checker + extra_args: --user + register: result + changed_when: "'Running setup.py install for hdl-checker' in result.stdout" diff --git a/roles/vim/meta/main.yml b/roles/vim/meta/main.yml deleted file mode 100644 index edef5f0..0000000 --- a/roles/vim/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: check-sudo diff --git a/roles/vim/tasks/main.yml b/roles/vim/tasks/main.yml deleted file mode 100644 index 8fcc397..0000000 --- a/roles/vim/tasks/main.yml +++ /dev/null @@ -1,112 +0,0 @@ ---- -- name: Install packages (Archlinux) - become: true - pacman: - name: - - gvim - - ansible-lint - - python-pylint - - python-black - - base-devel - - flake8 - - mypy - - shellcheck - - cmake - - clang - - npm # for coc - when: ansible_facts['distribution'] == 'Archlinux' - -- name: Install packages (Debian) - become: true - apt: - name: - - vim-gtk - - pylint3 - - build-essential - - ansible-lint - - python3-dev - - flake8 - - mypy - - shellcheck - - cmake - - clang - - npm # for coc - when: ansible_facts['distribution'] == 'Debian' - -# some Arch derivatives don't have the 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: 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 }} - 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 - command: curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - 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 - register: result - # TODO: changed_when - -- name: Install hdl-checker - pip: - name: hdl-checker - extra_args: --user - register: result - changed_when: "'Running setup.py install for hdl-checker' in result.stdout"