From dd0e5a218916e1cf40237750339690ef5d1fba50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 2 Jul 2021 22:57:07 +0200 Subject: [PATCH] Basis for vim configuration Hyped for neovim 0.5! --- config/automatrop/playbooks/default.yml | 2 ++ .../automatrop/roles/dotfiles/tasks/main.yml | 6 ------ config/automatrop/roles/gnupg/tasks/main.yml | 2 -- config/automatrop/roles/vim/handlers/main.yml | 5 +++++ config/automatrop/roles/vim/tasks/main.yml | 14 +++++++++++++ config/automatrop/roles/vim/templates/nvim.j2 | 8 +++++++ .../roles/vim/templates/pluginlist.j2 | 9 ++++++++ .../automatrop/roles/vim/templates/plugins.j2 | 21 +++++++++++++++++++ .../roles/vim/templates/plugins/ale.j2 | 9 ++++++++ .../roles/vim/templates/plugins/deoplete.j2 | 1 + config/nvim/.gitignore | 1 - config/nvim/init.vim | 3 --- 12 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 config/automatrop/roles/vim/handlers/main.yml create mode 100644 config/automatrop/roles/vim/tasks/main.yml create mode 100644 config/automatrop/roles/vim/templates/nvim.j2 create mode 100644 config/automatrop/roles/vim/templates/pluginlist.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/ale.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/deoplete.j2 delete mode 100644 config/nvim/.gitignore delete mode 100644 config/nvim/init.vim diff --git a/config/automatrop/playbooks/default.yml b/config/automatrop/playbooks/default.yml index dbf178f..227b4a4 100644 --- a/config/automatrop/playbooks/default.yml +++ b/config/automatrop/playbooks/default.yml @@ -16,6 +16,8 @@ when: encrypt_home_stacked_fs - role: dotfiles tags: dotfiles + - role: vim + tags: vim - role: gnupg tags: gnupg - role: mnussbaum.base16-builder-ansible # Required for desktop_environment diff --git a/config/automatrop/roles/dotfiles/tasks/main.yml b/config/automatrop/roles/dotfiles/tasks/main.yml index 0692b42..8d55342 100644 --- a/config/automatrop/roles/dotfiles/tasks/main.yml +++ b/config/automatrop/roles/dotfiles/tasks/main.yml @@ -28,9 +28,3 @@ pip: requirements: "{{ ansible_user_dir }}/.dotfiles/config/scripts/requirements.txt" -- name: Install Neovim plugins - command: "nvim +PlugUpgrade +PlugUpdate +PlugInstall +qall" - failed_when: no - changed_when: yes -# TODO Build Neovim configuration better - diff --git a/config/automatrop/roles/gnupg/tasks/main.yml b/config/automatrop/roles/gnupg/tasks/main.yml index 1890860..ed4c7aa 100644 --- a/config/automatrop/roles/gnupg/tasks/main.yml +++ b/config/automatrop/roles/gnupg/tasks/main.yml @@ -44,8 +44,6 @@ value: SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed - key: personal-cipher-preferences value: TWOFISH CAMELLIA256 AES 3DES -# TODO Set default-key in extensions depending on which ones are available -# TODO Add enable-ssh-support to gpg-agent.conf in extensions to signal shenv that we should not use the SSH agent - name: Install Geoffrey Frogeye's key gpg_key: diff --git a/config/automatrop/roles/vim/handlers/main.yml b/config/automatrop/roles/vim/handlers/main.yml new file mode 100644 index 0000000..bd090a3 --- /dev/null +++ b/config/automatrop/roles/vim/handlers/main.yml @@ -0,0 +1,5 @@ +- name: Upgrade Neovim plugins + command: "nvim +PlugUpgrade +PlugUpdate +PlugInstall +qall" + failed_when: no + listen: neovim plugins changed + diff --git a/config/automatrop/roles/vim/tasks/main.yml b/config/automatrop/roles/vim/tasks/main.yml new file mode 100644 index 0000000..97e4c5e --- /dev/null +++ b/config/automatrop/roles/vim/tasks/main.yml @@ -0,0 +1,14 @@ +- name: Create nvim configuration directory + file: + state: directory + path: "{{ ansible_user_dir }}/.config/{{ item }}" + mode: "u=rwx,g=rx,o=rx" + with_items: + - nvim + +- name: Configure nvim + template: + src: nvim.j2 + dest: "{{ ansible_user_dir }}/.config/nvim/init.vim" + mode: "u=rw,g=r,o=r" + tags: g diff --git a/config/automatrop/roles/vim/templates/nvim.j2 b/config/automatrop/roles/vim/templates/nvim.j2 new file mode 100644 index 0000000..d6a50ef --- /dev/null +++ b/config/automatrop/roles/vim/templates/nvim.j2 @@ -0,0 +1,8 @@ +set nocompatible +filetype on + +set runtimepath+=~/.config/vim,~/.cache/vim +set viminfo+=n~/.cache/vim/viminfo + +{% include 'plugins.j2' %} + diff --git a/config/automatrop/roles/vim/templates/pluginlist.j2 b/config/automatrop/roles/vim/templates/pluginlist.j2 new file mode 100644 index 0000000..8e34e9e --- /dev/null +++ b/config/automatrop/roles/vim/templates/pluginlist.j2 @@ -0,0 +1,9 @@ +{% macro add_source(link, extra={}) -%} +{% set plugins.sources = plugins.sources + [(link, extra)] %} +{%- endmacro -%} +{% macro use_plugin(name) -%} +{% include 'plugins/' + name + '.j2' %} +{%- endmacro -%} + +{{ use_plugin('ale') }} +{{ use_plugin('deoplete') }} diff --git a/config/automatrop/roles/vim/templates/plugins.j2 b/config/automatrop/roles/vim/templates/plugins.j2 new file mode 100644 index 0000000..ced41b2 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins.j2 @@ -0,0 +1,21 @@ +" Auto-install vim-plug +if empty(glob('~/.cache/vim/autoload/plug.vim')) + silent !curl -fLo ~/.cache/vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +{% set plugins = namespace(sources=[]) %} +{% import 'pluginlist.j2' as pluginlist with context %} + +call plug#begin('~/.cache/vim/plugged') +{% for link, extra in plugins.sources %} +{% if extra %} +Plug '{{ link }}', { {% for k, v in extra.items() %}'{{ k }}': '{{ v }}', {% endfor %} } +{% else %} +Plug '{{ link }}' +{% endif %} +{% endfor %} +call plug#end() + +{% include 'pluginlist.j2' %} diff --git a/config/automatrop/roles/vim/templates/plugins/ale.j2 b/config/automatrop/roles/vim/templates/plugins/ale.j2 new file mode 100644 index 0000000..50089d7 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/ale.j2 @@ -0,0 +1,9 @@ +{{ add_source('dense-analysis/ale') }} + +nmap :ALEFix + +let g:ale_sign_error = '×' +let g:ale_sign_warning = '!' +let g:ale_completion_enabled = 1 +let g:ale_fixers = ['autopep8', 'shfmt', 'uncrustify', 'remove_trailing_lines', 'trim_whitespace', 'phpcbf'] +let g:ale_php_phpcs_standard = '/srv/http/machines/ruleset.xml' diff --git a/config/automatrop/roles/vim/templates/plugins/deoplete.j2 b/config/automatrop/roles/vim/templates/plugins/deoplete.j2 new file mode 100644 index 0000000..870abda --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/deoplete.j2 @@ -0,0 +1 @@ +{{ add_source('Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}) }} diff --git a/config/nvim/.gitignore b/config/nvim/.gitignore deleted file mode 100644 index a0e76af..0000000 --- a/config/nvim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.netrwhist diff --git a/config/nvim/init.vim b/config/nvim/init.vim deleted file mode 100644 index 94fbe0f..0000000 --- a/config/nvim/init.vim +++ /dev/null @@ -1,3 +0,0 @@ -set runtimepath+=~/.config/vim,~/.cache/vim -let &packpath = &runtimepath -source ~/.config/vimrc