Use include_tasks in neovim role

This commit is contained in:
flyingscorpio@clevo 2023-05-12 08:46:45 +02:00
parent 32288b69ce
commit 3fc4a674b5
4 changed files with 207 additions and 172 deletions

View file

@ -0,0 +1,38 @@
---
- name: Install things with pacman
become: true
community.general.pacman:
name:
- neovim
- python-pynvim
- base-devel
- cmake
- clang
- npm
- ripgrep
- zathura
- zathura-pdf-mupdf
- rsync # for 'synchronize' module
- ansible-lint
- flake8
- mypy
- python-pylint
- python-black
- shellcheck
- bash-language-server
- jedi-language-server
- lua-language-server
- texlab
- rust-analyzer
- name: Install things with npm
become: true
community.general.npm:
name: "{{ item }}"
global: true
with_items:
- '@ansible/ansible-language-server'
- diagnostic-languageserver
- name: Include marksman tasks
ansible.builtin.include_tasks: marksman.yml

View file

@ -0,0 +1,142 @@
---
- name: Find latest neovim version
ansible.builtin.uri:
url: https://github.com/neovim/neovim/releases/latest
register: latest_http_content
- name: Set latest neovim version
ansible.builtin.set_fact:
neovim_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest neovim deb package
ansible.builtin.get_url:
url: "https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb"
checksum: "sha256:https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb.sha256sum"
dest: /tmp/nvim-linux64.deb
mode: 0644
- name: Install neovim deb package
become: true
ansible.builtin.apt:
deb: /tmp/nvim-linux64.deb
- name: Install things with apt
become: true
ansible.builtin.apt:
name:
- ansible-lint
- python3-pynvim
- build-essential
- python3-dev
- cmake
- clang
- clangd
- npm
- ripgrep
- zathura
- rsync # for 'synchronize' module
- flake8
- mypy
- pylint3
- shellcheck
- name: Install things with pip
ansible.builtin.pip:
name:
- jedi-language-server
extra_args: --user
- name: Install things with npm
become: true
community.general.npm:
name: "{{ item }}"
global: true
with_items:
- '@ansible/ansible-language-server'
- bash-language-server
- diagnostic-languageserver
- name: Find latest texlab version
ansible.builtin.uri:
url: https://github.com/latex-lsp/texlab/releases/latest
register: latest_http_content
- name: Set latest texlab version
ansible.builtin.set_fact:
texlab_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest texlab binary
ansible.builtin.unarchive:
src: "https://github.com/latex-lsp/texlab/releases/download/{{ texlab_version }}/texlab-{{ ansible_facts.architecture }}-linux.tar.gz"
remote_src: true
dest: ~/.local/bin/
mode: 0755
- name: Find latest lua-language-server version
ansible.builtin.uri:
url: https://github.com/luals/lua-language-server/releases/latest
register: latest_http_content
- name: Set latest lua-language-server version
ansible.builtin.set_fact:
lua_lsp_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Create tempdir for extracting lua-language-server
ansible.builtin.file:
path: /tmp/lualsp
state: directory
mode: 0755
changed_when: false
- name: Get latest lua-lsp archive
ansible.builtin.unarchive:
src: "https://github.com/luals/lua-language-server/releases/download/{{ lua_lsp_version }}/lua-language-server-{{ lua_lsp_version }}-linux-x64.tar.gz"
remote_src: true
dest: /tmp/lualsp/
changed_when: false
- name: Copy lua-lsp binary
ansible.builtin.copy:
src: /tmp/lualsp/bin/lua-language-server
remote_src: true
dest: ~/.local/bin/
mode: 0755
- name: Find latest rust-analyzer version
ansible.builtin.uri:
url: https://github.com/rust-lang/rust-analyzer/releases/latest
register: latest_http_content
- name: Set latest rust-analyzer version
ansible.builtin.set_fact:
rust_analyzer_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Create tempdir for extracting rust-analyzer
ansible.builtin.file:
path: /tmp/rust-analyzer
state: directory
mode: 0755
changed_when: false
- name: Get latest rust-analyzer compressed binary
ansible.builtin.get_url:
url: "https://github.com/rust-lang/rust-analyzer/releases/download/{{ rust_analyzer_version }}/rust-analyzer-x86_64-unknown-linux-gnu.gz"
dest: /tmp/rust-analyzer/
mode: 0644
changed_when: false
- name: Decompress rust-analyzer binary
ansible.builtin.command:
cmd: gzip -fd /tmp/rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu.gz
chdir: /tmp/rust-analyzer
changed_when: false
- name: Copy rust-analyzer binary
ansible.builtin.copy:
src: /tmp/rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
remote_src: true
dest: ~/.local/bin/rust-analyzer
mode: 0755
- name: Include marksman tasks
ansible.builtin.include_tasks: marksman.yml

View file

