- name: ensure neovim configuration directories exist file: path: '{{ item }}' state: directory loop: - '{{ xdg_config_dir }}/nvim/' - '{{ xdg_config_dir }}/nvim/lua' - '{{ xdg_config_dir }}/nvim/after' - '{{ xdg_config_dir }}/nvim/after/ftplugin' - '{{ xdg_data_dir }}/nvim/site' - '{{ xdg_data_dir }}/nvim/site/pack' - '{{ xdg_data_dir }}/nvim/site/pack/default' - '{{ xdg_data_dir }}/nvim/site/pack/default/start' - name: remove old neovim packages file: path: '{{ item }}' state: absent loop: - '{{ xdg_data_dir }}/nvim/site/pack/default/start/catpuccin' - '{{ xdg_data_dir }}/nvim/site/pack/default/start/vim-colors-xcode' # Note that helptags may need to be regenerated (see `:h helptags`) - name: clone neovim packages git: repo: '{{ item.url }}' dest: '{{ xdg_data_dir }}/nvim/site/pack/default/start/{{ item.name }}' update: true version: '{{ item.version|default("HEAD") }}' force: true # some maintainers overwrite existing tags :/ loop: '{{ neovim_plugins }}' - name: install neovim node package become: true npm: name: neovim global: true - name: install language servers become: true package: name: '{{ item }}' state: present loop: '{{ language_servers | map(attribute="package") | list }}' when: ansible_facts['os_family'] == 'Archlinux' - name: install language servers on debian hosts become: true npm: name: '{{ item }}' global: true loop: '{{ language_servers | map(attribute="package") | list }}' when: ansible_facts['os_family'] == 'Debian' - name: remove old neovim configuration file file: path: '{{ xdg_config_dir }}/nvim/init.vim' state: absent - name: remove coc.nvim extension file: path: '{{ xdg_data_dir }}/nvim/site/pack/default/start/coc.nvim' state: absent - name: setup neovim configuration files template: dest: '{{ item.dest }}' src: '{{ item.src }}' loop: - { src: 'templates/nvim/ftplugin/bash.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/bash.lua', } - { src: 'templates/nvim/ftplugin/css.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/css.lua', } - { src: 'templates/nvim/ftplugin/html.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/html.lua', } - { src: 'templates/nvim/ftplugin/htmldjango.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/htmldjango.lua', } - { src: 'templates/nvim/ftplugin/javascript.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/javascript.lua', } - { src: 'templates/nvim/ftplugin/json.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/json.lua', } - { src: 'templates/nvim/ftplugin/lua.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/lua.lua', } - { src: 'templates/nvim/ftplugin/python.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/python.lua', } - { src: 'templates/nvim/ftplugin/scss.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/scss.lua', } - { src: 'templates/nvim/ftplugin/sh.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/sh.lua', } - { src: 'templates/nvim/ftplugin/yaml.lua.j2', dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/yaml.lua', } - { src: 'templates/nvim/init.lua.j2', dest: '{{ xdg_config_dir }}/nvim/init.lua' } - { src: 'templates/nvim/lua/auto-commands.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/auto-commands.lua', } - { src: 'templates/nvim/lua/keybindings.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/keybindings.lua', } - { src: 'templates/nvim/lua/lsp.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/lsp.lua', } - { src: 'templates/nvim/lua/nvim-cmp.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/nvim-cmp.lua', } - { src: 'templates/nvim/lua/options.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/options.lua', } - { src: 'templates/nvim/lua/tree-sitter.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/tree-sitter.lua', } - { src: 'templates/nvim/lua/git-signs.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/git-signs.lua', } - { src: 'templates/nvim/lua/lua-line.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/lua-line.lua', } - { src: 'templates/nvim/lua/telescope.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/_telescope.lua', } - { src: 'templates/nvim/lua/indent-blankline.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/indent-blankline.lua', } - { src: 'templates/nvim/lua/nvim-tree.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/_nvim-tree.lua', } - { src: 'templates/nvim/lua/colorscheme.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/colorscheme.lua', } - block: - name: create neovim install directory become: true file: state: directory path: '{{ neovim.install_path }}' owner: '{{ ansible_user_id }}' group: '{{ ansible_user_gid }}' - name: register the current neovim version command: argv: - '{{ neovim.install_path }}/bin/nvim' - '--version' register: neovim_stats ignore_errors: true - name: parse the current neovim version set_fact: neovim_installed_version: neovim_stats.stdout_lines[0] | regex_search('(v\d+\.\d+\.\d+)') when: neovim_stats.rc == 0 # TODO: verify checksum - name: download neovim {{ neovim.version }} get_url: url: 'https://github.com/neovim/neovim/releases/download/{{ neovim.version }}/nvim-linux64.tar.gz' dest: /tmp/nvim-linux64.tar.gz when: neovim_stats.rc > 0 or neovim_installed_version != neovim.version register: neovim_download - name: extract downloaded neovim version unarchive: src: /tmp/nvim-linux64.tar.gz dest: '{{ neovim.install_path }}' extra_opts: - '--strip-components=1' - '--show-stored-names' - '--overwrite' when: neovim_download.state == 'file' and (neovim_installed_version is undefined or neovim_installed_version != neovim.version) - name: add neovim to PATH become: true template: src: 'templates/nvim.profile.j2' dest: '/etc/profile.d/neovim.sh' when: ansible_facts['os_family'] == 'Debian'