This repository has been archived on 2024-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
setup/roles/neovim/tasks/main.yml

130 lines
3.1 KiB
YAML
Raw Normal View History

2023-06-12 13:05:00 +00:00
- name: Check if neovim is installed
command:
cmd: "which nvim"
failed_when: false
changed_when: false
register: which_nvim
- name: Check local neovim version
command:
cmd: "nvim --version"
changed_when: false
check_mode: false
register: current_neovim_version
when: which_nvim.rc == 0
- name: Set local nvim version as fact if present
set_fact:
current_neovim_version: "{{ current_neovim_version.stdout_lines | default(['no version']) | first }}"
when: which_nvim.rc == 0
- name: Set local nvim version as fact if not present
set_fact:
current_neovim_version: "error"
when: which_nvim.rc != 0
- name: Get latest release version
uri:
url: "https://api.github.com/repos/neovim/neovim/releases/latest"
changed_when: false
check_mode: false
register: latest_stable_neovim_version
- name: Set latest nvim stable version as fact
set_fact:
latest_stable_neovim_version: "{{ latest_stable_neovim_version.json.body.splitlines()[1] }}"
- name: Diff latest release and currently installed
ansible.builtin.set_fact:
neovim_up_to_date: "{{ latest_stable_neovim_version == current_neovim_version }}"
- name: Build neovim
when: not neovim_up_to_date
block:
- name: Pull neovim github repository
git:
repo: "https://github.com/neovim/neovim.git"
dest: "$HOME/repos/neovim"
update: true
version: stable
- name: Compile neovim from source
make:
chdir: "$HOME/repos/neovim"
target: all
params:
CMAKE_BUILD_TYPE: RelWithDebInfo
- name: Install neovim from source
make:
chdir: "/home/{{ ansible_user_id }}/repos/neovim"
target: install
become: true
- name: Remove neovim git repo
file:
path: "$HOME/repos/neovim"
state: absent
- name: Create configuration directory
file:
path: ~/.config/nvim
state: directory
2023-06-12 13:05:00 +00:00
- name: Copy init.lua
copy:
src: "{{ role_path }}/files/init.lua"
dest: ~/.config/nvim/init.lua
2023-06-12 13:05:00 +00:00
- name: Create plugin directory
file:
path: ~/.config/nvim/plugin
state: directory
recurse: true
2023-06-12 13:05:00 +00:00
- name: Copy plugin configuration files
copy:
src: "{{ role_path }}/files/plugin/"
dest: ~/.config/nvim/plugin
2023-06-12 13:05:00 +00:00
- name: Create lua directory
file:
path: ~/.config/nvim/lua
state: directory
recurse: true
2023-06-12 13:05:00 +00:00
- name: Copy lua files
copy:
src: "{{ role_path }}/files/lua/"
dest: ~/.config/nvim/lua
2023-06-12 13:05:00 +00:00
2023-01-20 21:18:32 +00:00
- name: Install python-lsp-server
pip:
name:
- "python-lsp-server[all]"
2023-06-12 13:05:00 +00:00
2023-02-13 12:47:25 +00:00
- name: Clone packer repository
git:
repo: https://github.com/wbthomason/packer.nvim
depth: 1
dest: ~/.local/share/nvim/site/pack/packer/start/packer.nvim
2023-06-12 13:05:00 +00:00
2023-01-23 13:02:52 +00:00
- name: Install terraform-ls
2023-02-11 20:14:07 +00:00
become: true
2023-01-23 13:02:52 +00:00
apt:
pkg: terraform-ls
2023-06-12 13:05:00 +00:00
2023-02-01 17:46:38 +00:00
- name: Set default applications
ini_file:
path: ~/.config/mimeapps.list
section: "Default Applications"
option: "{{ item }}"
value: "nvim.desktop"
no_extra_spaces: true
2023-02-01 17:46:38 +00:00
loop: "{{ default_apps }}"
2023-06-12 13:05:00 +00:00
2023-03-04 13:28:09 +00:00
- name: Copy neovim.bashrc
copy:
src: "{{ role_path }}/files/neovim.bashrc"
dest: ~/.bashrc.d/neovim.bashrc