diff --git a/dotfiles.yml b/dotfiles.yml index ee71cf6..1dbf9d2 100644 --- a/dotfiles.yml +++ b/dotfiles.yml @@ -1,7 +1,10 @@ --- - - name: Set up development machine hosts: localhost + vars: + xdg_config_home: "~/.config" + xdg_cache_home: "~/.cache" + xdg_data_home: "~/.local/share" roles: - bash #- dircolors @@ -12,4 +15,4 @@ #- readline #- ssh #- tmux - #- vim + - vim diff --git a/roles/vim/defaults/main.yml b/roles/vim/defaults/main.yml new file mode 100644 index 0000000..017b984 --- /dev/null +++ b/roles/vim/defaults/main.yml @@ -0,0 +1,5 @@ +--- +xdg_config_home: "~/.config" +xdg_cache_home: "~/.cache" +xdg_data_home: "~/.local/share" + diff --git a/dotfiles/.config/vim/autoload/plug.vim b/roles/vim/files/autoload/plug.vim similarity index 100% rename from dotfiles/.config/vim/autoload/plug.vim rename to roles/vim/files/autoload/plug.vim diff --git a/dotfiles/.config/vim/vimrc b/roles/vim/files/vimrc similarity index 92% rename from dotfiles/.config/vim/vimrc rename to roles/vim/files/vimrc index 70c4e53..503043d 100644 --- a/dotfiles/.config/vim/vimrc +++ b/roles/vim/files/vimrc @@ -1,5 +1,8 @@ set nocompatible +if $XDG_CONFIG_HOME == "" | let $XDG_CONFIG_HOME="~/.config" | endif +if $XDG_CACHE_HOME == "" | let $XDG_CACHE_HOME="~/.cache" | endif + let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" " Options {{{ @@ -102,10 +105,12 @@ let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" let g:rainbow#pairs = [['(',')'], ['[',']'], ['{','}']] - if has('multi_byte') && &encoding ==# 'utf-8' - let g:airline_section_z = airline#section#create(['ℓ%4l/%L 𝚌%3v']) - else " line / total : col - let g:airline_section_z = airline#section#create(['L%4l/%L c%3v']) + if exists('airline#section#create') + if has('multi_byte') && &encoding ==# 'utf-8' + let g:airline_section_z = airline#section#create(['ℓ%4l/%L 𝚌%3v']) + else " line / total : col + let g:airline_section_z = airline#section#create(['L%4l/%L c%3v']) + endif endif if !exists('g:airline_symbols') @@ -132,7 +137,7 @@ let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" highlight link srec32BitAddress Constant highlight link srecChecksum Type - colorscheme solarized + silent! colorscheme solarized filetype plugin indent on syntax enable " }}} @@ -232,7 +237,7 @@ augroup vimrc " {{{ autocmd FileType gitcommit setlocal textwidth=72 augroup END " }}} -if filereadable(expand("$XDG_CONFIG_HOME/vimrc.local")) - source $XDG_CONFIG_HOME/vimrc.local +if filereadable(expand("$XDG_CONFIG_HOME/vim/vimrc.local")) + source "$XDG_CONFIG_HOME/vim/vimrc.local" endif diff --git a/roles/vim/tasks/main.yml b/roles/vim/tasks/main.yml new file mode 100644 index 0000000..7cc116a --- /dev/null +++ b/roles/vim/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Create the vim cache and config directories + file: + path: "{{ item }}" + state: directory + loop: + - "{{ xdg_cache_home }}/vim" + - "{{ xdg_config_home }}/vim" + - "{{ xdg_config_home }}/vim/autoload" + +- name: Deploy vim plug and vimrc + file: + src: "{{ role_path }}/files/{{ item }}" + dest: "{{ xdg_config_home }}/vim/{{ item }}" + state: link + force: yes + loop: + - autoload/plug.vim + - vimrc + +- name: Install configured vim plugins + shell: vim -u "{{ xdg_config_home }}/vim/vimrc" +PlugInstall +qall +