Extract neovim from prebuilt archives for debian hosts

This commit is contained in:
Sonny Bakker 2024-08-10 16:08:06 +02:00
parent b53e644f7e
commit deec1581c5
4 changed files with 126 additions and 22 deletions

View file

@ -27,14 +27,21 @@
name: neovim
global: true
# Note that the "python-lsp-server", "python-lsp-ruff" and "neovim" python
# packages should be installed to the corresponding virtualenv as well.
- name: install language servers
become: true
package:
name: '{{ item }}'
state: present
loop: '{{ language_servers }}'
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:
@ -141,3 +148,45 @@
src: 'templates/nvim/lua/indent-blankline.lua.j2',
dest: '{{ xdg_config_dir }}/nvim/lua/indent-blankline.lua',
}
- block:
- name: register the current version
command:
argv:
- '{{ neovim.install_path }}/bin/nvim'
- '--version'
register: neovim_stats
- name: parse the current version
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 }}
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'
when: neovim_download.rc == 0
- name: set updated PATH variable
set_fact:
neovim_new_path: '{{ neovim.install_path }}/bin'
- name: Update PATH to include {{ neovim_new_path }}
ansible.builtin.replace:
path: '~/.profile'
regexp: '^PATH="{{ ansible_env.PATH }}"'
replace: 'PATH="{{ ansible_env.PATH }}:{{ neovim_new_path }}"'
when: neovim_new_path not in ansible_env.PATH
when: ansible_facts['os_family'] == 'Debian'