ansible: add vim role

This commit is contained in:
Kirby 2025-09-15 13:59:36 +02:00
parent aed7efed71
commit cf5c5a076e
5 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,15 @@
---
vim_plugins:
- url: "https://github.com/jvirtanen/vim-hcl.git"
dest: "vim-hcl"
- url: "https://github.com/fatih/vim-go.git"
dest: "vim-go"
- url: "https://github.com/vim-airline/vim-airline.git"
dest: "vim-airline"
- url: "https://tpope.io/vim/fugitive.git"
dest: "fugitive"
- url: "https://github.com/dense-analysis/ale"
dest: "ale"
- url: "https://github.com/preservim/nerdtree"
dest: "nerdtree"

View File

@ -0,0 +1,55 @@
" ansible managed
" We don't care about vi
set nocompatible
" Syntax color
syntax on
" Read/write a .viminfo file, don't store more than 50 lines of registers
set viminfo='20,\"50
" Keep 50 lines of command line history
set history=50
" Disable auto-indent
set noautoindent
" Show line and column number of cursor
set ruler
" Search is case sensistive only if there is uppercase in the pattern
set smartcase
" Disable bell and use visualbell
set noerrorbells
set visualbell
" Highlight search match
set hlsearch
" Always display a status line
set laststatus=2
" Use spaces when using the tab key
set expandtab
" Use 4 spaces
set shiftwidth=4
set softtabstop=4
" Restore cursor position
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
" Disable automatic visual mode
set mouse-=a
" show line numbers
set nu
" set color for white background
:color desert
:highlight ws ctermbg=red guibg=red
:match ws /\s\+$/
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:ale_fixers = {
\ '*': ['remove_trailing_lines','trim_whitespace'],
\ 'yaml': ['yamllint'],
\ 'python': ['pylint'],
\}
filetype plugin indent on

View File

@ -0,0 +1,34 @@
---
- name: install vim and requirements for role
ansible.builtin.apt:
name: "{{ item }}"
state: present
remote_user: "{{ app_user | default('root') }}"
become: true
with_items:
- vim
- git
- name: deploy vimrc
ansible.builtin.copy:
src: vimrc
dest: "{{ vim_dir | default('/root/') }}/.vimrc"
owner: "{{ app_user | default('root') }}"
group: "{{ vim_group | default('root') }}"
mode: 0644
remote_user: "{{ app_user | default('root') }}"
- name: ensure plugins and colors folder exists
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ vim_plugins_dir | default('/root/.vim/pack/plugins/start') }}"
- name: download and install vim plugins
ansible.builtin.git:
repo: "{{ item.url }}"
dest: "{{ vim_plugins_dir | default('/root/.vim/pack/plugins/start') }}/{{ item.dest }}"
remote_user: "{{ app_user | default('root') }}"
loop: "{{ vim_plugins }}"

View File

@ -0,0 +1,4 @@
---
vim_package: vim
vim_plugins_dir: "~/.vim/pack/plugins/start"

View File

@ -0,0 +1,4 @@
---
vim_package: vim--no_x11
vim_root_group: wheel