Dot_Files/roles/nvim/tasks/install-nvim.yml

73 lines
2.2 KiB
YAML
Raw Normal View History

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
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
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()
- 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
2022-08-01 23:41:47 -05:00
- 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
2022-08-01 23:41:47 -05:00
- name: Build Neovim
community.general.make:
chdir: "{{ nvim_work_dir.path }}"
jobs: "{{ ansible_processor_cores // 2 }}"
params:
NUM_THREADS: "{{ ansible_processor_cores // 2 }}"
CMAKE_BUILD_TYPE: Release
2022-08-01 21:03:44 -05:00
- name: Install Neovim
become: true
community.general.make:
chdir: "{{ nvim_work_dir.path }}"
target: install