2022-08-01 21:03:44 -05:00
|
|
|
---
|
2022-08-01 23:41:47 -05:00
|
|
|
- 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
|
|
|
|
# noqa risky-shell-pipe
|
|
|
|
ansible.builtin.shell: |
|
|
|
|
set pipefail
|
2022-11-11 14:22:59 -06:00
|
|
|
nvim --version | head -n 1 | awk -F '-' '{ print $NF }' | cut -d '+' -f2 | cut -c2-
|
2022-08-01 23:41:47 -05:00
|
|
|
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
|
2023-06-24 22:20:43 -05:00
|
|
|
NVIM_HEAD_VER="$(git ls-remote --heads https://github.com/neovim/neovim.git master \
|
2022-08-01 23:41:47 -05:00
|
|
|
| awk '{ print $1 }' \
|
|
|
|
| head -c 9)"
|
|
|
|
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 | default() != nvim_installed_version.stdout | default()
|
|
|
|
|
2023-06-24 22:20:43 -05:00
|
|
|
- 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
|
2022-08-03 02:06:23 -05:00
|
|
|
block:
|
|
|
|
- name: Create working directory
|
|
|
|
ansible.builtin.tempfile:
|
|
|
|
state: directory
|
2023-06-24 22:20:43 -05:00
|
|
|
prefix: neovim-checkout-
|
2022-08-03 02:06:23 -05:00
|
|
|
register: nvim_work_dir
|
2022-08-01 23:41:47 -05:00
|
|
|
|
2023-06-24 22:20:43 -05:00
|
|
|
- name: Checkout Neovim Master from Git
|
|
|
|
# noqa latest
|
|
|
|
ansible.builtin.git:
|
|
|
|
repo: "{{ nvim_git_url }}"
|
|
|
|
dest: "{{ nvim_work_dir.path }}"
|
2023-08-21 22:43:24 -05:00
|
|
|
depth: 1
|
2023-06-24 22:20:43 -05:00
|
|
|
force: true
|
|
|
|
update: true
|
2022-08-01 23:41:47 -05:00
|
|
|
|
2023-06-24 22:20:43 -05:00
|
|
|
- name: Build Neovim
|
|
|
|
community.general.make:
|
|
|
|
chdir: "{{ nvim_work_dir.path }}"
|
2023-08-21 22:43:24 -05:00
|
|
|
jobs: "{{ ansible_processor_cores // 2 }}"
|
2023-06-24 22:20:43 -05:00
|
|
|
params:
|
2023-08-21 22:43:24 -05:00
|
|
|
NUM_THREADS: "{{ ansible_processor_cores // 2 }}"
|
2023-06-24 22:20:43 -05:00
|
|
|
CMAKE_BUILD_TYPE: Release
|
2022-08-01 21:03:44 -05:00
|
|
|
|
2023-06-24 22:20:43 -05:00
|
|
|
- name: Install Neovim
|
2022-08-03 02:06:23 -05:00
|
|
|
become: true
|
2023-06-24 22:20:43 -05:00
|
|
|
community.general.make:
|
|
|
|
chdir: "{{ nvim_work_dir.path }}"
|
|
|
|
target: install
|