diff --git a/roles/vim/files/vimrc b/roles/vim/files/vimrc index 858e4f4..42f4065 100644 --- a/roles/vim/files/vimrc +++ b/roles/vim/files/vimrc @@ -66,7 +66,7 @@ set ttyfast " indicate a fast terminal for smoother redrawing " | | | | | | " v v v v v v set viminfo=h,'500,<10000,s1000,/1000,:1000 -set viminfofile=$XDG_CACHE_HOME/vim/viminfo +set viminfofile=$XDG_CACHE_HOME/vim/viminfo set virtualedit=block " position the cursor anywhere in Visual Block mode set wildignore=*.o,*.obj,*.pyc,*.exe,*.so,*.dll set wildmenu " use the menu for commandline completion @@ -83,155 +83,154 @@ endif " }}} " Plugins {{{ - call plug#begin('$XDG_CONFIG_HOME/vim/bundle') - Plug 'altercation/vim-colors-solarized' - Plug 'bronson/vim-trailing-whitespace' - Plug 'elzr/vim-json' - " Make numbers and booleans stand out, important because of the - " concealment used by vim-json. - highlight link jsonBraces Text - highlight link jsonNumber Identifier - highlight link jsonBoolean Identifier - highlight link jsonNull Identifier - Plug 'godlygeek/tabular' | Plug 'plasticboy/vim-markdown' - let g:vim_markdown_conceal_code_blocks = 0 - Plug 'junegunn/rainbow_parentheses.vim' - let g:rainbow#pairs = [['(',')'], ['[',']'], ['{','}']] - Plug 'kien/ctrlp.vim' - let g:ctrlp_match_window = 'bottom,order:ttb' - let g:ctrlp_switch_buffer = 0 " open files in new buffer - let g:ctrlp_show_hidden = 1 " show hidden files - Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } - Plug 'tpope/vim-commentary' - Plug 'tpope/vim-fugitive' - Plug 'vim-airline/vim-airline' - Plug 'vim-airline/vim-airline-themes' - if !exists('g:airline_symbols') - let g:airline_symbols = {} - endif - let g:airline_left_sep = ' ' - let g:airline_left_alt_sep = '' - let g:airline_right_sep = ' ' - let g:airline_right_alt_sep = '' - let g:airline_symbols.crypt = '๐Ÿ”’' - let g:airline_symbols.branch = 'โއ' - let g:airline_symbols.paste = 'โ“…' - let g:airline_symbols.spell = 'โœ”' - let g:airline_symbols.readonly = ' โƒ ' - let g:airline_symbols.notexists = 'โˆ„' - let g:airline_symbols.whitespace = 'โœ—' - Plug 'vim-scripts/srec.vim' - highlight link srecStart Comment - highlight link srecType Comment - highlight link srecLength WarningMsg - highlight link srec16BitAddress Constant - highlight link srec24BitAddress Constant - highlight link srec32BitAddress Constant - highlight link srecChecksum Type - Plug 'keith/swift.vim' - Plug 'chr4/nginx.vim' - call plug#end() - - " This has to be here (as opposed to right after the Plug call) because the - " function airline#section#create doesn't exist before plug#end() is - " called. THe exists() call is still needed so no errors are generated on - " the very first time vim is run, as no plugins are installed yet. - 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']) +call plug#begin('$XDG_CONFIG_HOME/vim/bundle') + Plug 'altercation/vim-colors-solarized' + Plug 'bronson/vim-trailing-whitespace' + Plug 'elzr/vim-json' + " Make numbers and booleans stand out, important because of the + " concealment used by vim-json. + highlight link jsonBraces Text + highlight link jsonNumber Identifier + highlight link jsonBoolean Identifier + highlight link jsonNull Identifier + Plug 'godlygeek/tabular' | Plug 'plasticboy/vim-markdown' + let g:vim_markdown_conceal_code_blocks = 0 + Plug 'junegunn/rainbow_parentheses.vim' + let g:rainbow#pairs = [['(',')'], ['[',']'], ['{','}']] + Plug 'kien/ctrlp.vim' + let g:ctrlp_match_window = 'bottom,order:ttb' + let g:ctrlp_switch_buffer = 0 " open files in new buffer + let g:ctrlp_show_hidden = 1 " show hidden files + Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } + Plug 'tpope/vim-commentary' + Plug 'tpope/vim-fugitive' + Plug 'vim-airline/vim-airline' + Plug 'vim-airline/vim-airline-themes' + if !exists('g:airline_symbols') + let g:airline_symbols = {} endif - endif + let g:airline_left_sep = ' ' + let g:airline_left_alt_sep = '' + let g:airline_right_sep = ' ' + let g:airline_right_alt_sep = '' + let g:airline_symbols.crypt = '๐Ÿ”’' + let g:airline_symbols.branch = 'โއ' + let g:airline_symbols.paste = 'โ“…' + let g:airline_symbols.spell = 'โœ”' + let g:airline_symbols.readonly = ' โƒ ' + let g:airline_symbols.notexists = 'โˆ„' + let g:airline_symbols.whitespace = 'โœ—' + Plug 'vim-scripts/srec.vim' + highlight link srecStart Comment + highlight link srecType Comment + highlight link srecLength WarningMsg + highlight link srec16BitAddress Constant + highlight link srec24BitAddress Constant + highlight link srec32BitAddress Constant + highlight link srecChecksum Type + Plug 'keith/swift.vim' + Plug 'chr4/nginx.vim' +call plug#end() - silent! colorscheme solarized - filetype plugin indent on - syntax enable +" This has to be here (as opposed to right after the Plug call) because the +" function airline#section#create doesn't exist before plug#end() is +" called. The exists() call is still needed so no errors are generated on +" the very first time vim is run, as no plugins are installed yet. +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 + +silent! colorscheme solarized +filetype plugin indent on +syntax enable " }}} " Functions {{{ - " Cycle through relativenumber + number, number (only), and no numbering. - function! VimrcCycleNumbers() abort - if exists('+relativenumber') - execute { - \ '00': 'set relativenumber | set number', - \ '01': 'set norelativenumber | set number', - \ '10': 'set norelativenumber | set nonumber', - \ '11': 'set norelativenumber | set number' }[&number . &relativenumber] - else - set number! " No relative numbering, just toggle numbers on and off. - endif - endfunction +" Cycle through relativenumber + number, number (only), and no numbering. +function! VimrcCycleNumbers() abort + if exists('+relativenumber') + execute { + \ '00': 'set relativenumber | set number', + \ '01': 'set norelativenumber | set number', + \ '10': 'set norelativenumber | set nonumber', + \ '11': 'set norelativenumber | set number' }[&number . &relativenumber] + else + set number! " No relative numbering, just toggle numbers on and off. + endif +endfunction - " Turn fold text from this: - " - " +--- 2 lines: text of first line in fold -------------------------- - " - " into this: - " - " ยทยทยท 2โ„“: text of first line in fold ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท - function! VimrcFoldText() abort - let l:level=substitute(v:folddashes, '-', 'ยท', 'g') - let l:count=(v:foldend - v:foldstart + 1) - let l:title=substitute(getline(v:foldstart), '\v *', '', '') - return l:level . ' ' . l:count . 'โ„“: ' . l:title . ' ' - endfunction +" Turn fold text from this: +" +" +--- 2 lines: text of first line in fold -------------------------- +" +" into this: +" +" ยทยทยท 2โ„“: text of first line in fold ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท +function! VimrcFoldText() abort + let l:level=substitute(v:folddashes, '-', 'ยท', 'g') + let l:count=(v:foldend - v:foldstart + 1) + let l:title=substitute(getline(v:foldstart), '\v *', '', '') + return l:level . ' ' . l:count . 'โ„“: ' . l:title . ' ' +endfunction " }}}" " Mappings {{{ - let mapleader = "\" - let maplocalleader = "," +let mapleader = "\" +let maplocalleader = "," - " better navigation for wrapped lines - noremap j gj - noremap k gk +" better navigation for wrapped lines +noremap j gj +noremap k gk - " quickly exit insert mode - inoremap jk +" quickly exit insert mode +inoremap jk - " retain selection when indenting/unindenting in visual mode - vnoremap > >gv - vnoremap < <gv +" retain selection when indenting/unindenting in visual mode +vnoremap > >gv +vnoremap < <gv - " better searching (case insensitive & expand on previous) - nnoremap // /\c - nnoremap /// // +" better searching (case insensitive & expand on previous) +nnoremap // /\c +nnoremap /// // - " window resizing similar to the way I have tmux set up - nnoremap 5+ - nnoremap 5- - nnoremap 5< - nnoremap 5> +" window resizing similar to the way I have tmux set up +nnoremap 5+ +nnoremap 5- +nnoremap 5< +nnoremap 5> - " easier window navigation - nnoremap j - nnoremap k - nnoremap h - nnoremap l +" easier window navigation +nnoremap j +nnoremap k +nnoremap h +nnoremap l - " easier tab navigation - nnoremap :tabprevious - nnoremap :tabnext +" easier tab navigation +nnoremap :tabprevious +nnoremap :tabnext - " quickly change background - nnoremap bg - \ :let &background = &background ==# 'light' ? 'dark' : 'light' +" quickly change background +nnoremap bg + \ :let &background = &background ==# 'light' ? 'dark' : 'light' - " turn off search highlight - nnoremap h :nohlsearch +" turn off search highlight +nnoremap h :nohlsearch - " toggle NERDTree - nnoremap n :NERDTreeToggle +" toggle NERDTree +nnoremap n :NERDTreeToggle - " toggle rainbow parens - nnoremap p :RainbowParentheses!! +" toggle rainbow parens +nnoremap p :RainbowParentheses!! - " fix whitespace - nnoremap w :FixWhitespace - - " cycle through line numbering modes - nnoremap l :call VimrcCycleNumbers() +" fix whitespace +nnoremap w :FixWhitespace +" cycle through line numbering modes +nnoremap l :call VimrcCycleNumbers() " }}}" augroup vimrc " {{{