@ -5,191 +5,31 @@
register: init_vim
failed_when: init_vim.stat.exists
- name: Install (Archlinux)
- name: Include Archlinux tasks
ansible.builtin.include_tasks: archlinux.yml
when:
ansible_facts['distribution'] == 'Archlinux'
block:
- name: Install things with pacman (Archlinux)
become: true
community.general.pacman:
name:
- neovim
- python-pynvim
- base-devel
- cmake
- clang
- npm
- ripgrep
- zathura
- zathura-pdf-mupdf
- rsync # for 'synchronize' module
- ansible-lint
- flake8
- mypy
- python-pylint
- python-black
- shellcheck
- bash-language-server
- jedi-language-server
- lua-language-server
- texlab
- rust-analyzer
- name: Install things with npm (Archlinux)
become: true
community.general.npm:
name: "{{ item }}"
global: true
with_items:
- '@ansible/ansible-language-server'
- diagnostic-languageserver
- name: Install (Debian)
- name: Include Debian tasks
ansible.builtin.include_tasks: debian.yml
when:
ansible_facts['distribution'] == 'Debian'
block:
- name: Find latest neovim version
ansible.builtin.uri:
url: https://github.com/neovim/neovim/releases/latest
register: latest_http_content
- name: Set latest neovim version
ansible.builtin.set_fact:
neovim_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest neovim deb package
ansible.builtin.get_url:
url: "https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb"
checksum: "sha256:https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb.sha256sum"
dest: /tmp/nvim-linux64.deb
mode: 0644
- name: Install neovim deb package (Debian)
become: true
ansible.builtin.apt:
deb: /tmp/nvim-linux64.deb
- name: Install things with apt (Debian)
become: true
ansible.builtin.apt:
name:
- ansible-lint
- python3-pynvim
- build-essential
- python3-dev
- cmake
- clang
- clangd
- npm
- ripgrep
- zathura
- rsync # for 'synchronize' module
- flake8
- mypy
- pylint3
- shellcheck
- name: Install things with pip (Debian)
ansible.builtin.pip:
name:
- jedi-language-server
extra_args: --user
- name: Install things with npm (Debian)
become: true
community.general.npm:
name: "{{ item }}"
global: true
with_items:
- '@ansible/ansible-language-server'
- bash-language-server
- diagnostic-languageserver
- name: Find latest texlab version
ansible.builtin.uri:
url: https://github.com/latex-lsp/texlab/releases/latest
register: latest_http_content
- name: Set latest texlab version
ansible.builtin.set_fact:
texlab_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest texlab binary
ansible.builtin.unarchive:
src: "https://github.com/latex-lsp/texlab/releases/download/{{ texlab_version }}/texlab-{{ ansible_facts.architecture }}-linux.tar.gz"
remote_src: true
dest: ~/.local/bin/
mode: 0755
- name: Find latest lua-language-server version
ansible.builtin.uri:
url: https://github.com/luals/lua-language-server/releases/latest
register: latest_http_content
- name: Set latest lua-language-server version
ansible.builtin.set_fact:
lua_lsp_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Create tempdir for extracting lua-language-server
ansible.builtin.file:
path: /tmp/lualsp
state: directory
mode: 0755
changed_when: false
- name: Get latest lua-lsp archive
ansible.builtin.unarchive:
src: "https://github.com/luals/lua-language-server/releases/download/{{ lua_lsp_version }}/lua-language-server-{{ lua_lsp_version }}-linux-x64.tar.gz"
remote_src: true
dest: /tmp/lualsp/
changed_when: false
- name: Copy lua-lsp binary
ansible.builtin.copy:
src: /tmp/lualsp/bin/lua-language-server
remote_src: true
dest: ~/.local/bin/
mode: 0755
- name: Find latest rust-analyzer version
ansible.builtin.uri:
url: https://github.com/rust-lang/rust-analyzer/releases/latest
register: latest_http_content
- name: Set latest rust-analyzer version
ansible.builtin.set_fact:
rust_analyzer_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Create tempdir for extracting rust-analyzer
ansible.builtin.file:
path: /tmp/rust-analyzer
state: directory
mode: 0755
changed_when: false
- name: Get latest rust-analyzer compressed binary
ansible.builtin.get_url:
url: "https://github.com/rust-lang/rust-analyzer/releases/download/{{ rust_analyzer_version }}/rust-analyzer-x86_64-unknown-linux-gnu.gz"
dest: /tmp/rust-analyzer/
mode: 0644
changed_when: false
- name: Decompress rust-analyzer binary
ansible.builtin.command:
cmd: gzip -fd /tmp/rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu.gz
chdir: /tmp/rust-analyzer
changed_when: false
- name: Copy rust-analyzer binary
ansible.builtin.copy:
src: /tmp/rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
remote_src: true
dest: ~/.local/bin/rust-analyzer
mode: 0755
- name: Grab marksman (LSP server) binary
block:
- name: Find latest marksman version
ansible.builtin.uri:
url: https://github.com/artempyanykh/marksman/releases/latest
register: latest_http_content
- name: Set latest marksman version
ansible.builtin.set_fact:
marksman_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest marksman binary
ansible.builtin.get_url:
url: "https://github.com/artempyanykh/marksman/releases/download/{{ marksman_version }}/marksman-linux"
dest: ~/.local/bin/marksman
mode: 0755
- name: Make sure needed directories exist
ansible.builtin.file: path={{ item.path }} state=directory mode={{ item.mode }}
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: "{{ item.mode }}"
with_items:
- {path: '~/.config/nvim', mode: '0755'}
- {path: '~/.config/nvim/lua', mode: '0755'}
- {path: '~/.config/nvim/after', mode: '0755'}
- name: Copy configs
ansible.builtin.copy: src={{ item.src }} dest={{ item.dest }} mode=0644
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
with_items:
- {src: 'init.lua', dest: '~/.config/nvim/init.lua'}
- {src: 'flake8', dest: '~/.flake8'}

View file

@ -0,0 +1,15 @@
---
- name: Find latest marksman version
ansible.builtin.uri:
url: https://github.com/artempyanykh/marksman/releases/latest
register: latest_http_content
- name: Set latest marksman version
ansible.builtin.set_fact:
marksman_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest marksman binary
ansible.builtin.get_url:
url: "https://github.com/artempyanykh/marksman/releases/download/{{ marksman_version }}/marksman-linux"
dest: ~/.local/bin/marksman
mode: 0755