71 lines
2.2 KiB
YAML
71 lines
2.2 KiB
YAML
---
|
|
- name: Check if nvim is installed
|
|
ansible.builtin.command: which nvim
|
|
changed_when: false
|
|
register: nvim_installed
|
|
failed_when: nvim_installed.rc > 1
|
|
|
|
- name: Request nvim install if nvim missing
|
|
ansible.builtin.set_fact:
|
|
nvim_install_needed: "{{ nvim_install_needed | default(true) }}"
|
|
when: nvim_installed.rc == 1
|
|
|
|
- name: Check if nvim needs update
|
|
ansible.builtin.shell: |
|
|
nvim --headless -c "lua print(vim.version().build)" +q
|
|
changed_when: false
|
|
register: nvim_installed_version
|
|
when: nvim_installed.rc == 0
|
|
|
|
- name: Get nvim remote version
|
|
# noqa risky-shell-pipe
|
|
ansible.builtin.shell: |
|
|
set pipefail
|
|
# yamllint disable-line rule:line-length
|
|
NVIM_HEAD_VER="$(git ls-remote --heads https://github.com/neovim/neovim.git master \
|
|
| awk '{ print $1 }' \
|
|
| head -c 7)"
|
|
echo $NVIM_HEAD_VER >&2
|
|
printf "%s\n" "${NVIM_HEAD_VER}"
|
|
changed_when: false
|
|
register: nvim_remote_version
|
|
when: nvim_installed.rc == 0
|
|
|
|
- name: Request nvim install if nvim update needed
|
|
ansible.builtin.set_fact:
|
|
nvim_install_needed: "{{ nvim_install_needed | default(true) }}"
|
|
when: nvim_installed.rc == 0 and nvim_remote_version.stdout != nvim_installed_version.stderr
|
|
|
|
- name: Handle neovim install for Unix systems
|
|
# TODO: Actually limit the targetting of this to Unix systems
|
|
when: nvim_install_needed is defined and nvim_install_needed is true
|
|
block:
|
|
- name: Create working directory
|
|
ansible.builtin.tempfile:
|
|
state: directory
|
|
prefix: neovim-checkout-
|
|
register: nvim_work_dir
|
|
|
|
- name: Checkout Neovim Master from Git
|
|
# noqa latest
|
|
ansible.builtin.git:
|
|
repo: "{{ nvim_git_url }}"
|
|
dest: "{{ nvim_work_dir.path }}"
|
|
depth: 1
|
|
force: true
|
|
update: true
|
|
|
|
- name: Build Neovim
|
|
community.general.make:
|
|
chdir: "{{ nvim_work_dir.path }}"
|
|
jobs: "{{ ansible_processor_cores or 1 }}"
|
|
params:
|
|
NUM_THREADS: "{{ ansible_processor_cores or 1 }}"
|
|
CMAKE_BUILD_TYPE: Release
|
|
|
|
- name: Install Neovim
|
|
become: true
|
|
community.general.make:
|
|
chdir: "{{ nvim_work_dir.path }}"
|
|
target: install
|