tonipamies.vim

Molecule Test Ansible-lint rules explanation Ansible-lint pre-commit CodeFactor
Galaxy VIM Galaxy VIM Galaxy VIM

Ansible role ansible-role-vim

Description

An Ansible role to install and configure vim in linux distributions. Specifically, the responsibilities of this role are to:

Refer to the change log for changes in each release.

Linux distributions supported

  • CentOS 8
  • Debian 10 Buster
  • Debian 11 Bullseye
  • Debian 12 Bookworm
  • Fedora 31
  • Fedora 32
  • Fedora 33
  • Fedora 34
  • Fedora 35
  • Fedora 36
  • Fedora 37
  • Fedora 38
  • Ubuntu 18.04 Bionic
  • Ubuntu 20.04 Focal
  • Ubuntu 22.04 Jammy

Requirements

  • Ansible 2.9
  • Git for install the pathogen plugins (Installation included in the role itself)
  • On CentOS EPEL Repository (Installation included in the role itself)

Role Variables

None of the variables below are required. When not defined by the user, the default values are used.

Basic configuration

Variable Default Comments
color 'darkblue' The default colorschema
One of: blue, darkblue, default, delek, desert, elflord, evening, industry, koehler,
morning, murphy, pablo, peachpuff, ron, shine, slate, solarized, torte, zellnet
airline_theme 'luna' The default airline theme
One of: alduin, angr, atomic, aurora, ayu_mirage, badcat, badwolf, base16,
base16_3024, base16_apathy, base16_ashes, base16_atelierdune,
base16_atelierforest, base16_atelierheath, base16_atelierlakeside
base16_atelierseaside, base16_bespin, base16_brewer, base16_bright,
base16_chalk, base16_classic, base16_codeschool, base16_colors,
base16_default, base16_eighties, base16_embers, base16_flat,
base16_google, base16_grayscale, base16_greenscreen, base16_harmonic16,
base16_hopscotch, base16_isotope, base16_londontube, base16_marrakesh,
base16_mocha, base16_monokai, base16_nord, base16_ocean,
base16_oceanicnext, base16_paraiso, base16_pop, base16_railscasts,
base16_seti, base16_shapeshifter, base16_shell, base16_solarized,
base16_spacemacs, base16_summerfruit, base16_tomorrow, base16_twilight,
base16color, behelit, biogoo, bubblegum, cobalt2, cool, dark,
dark_minimal, distinguished, dracula, durant, fairyfloss, hybrid,
hybridline, jellybeans, jet, kalisi, kolor, laederon, light, lucius,
luna, minimalist, molokai, monochrome, murmur, night_owl, onedark,
papercolor, peaksea, powerlineish, qwq, raven, ravenpower, serene,
sierra, silver, simple, sol, solarized, solarized_flood, term,
term_light, tomorrow, ubaryd, understated, vice, violet, wombat,
xtermlight, zenburn
custom_pathogen_plugins [] List of dicts specifying the pathogen plugins to be added. See below for details
backup_config_files false When true, this role will backup all the configurations files before to do any change

Custom pathogen plugins

A list of pathogen plugins to be added and are defined with a dict containing the fields:

  • name (required) The name of the pathogen plugin
  • url (required) The git url of the pathogen plugin
  • enabled (required) true install the pathogen plugin
  • config_file (optional) a vim config file to be included in vimrc with specificconfiguration for this plugin

The following example installs nerdcommenter

- custom_pathogen_plugins:
  - name: nerdcommenter
    url: 'https://github.com/preservim/nerdcommenter'
    enabled: true
    config_file: 'roles/common/templates/etc/vim/nerdcommenter.vim.j2

Examples

Example Playbook

---
- hosts: all
  gather_facts: true
  remote_user: ansible
  become: true

  roles:
    - role: vim
      vars:
        - backup_config_files: true
        - color: ron
        - airline_theme: vice
        - custom_pathogen_plugins:
          - name: nerdcommenter
            url: 'https://github.com/preservim/nerdcommenter'
            enabled: true
            config_file: 'roles/common/templates/etc/vim/nerdcommenter.vim.j2'

Example Task

#
# Install Vim Packages
#
- name: INCLUDE ROLE | Install Vim Packages & Configure it
  include_role:
    name: vim
  vars:
    - backup_config_files: true
    - color: ron
    - airline_theme: vice
    - custom_pathogen_plugins:
      - name: nerdcommenter
        url: 'https://github.com/preservim/nerdcommenter'
        enabled: true
        config_file: 'roles/common/templates/etc/vim/nerdcommenter.vim.j2'
  when:
    - vim_for_sysadmins is defined
    - vim_for_sysadmins | bool
  tags:
    - install
    - configure

Example of file nerdcommenter.vim.j2

{{ ansible_managed | comment }}
"
" Nerdcommenter configuration
"
"
" Create default mappings
let g:NERDCreateDefaultMappings = 1

" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1

" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1

" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'

" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1

" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }

" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1

" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1

" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
About

Ansible Role to install and configure vim in linux distributions

Install
ansible-galaxy install tonipamies.vim
GitHub repository
License
agpl-3.0
Downloads
128