Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use Ansible to configure Vim - Enable SysAdmin
- name: Config Vim with plugins
hosts: localhost
gather_facts: yes
become: no
vars:
vim_dir: "{{ ansible_env.HOME }}/.vim"
vimrc: "{{ ansible_env.HOME }}/.vimrc"
tasks:
- name: Install required packages
package:
name:
- vim-enhanced
- git
- powerline-fonts
- fzf
state: installed
become: yes
tags:
- install_packages
- name: Ensure .vim/{autoload,bundle} directory exists
file:
path: "{{ item }}"
state: directory
recurse: no
mode: 0750
loop:
- "{{ vim_dir }}"
- "{{ vim_dir }}/autoload"
- "{{ vim_dir }}/bundle"
- name: Ensure Pathogen is in place
get_url:
dest: "{{ vim_dir }}/autoload/pathogen.vim"
url: https://tpo.pe/pathogen.vim
- name: Deploy plugins
git:
dest: "{{ vim_dir }}/bundle/{{ item.name }}"
repo: "{{ item.url }}"
clone: yes
update: yes
recursive: no
loop:
- name: vim-airline
url: https://github.com/vim-airline/vim-airline
- name: nerdtree
url: https://github.com/preservim/nerdtree
- name: fzf-vim
url: https://github.com/junegunn/fzf.vim
- name: vim-gitgutter
url: https://github.com/airblade/vim-gitgutter
- name: vim-fugitive
url: https://github.com/tpope/vim-fugitive
- name: vim-floaterm
url: https://github.com/voldikss/vim-floaterm
- name: Ensure .vimrc config in place
copy:
src: vimrc
dest: "{{ vimrc }}"
backup: yes
mode: 0640
execute pathogen#infect()
syntax on
filetype plugin indent on
colo darkblue
" Configuration vim Airline
set laststatus=2
let g:airline#extensions#tabline#enabled=1
let g:airline_powerline_fonts=1
" Configuration NERDTree
map <F5> :NERDTreeToggle<CR>
" Configuration floaterm
let g:floaterm_keymap_toggle = '<F12>'
let g:floaterm_width = 0.9
let g:floaterm_height = 0.9
" Configuration Vim.FZF
let g:fzf_preview_window = 'right:50%'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment