parent
5aa08aef39
commit
199f40b0ea
4 changed files with 176 additions and 145 deletions
|
|
@ -24,9 +24,11 @@
|
||||||
manager: pacman
|
manager: pacman
|
||||||
- import_tasks: 'tasks/aur.yml'
|
- import_tasks: 'tasks/aur.yml'
|
||||||
- import_tasks: 'tasks/docker.yml'
|
- import_tasks: 'tasks/docker.yml'
|
||||||
|
|
||||||
- name: setup python versions
|
- name: setup python versions
|
||||||
include_tasks: 'tasks/python.yml'
|
include_tasks: 'tasks/python.yml'
|
||||||
loop: '{{ python_versions }}'
|
loop: '{{ python_versions }}'
|
||||||
|
|
||||||
- import_tasks: 'tasks/nvm.yml'
|
- import_tasks: 'tasks/nvm.yml'
|
||||||
vars_files:
|
vars_files:
|
||||||
- 'vars/main.yml'
|
- 'vars/main.yml'
|
||||||
|
|
|
||||||
277
tasks/neovim.yml
277
tasks/neovim.yml
|
|
@ -1,7 +1,8 @@
|
||||||
- name: ensure neovim configuration directories exist
|
- name: Ensure neovim configuration directories exist
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
loop:
|
loop:
|
||||||
- '{{ xdg_config_dir }}/nvim/'
|
- '{{ xdg_config_dir }}/nvim/'
|
||||||
- '{{ xdg_config_dir }}/nvim/lua'
|
- '{{ xdg_config_dir }}/nvim/lua'
|
||||||
|
|
@ -12,8 +13,8 @@
|
||||||
- '{{ xdg_data_dir }}/nvim/site/pack/default'
|
- '{{ xdg_data_dir }}/nvim/site/pack/default'
|
||||||
- '{{ xdg_data_dir }}/nvim/site/pack/default/start'
|
- '{{ xdg_data_dir }}/nvim/site/pack/default/start'
|
||||||
|
|
||||||
- name: remove old neovim packages
|
- name: Remove old neovim packages
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
|
|
@ -21,185 +22,171 @@
|
||||||
- '{{ xdg_data_dir }}/nvim/site/pack/default/start/vim-colors-xcode'
|
- '{{ xdg_data_dir }}/nvim/site/pack/default/start/vim-colors-xcode'
|
||||||
|
|
||||||
# Note that helptags may need to be regenerated (see `:h helptags`)
|
# Note that helptags may need to be regenerated (see `:h helptags`)
|
||||||
- name: clone neovim packages
|
- name: Clone neovim packages
|
||||||
git:
|
ansible.builtin.git:
|
||||||
repo: '{{ item.url }}'
|
repo: '{{ item.url }}'
|
||||||
dest: '{{ xdg_data_dir }}/nvim/site/pack/default/start/{{ item.name }}'
|
dest: '{{ xdg_data_dir }}/nvim/site/pack/default/start/{{ item.name }}'
|
||||||
update: true
|
update: true
|
||||||
version: '{{ item.version|default("HEAD") }}'
|
version: '{{ item.version | default("HEAD") }}'
|
||||||
force: true # some maintainers overwrite existing tags :/
|
force: true # some maintainers overwrite existing tags :/
|
||||||
loop: '{{ neovim_plugins }}'
|
loop: '{{ neovim_plugins }}'
|
||||||
|
|
||||||
- name: install neovim node package
|
- name: Install neovim node package
|
||||||
become: true
|
become: true
|
||||||
npm:
|
community.general.npm:
|
||||||
name: neovim
|
name: neovim
|
||||||
global: true
|
global: true
|
||||||
|
|
||||||
- name: install language servers
|
- name: Install language servers
|
||||||
become: true
|
become: true
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
state: present
|
state: present
|
||||||
loop: '{{ language_servers | map(attribute="package") | list }}'
|
loop: '{{ language_servers | map(attribute="package") | list }}'
|
||||||
when: ansible_facts['os_family'] == 'Archlinux'
|
when: ansible_facts['os_family'] == 'Archlinux'
|
||||||
|
|
||||||
- name: install language servers on debian hosts
|
- name: Install language servers on debian hosts
|
||||||
become: true
|
become: true
|
||||||
npm:
|
community.general.npm:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
global: true
|
global: true
|
||||||
loop: '{{ language_servers | map(attribute="package") | list }}'
|
loop: '{{ language_servers | map(attribute="package") | list }}'
|
||||||
when: ansible_facts['os_family'] == 'Debian'
|
when: ansible_facts['os_family'] == 'Debian'
|
||||||
|
|
||||||
- name: remove old neovim configuration file
|
- name: Remove old neovim configuration file
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ xdg_config_dir }}/nvim/init.vim'
|
path: '{{ xdg_config_dir }}/nvim/init.vim'
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: remove coc.nvim extension
|
- name: Remove coc.nvim extension
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ xdg_data_dir }}/nvim/site/pack/default/start/coc.nvim'
|
path: '{{ xdg_data_dir }}/nvim/site/pack/default/start/coc.nvim'
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: setup neovim configuration files
|
- name: Setup neovim configuration files
|
||||||
template:
|
ansible.builtin.template:
|
||||||
dest: '{{ item.dest }}'
|
dest: '{{ item.dest }}'
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
|
mode: '0755'
|
||||||
loop:
|
loop:
|
||||||
- {
|
- src: 'templates/nvim/ftplugin/bash.lua.j2'
|
||||||
src: 'templates/nvim/ftplugin/bash.lua.j2',
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/bash.lua'
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/bash.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/css.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/css.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/html.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/html.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/htmldjango.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/htmldjango.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/javascript.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/javascript.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/json.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/json.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/lua.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/lua.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/python.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/python.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/scss.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/scss.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/sh.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/sh.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/ftplugin/yaml.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/yaml.lua',
|
|
||||||
}
|
|
||||||
- { src: 'templates/nvim/init.lua.j2', dest: '{{ xdg_config_dir }}/nvim/init.lua' }
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/lsp.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/lsp.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/options.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/options.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/tree-sitter.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/tree-sitter.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/git-signs.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/git-signs.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/lua-line.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/lua-line.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/telescope.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/_telescope.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/indent-blankline.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/indent-blankline.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/nvim-tree.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/_nvim-tree.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/colorscheme.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/colorscheme.lua',
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
src: 'templates/nvim/lua/source-link.lua.j2',
|
|
||||||
dest: '{{ xdg_config_dir }}/nvim/lua/_source-link.lua',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
- src: 'templates/nvim/ftplugin/css.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/css.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/ftplugin/html.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/html.lua'
|
||||||
|
- src: 'templates/nvim/ftplugin/htmldjango.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/htmldjango.lua'
|
||||||
|
|
||||||
- block:
|
- src: 'templates/nvim/ftplugin/javascript.lua.j2'
|
||||||
- name: create neovim install directory
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/javascript.lua'
|
||||||
become: true
|
|
||||||
file:
|
|
||||||
state: directory
|
|
||||||
path: '{{ neovim.install_path }}'
|
|
||||||
owner: '{{ ansible_user_id }}'
|
|
||||||
group: '{{ ansible_user_gid }}'
|
|
||||||
|
|
||||||
- name: register the current neovim version
|
- src: 'templates/nvim/ftplugin/json.lua.j2'
|
||||||
command:
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/json.lua'
|
||||||
argv:
|
|
||||||
- '{{ neovim.install_path }}/bin/nvim'
|
|
||||||
- '--version'
|
|
||||||
register: neovim_stats
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: parse the current neovim version
|
- src: 'templates/nvim/ftplugin/lua.lua.j2'
|
||||||
set_fact:
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/lua.lua'
|
||||||
neovim_installed_version: neovim_stats.stdout_lines[0] | regex_search('(v\d+\.\d+\.\d+)')
|
|
||||||
when: neovim_stats.rc == 0
|
|
||||||
|
|
||||||
# TODO: verify checksum
|
- src: 'templates/nvim/ftplugin/python.lua.j2'
|
||||||
- name: download neovim {{ neovim.version }}
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/python.lua'
|
||||||
get_url:
|
|
||||||
url: 'https://github.com/neovim/neovim/releases/download/{{ neovim.version }}/nvim-linux64.tar.gz'
|
|
||||||
dest: /tmp/nvim-linux64.tar.gz
|
|
||||||
when: neovim_stats.rc > 0 or neovim_installed_version != neovim.version
|
|
||||||
register: neovim_download
|
|
||||||
|
|
||||||
- name: extract downloaded neovim version
|
- src: 'templates/nvim/ftplugin/scss.lua.j2'
|
||||||
unarchive:
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/scss.lua'
|
||||||
src: /tmp/nvim-linux64.tar.gz
|
|
||||||
dest: '{{ neovim.install_path }}'
|
|
||||||
extra_opts:
|
|
||||||
- '--strip-components=1'
|
|
||||||
- '--show-stored-names'
|
|
||||||
- '--overwrite'
|
|
||||||
when: neovim_download.state == 'file' and
|
|
||||||
(neovim_installed_version is undefined or neovim_installed_version != neovim.version)
|
|
||||||
|
|
||||||
- name: add neovim to PATH
|
- src: 'templates/nvim/ftplugin/sh.lua.j2'
|
||||||
become: true
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/sh.lua'
|
||||||
template:
|
|
||||||
src: 'templates/nvim.profile.j2'
|
|
||||||
dest: '/etc/profile.d/neovim.sh'
|
|
||||||
|
|
||||||
|
- src: 'templates/nvim/ftplugin/yaml.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/yaml.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/init.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/init.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/lsp.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/lsp.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/options.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/options.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/tree-sitter.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/tree-sitter.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/git-signs.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/git-signs.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/lua-line.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/lua-line.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/telescope.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/_telescope.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/indent-blankline.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/indent-blankline.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/nvim-tree.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/_nvim-tree.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/colorscheme.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/colorscheme.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/source-link.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/_source-link.lua'
|
||||||
|
|
||||||
|
- src: 'templates/nvim/lua/filetype.lua.j2'
|
||||||
|
dest: '{{ xdg_config_dir }}/nvim/lua/_filetype.lua'
|
||||||
|
|
||||||
|
- name: Install neovim from archive
|
||||||
when: ansible_facts['os_family'] == 'Debian'
|
when: ansible_facts['os_family'] == 'Debian'
|
||||||
|
block:
|
||||||
|
- name: Create neovim install directory
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: directory
|
||||||
|
path: '{{ neovim.install_path }}'
|
||||||
|
owner: '{{ ansible_user_id }}'
|
||||||
|
group: '{{ ansible_user_gid }}'
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Register the current neovim version
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- '{{ neovim.install_path }}/bin/nvim'
|
||||||
|
- '--version'
|
||||||
|
register: neovim_stats
|
||||||
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Parse the current neovim version
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
neovim_installed_version: neovim_stats.stdout_lines[0] | regex_search('(v\d+\.\d+\.\d+)')
|
||||||
|
when: neovim_stats.rc == 0
|
||||||
|
|
||||||
|
# TODO: verify checksum
|
||||||
|
- name: Download neovim {{ neovim.version }}
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: 'https://github.com/neovim/neovim/releases/download/{{ neovim.version }}/nvim-linux64.tar.gz'
|
||||||
|
dest: /tmp/nvim-linux64.tar.gz
|
||||||
|
mode: '0755'
|
||||||
|
when: neovim_stats.rc > 0 or neovim_installed_version != neovim.version
|
||||||
|
register: neovim_download
|
||||||
|
|
||||||
|
- name: Extract downloaded neovim version
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: /tmp/nvim-linux64.tar.gz
|
||||||
|
dest: '{{ neovim.install_path }}'
|
||||||
|
extra_opts:
|
||||||
|
- '--strip-components=1'
|
||||||
|
- '--show-stored-names'
|
||||||
|
- '--overwrite'
|
||||||
|
when: |
|
||||||
|
neovim_download.state == 'file'
|
||||||
|
and (neovim_installed_version is undefined or neovim_installed_version != neovim.version)
|
||||||
|
|
||||||
|
- name: Add neovim to PATH
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 'templates/nvim.profile.j2'
|
||||||
|
dest: '/etc/profile.d/neovim.sh'
|
||||||
|
mode: '0755'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
-- {{ ansible_managed }}
|
-- {{ ansible_managed }}
|
||||||
|
|
||||||
|
-- TODO: load environment vars from .env files
|
||||||
require('options')
|
require('options')
|
||||||
|
require('_filetype')
|
||||||
require('colorscheme')
|
require('colorscheme')
|
||||||
require('lsp')
|
require('lsp')
|
||||||
require('tree-sitter')
|
require('tree-sitter')
|
||||||
|
|
|
||||||
40
templates/nvim/lua/filetype.lua.j2
Normal file
40
templates/nvim/lua/filetype.lua.j2
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
local ansible_keywords = {
|
||||||
|
'hosts',
|
||||||
|
'tasks',
|
||||||
|
'vars',
|
||||||
|
'vars_files',
|
||||||
|
'vars_prompt',
|
||||||
|
'handlers',
|
||||||
|
'roles',
|
||||||
|
'import_tasks',
|
||||||
|
'import_playbook',
|
||||||
|
'import_role',
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.filetype.add {
|
||||||
|
pattern = {
|
||||||
|
['playbook*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['site*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['inventory*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['task*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['requirement*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
|
||||||
|
|
||||||
|
['.*/tasks/.*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['.*/vars/.*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
['.*/playbooks/.*.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
|
||||||
|
['*.ansible.y(a?)ml'] = 'yaml.ansible',
|
||||||
|
|
||||||
|
['.*.y(a?)ml'] = {
|
||||||
|
function(path, bufnr)
|
||||||
|
local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ''
|
||||||
|
|
||||||
|
for _, keyword in pairs(ansible_keywords) do
|
||||||
|
local pattern = string.format('^- %s:', keyword)
|
||||||
|
if content:match(pattern) then return 'yaml.ansible' end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue