development/tasks/debian/neovim.yml

58 lines
1.7 KiB
YAML

---
- name: Install language servers on debian hosts
become: true
community.general.npm:
name: "{{ item }}"
global: true
loop: '{{ language_servers | map(attribute="package") | list }}'
- name: Create neovim install directory
become: true
ansible.builtin.file:
state: directory
path: "{{ neovim.install_path }}"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
mode: "0755"
- name: Register the current neovim version
ansible.builtin.command:
argv:
- "{{ neovim.install_path }}/bin/nvim"
- "--version"
register: neovim_stats
changed_when: false
ignore_errors: true
- name: Parse the current neovim version
ansible.builtin.set_fact:
neovim_installed_version: neovim_stats.stdout_lines[0] | regex_search('(v\d+\.\d+\.\d+)')
when: neovim_stats.rc == 0
- name: Download neovim {{ neovim.version }}
ansible.builtin.get_url:
url: "https://github.com/neovim/neovim/releases/download/{{ neovim.version }}/nvim-linux-x86_64.tar.gz"
dest: /tmp/nvim-linux64.tar.gz
mode: "0755"
checksum: "{{ neovim.download_checksum }}"
when: neovim_stats.rc > 0 or neovim_installed_version != neovim.version
register: neovim_download
- name: Extract downloaded neovim version
ansible.builtin.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
ansible.builtin.template:
src: "templates/debian/nvim.profile.j2"
dest: "/etc/profile.d/neovim.sh"
mode: "0755"