diff --git a/ansible/roles/vim/defaults/all b/ansible/roles/vim/defaults/all new file mode 100644 index 0000000..9ca01ac --- /dev/null +++ b/ansible/roles/vim/defaults/all @@ -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" diff --git a/ansible/roles/vim/files/vimrc b/ansible/roles/vim/files/vimrc new file mode 100644 index 0000000..f5cc413 --- /dev/null +++ b/ansible/roles/vim/files/vimrc @@ -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 diff --git a/ansible/roles/vim/tasks/main.yml b/ansible/roles/vim/tasks/main.yml new file mode 100644 index 0000000..1b4c79b --- /dev/null +++ b/ansible/roles/vim/tasks/main.yml @@ -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 }}" diff --git a/ansible/roles/vim/vars/Debian.yml b/ansible/roles/vim/vars/Debian.yml new file mode 100644 index 0000000..a2cbe4e --- /dev/null +++ b/ansible/roles/vim/vars/Debian.yml @@ -0,0 +1,4 @@ +--- + +vim_package: vim +vim_plugins_dir: "~/.vim/pack/plugins/start" diff --git a/ansible/roles/vim/vars/OpenBSD.yml b/ansible/roles/vim/vars/OpenBSD.yml new file mode 100644 index 0000000..529a02a --- /dev/null +++ b/ansible/roles/vim/vars/OpenBSD.yml @@ -0,0 +1,4 @@ +--- + +vim_package: vim--no_x11 +vim_root_group: wheel