From d084912154952de74ecbab3206d2399472759c4a Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sat, 7 Jan 2023 17:26:51 +0100 Subject: [PATCH] Usersettings: Add variable to disable vim plugings Some systems just don't need them, but they take quite some time to install and take up space. --- README.md | 1 + defaults/main.yml | 3 + tasks/usersettings.yml | 92 +++++++++++++++-------------- files/_vimrc => templates/_vimrc.j2 | 2 + 4 files changed, 53 insertions(+), 45 deletions(-) rename files/_vimrc => templates/_vimrc.j2 (99%) diff --git a/README.md b/README.md index e9872bc..633f8df 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The User Setup will change the user shell and global gitconfig. This can be disa * `gitconfig_name`: User's name in .gitconfig file (default: n.a.) * `gitconfig_email`: User's email in .gitconfig file (default: n.a.) - `usersetup_virtualenvwrapper`: Boolean to enable the virtualenvwrapper plugin in oh-my-zsh (default: false) +- `usersetup_vimplugins`: Boolean to enable installing my VIM plugins (default: true) The development environment for different programming languages can be setup automatically. To enable, that Visual Studio Code will be installed and configured, set `user_vscode` to true, otherwise only the bare development toolchain will be installed. diff --git a/defaults/main.yml b/defaults/main.yml index 3ff0f24..56c565b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,6 +15,9 @@ usersetup_gitconfig: true # enable virtualenvwrapper plugin in oh-my-zsh usersetup_virtualenvwrapper: false +# install VIM plugins +usersetup_vimplugins: true + # install VS Code and selectively activate different programming languages user_vscode: false user_lang_cpp: false diff --git a/tasks/usersettings.yml b/tasks/usersettings.yml index 0260623..e6e7f93 100644 --- a/tasks/usersettings.yml +++ b/tasks/usersettings.yml @@ -2,8 +2,8 @@ # Common/Usersettings: Universial Dotfiles. Update regularly. - name: usersettings - Install required tools - become: yes - ignore_errors: yes # just fail on systems without sudo access + become: true + ignore_errors: true # just fail on systems without sudo access ansible.builtin.package: name: "{{ packages }}" state: present @@ -33,8 +33,8 @@ when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "Darwin" and (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "FreeBSD" - become: yes - ignore_errors: yes # just fail on systems without sudo access + become: true + ignore_errors: true # just fail on systems without sudo access ansible.builtin.package: name: "{{ packages }}" state: present @@ -43,7 +43,7 @@ - python3-pip - name: usersettings - Install pip virtualenvwrapper (Debian) when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Debian" - become: yes + become: true ansible.builtin.pip: name: virtualenvwrapper extra_args: --system @@ -57,7 +57,7 @@ when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Centos" or (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Archlinux" - become: yes + become: true ansible.builtin.pip: name: virtualenvwrapper - name: usersettings - Copy dotfiles @@ -69,10 +69,6 @@ src: "{{ role_path }}/files/_gitignore_global", dest: "{{ ansible_user_dir }}/.gitignore_global", } - - { - src: "{{ role_path }}/files/_vimrc", - dest: "{{ ansible_user_dir }}/.vimrc", - } - { src: "{{ role_path }}/files/_config/mpv.conf", dest: "{{ ansible_user_dir }}/.config/mpv/", @@ -104,6 +100,11 @@ dest: "{{ ansible_user_dir }}/.tmux.conf", force: yes, } + - { + src: "{{ role_path }}/templates/_vimrc.j2", + dest: "{{ ansible_user_dir }}/.vimrc", + force: yes, + } - { src: "{{ role_path }}/templates/htoprc.j2", dest: "{{ ansible_user_dir }}/.config/htop/htoprc", @@ -115,38 +116,39 @@ src: "{{ role_path }}/templates/_gitconfig.j2" dest: "{{ ansible_user_dir }}/.gitconfig" -- name: usersettings - Create .vim directory - ansible.builtin.file: - path: "{{ ansible_user_dir }}/.vim/autoload" - state: directory - -- name: usersettings - Install vim plugin manager - ansible.builtin.get_url: - url: https://tpo.pe/pathogen.vim - dest: "{{ ansible_user_dir }}/.vim/autoload/pathogen.vim" - -- name: usersettings - Install vim plugins - ansible.builtin.git: - repo: "{{ item.repo }}" - dest: "{{ item.dest }}" - with_items: - - { - repo: "https://github.com/itchyny/lightline.vim", - dest: "{{ ansible_user_dir }}/.vim/bundle/lightline", - } - - { - repo: "https://github.com/w0rp/ale", - dest: "{{ ansible_user_dir }}/.vim/bundle/ale", - } - - { - repo: "https://github.com/airblade/vim-gitgutter", - dest: "{{ ansible_user_dir }}/.vim/bundle/vim-gitgutter", - } - - { - repo: "https://github.com/sheerun/vim-polyglot", - dest: "{{ ansible_user_dir }}/.vim/bundle/vim-polyglot", - } - - { - repo: "https://github.com/tpope/vim-commentary", - dest: "{{ ansible_user_dir }}/.vim/bundle/vim-commentary", - } +- name: usersettings - Vim Plugings + when: usersetup_vimplugins == true + block: + - name: usersettings - Create .vim directory + ansible.builtin.file: + path: "{{ ansible_user_dir }}/.vim/autoload" + state: directory + - name: usersettings - Install vim plugin manager + ansible.builtin.get_url: + url: https://tpo.pe/pathogen.vim + dest: "{{ ansible_user_dir }}/.vim/autoload/pathogen.vim" + - name: usersettings - Install vim plugins + ansible.builtin.git: + repo: "{{ item.repo }}" + dest: "{{ item.dest }}" + with_items: + - { + repo: "https://github.com/itchyny/lightline.vim", + dest: "{{ ansible_user_dir }}/.vim/bundle/lightline", + } + - { + repo: "https://github.com/w0rp/ale", + dest: "{{ ansible_user_dir }}/.vim/bundle/ale", + } + - { + repo: "https://github.com/airblade/vim-gitgutter", + dest: "{{ ansible_user_dir }}/.vim/bundle/vim-gitgutter", + } + - { + repo: "https://github.com/sheerun/vim-polyglot", + dest: "{{ ansible_user_dir }}/.vim/bundle/vim-polyglot", + } + - { + repo: "https://github.com/tpope/vim-commentary", + dest: "{{ ansible_user_dir }}/.vim/bundle/vim-commentary", + } diff --git a/files/_vimrc b/templates/_vimrc.j2 similarity index 99% rename from files/_vimrc rename to templates/_vimrc.j2 index f803b8f..63e6312 100644 --- a/files/_vimrc +++ b/templates/_vimrc.j2 @@ -121,6 +121,7 @@ filetype plugin indent on " PLUGIN SETTINGS " ---------------------------------------------------------------------------- +{% if usersetup_vimplugins|bool %} " Use Pathogen for plugin management. See update.sh in this directory. runtime bundle/vim-pathogen/autoload/pathogen.vim call pathogen#infect() @@ -182,6 +183,7 @@ function! s:MaybeUpdateLightline() call lightline#update() end endfunction +{% endif %} " ---------------------------------------------------------------------------- " COLORS