From a606022dd6c4e1433a9978e6068d6021fea7b112 Mon Sep 17 00:00:00 2001 From: commandline Date: Tue, 13 Oct 2015 22:48:33 -0400 Subject: [PATCH] Break up config, add other improvements. --- airline.vim | 16 +++++ java.vim => ftplugin/java.vim | 4 +- ftplugin/javascript.vim | 2 + ftplugin/markdown.vim | 8 +++ ftplugin/text.vim | 22 +++++++ gvimrc | 2 - javascript.vim | 4 -- mapping.vim | 11 ++++ markdown.vim | 17 ------ project.vimrc | 8 --- syntastic.vim | 13 ++++ text.vim | 23 ------- unite.vim | 6 ++ vimrc | 111 +++++++++++----------------------- 14 files changed, 114 insertions(+), 133 deletions(-) create mode 100644 airline.vim rename java.vim => ftplugin/java.vim (78%) create mode 100644 ftplugin/javascript.vim create mode 100644 ftplugin/markdown.vim create mode 100644 ftplugin/text.vim delete mode 100644 javascript.vim create mode 100644 mapping.vim delete mode 100644 markdown.vim delete mode 100644 project.vimrc create mode 100644 syntastic.vim delete mode 100644 text.vim create mode 100644 unite.vim diff --git a/airline.vim b/airline.vim new file mode 100644 index 0000000..d2c09d9 --- /dev/null +++ b/airline.vim @@ -0,0 +1,16 @@ +" configure airline, advanced status line plugin +let g:airline#extensions#tagbar#enabled = 1 +let g:airline#extensions#tabline#enabled = 1 +" these symbols rely on a patched powerline font being set either as gfn within +" .gvimrc or as the font for the given terminal program +let g:airline_powerline_fonts = 1 +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.branch = '' +let g:airline_symbols.readonly = '' +let g:airline_symbols.linenr = '' diff --git a/java.vim b/ftplugin/java.vim similarity index 78% rename from java.vim rename to ftplugin/java.vim index 46943da..d46f8b0 100644 --- a/java.vim +++ b/ftplugin/java.vim @@ -11,6 +11,6 @@ endfunction "let makeprg = 'java -cp /opt/boxen/homebrew/opt/checkstyle/libexec/checkstyle-6.0-all.jar -c '. vimrc_git . '/checkstyle.xml %:p' let makeprg = 'checkstyle -c '. vimrc_git . '/checkstyle.xml ./%' -autocmd FileType java let &makeprg=escape(makeprg, ' ') -autocmd FileType java set errorformat=%f:%l:\ %m,%f:%l:%v:\ %m,%-G%.%# +let &makeprg=escape(makeprg, ' ') +setlocal errorformat=%f:%l:\ %m,%f:%l:%v:\ %m,%-G%.%# diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim new file mode 100644 index 0000000..e1b7947 --- /dev/null +++ b/ftplugin/javascript.vim @@ -0,0 +1,2 @@ +setlocal fdm=indent +setlocal smartindent diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim new file mode 100644 index 0000000..2f3f070 --- /dev/null +++ b/ftplugin/markdown.vim @@ -0,0 +1,8 @@ +" set a smaller indent +setlocal ts=2 + +" and set up the buffer just like a text file +let oldwd = getcwd() +exec "cd ~/.vim/ftplugin" +source text.vim +exec "cd " . oldwd diff --git a/ftplugin/text.vim b/ftplugin/text.vim new file mode 100644 index 0000000..a4e8af6 --- /dev/null +++ b/ftplugin/text.vim @@ -0,0 +1,22 @@ +" don't hard break text +setlocal tw=0 +" keep soft breaks between words +setlocal linebreak +" turn list off as it interferes with soft wrapping +setlocal nolist! +" turn off breaking when typing new text +setlocal formatoptions-=t +" turn off line width hint +setlocal colorcolumn=0 + +" narrow width for gui since text will softwrap based on width +if has("gui_running") + " narrow the gui window for text wrangling + setlocal columns=120 +endif + +" open full screen with macvim +if has("gui_macvim") + set fuoptions=maxvert,maxhorz + au GUIEnter * set fullscreen +endif diff --git a/gvimrc b/gvimrc index fd8ade5..dc391f6 100644 --- a/gvimrc +++ b/gvimrc @@ -5,8 +5,6 @@ source ~/.gvimrc_local " Mac: set guifont=Monaco:h14 " from the help, recommended for tallest possible set lines=9999 -" from the help, recommended for widest possible -set columns=9999 set background=dark "" enable antialiasing for environments supporting it set anti diff --git a/javascript.vim b/javascript.vim deleted file mode 100644 index 07e5cb4..0000000 --- a/javascript.vim +++ /dev/null @@ -1,4 +0,0 @@ -autocmd FileType javascript set fdm=indent -autocmd FileType javascript set smarttab -autocmd FileType javascript set smartindent -autocmd FileType javascript set spell diff --git a/mapping.vim b/mapping.vim new file mode 100644 index 0000000..4686338 --- /dev/null +++ b/mapping.vim @@ -0,0 +1,11 @@ +" quickly clear Syntastic info +nmap :SyntasticReset +" toggle gundo's display +nmap :GundoToggle +" quickly toggle a right, vsplit for viewing, navigating whatever structure easy +" tags/tagbar can figure out for the current buffer +nmap :TagbarToggle +" quickly toggle a left, vsplit for an insanely powerful file explorer +nmap :NERDTreeToggle +" open tree to current buffer +nmap :NERDTreeFind diff --git a/markdown.vim b/markdown.vim deleted file mode 100644 index c61936c..0000000 --- a/markdown.vim +++ /dev/null @@ -1,17 +0,0 @@ -" set a smaller indent -autocmd filetype markdown set ts=2 -" like text files, don't break -"autocmd filetype markdown set tw=0 -"" keep soft breaks between words -"autocmd filetype markdown set nolinebreak -"" fold on what indents there are -"autocmd filetype markdown set fdm=indent -"" smarten indent handling -"autocmd filetype markdown set smartindent -"" turn off line width hint -"autocmd FileType markdown set colorcolumn=0 -" -"if has("gui_running") -" " narrow the gui window for text wrangling -" autocmd FileType markdown set columns=120 -"endif diff --git a/project.vimrc b/project.vimrc deleted file mode 100644 index 16f7372..0000000 --- a/project.vimrc +++ /dev/null @@ -1,8 +0,0 @@ -" set project's root to find's searchable path -set path =~/src/git/project/** -" honor project specific white space handling -set ts=4 sw=4 expandtab -" for coding projects, turn on list to view white space characters and line -" number -set list! -set number! diff --git a/syntastic.vim b/syntastic.vim new file mode 100644 index 0000000..3547123 --- /dev/null +++ b/syntastic.vim @@ -0,0 +1,13 @@ +" configure syntastic, advanced syntax checker, with some reasonable behaviors +" +" always stick detected errors in the location list +let g:syntastic_always_populate_loc_list = 1 +" open but only when errors are detected; default closes when errors are cleared +" but doesn't open the list automatically +let g:syntastic_auto_loc_list = 1 +" check when first opening a file +let g:syntastic_check_on_open = 1 +" don't check on writing and quitting +let g:syntastic_check_on_wq = 0 +" explicitly set the js checker to my preferred one +let g:syntastic_javascript_checkers = ['eslint'] diff --git a/text.vim b/text.vim deleted file mode 100644 index d6c8510..0000000 --- a/text.vim +++ /dev/null @@ -1,23 +0,0 @@ -" don't hard break text -autocmd FileType text set tw=0 -" keep soft breaks between words -autocmd FileType text set linebreak -" turn list off as it interferes with soft wrapping -autocmd FileType text set nolist! -" pull the wrap margin in given my preference for wide terms and windows -autocmd FileType text set wrapmargin=20 -" turn off breaking when typing new text -autocmd FileType text set formatoptions-=t -" turn off line width hint -autocmd FileType text set colorcolumn=0 - -" open full screen with macvim -if has("gui_macvim") - set fuoptions=maxvert,maxhorz - au GUIEnter * set fullscreen -endif - -if has("gui_running") - " narrow the gui window for text wrangling - autocmd FileType text set columns=80 -endif diff --git a/unite.vim b/unite.vim new file mode 100644 index 0000000..971bd5b --- /dev/null +++ b/unite.vim @@ -0,0 +1,6 @@ +" use the silver searcher with Unite's async file recursion +let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', ''] +" set default matcher in unite to fuzzy +call unite#filters#matcher_default#use(['matcher_fuzzy']) +" open Unite ready for recursively, fuzzy match files +nnoremap f :Unite -start-insert file_rec/async:! diff --git a/vimrc b/vimrc index dc90fd0..99dcf15 100644 --- a/vimrc +++ b/vimrc @@ -1,34 +1,17 @@ " set the directory where my vimrc git project is located source ~/.vimrc_local -" N.B. put settings that file type specific configs will override here -" -" even with the nice space/tab autodetect, prefer 4 for tab stops -" but let file type specifics override (for instance a setting of 2 for markdown -set ts=4 -" default to folding on syntax -set fdm=syntax -" set a readable width -set textwidth=80 -" make white space visible, where that matters -set list -" set up folding preferences -set fde=1 -" vim's spelling is smart enough for code, to only check comments -set spell -" add a hint for long lines -set colorcolumn=120 -" default to expanding tabs, I'm not insane -set expandtab +" it is a big fat key, after all +let mapleader = "\" " source aux files also under git control let oldwd = getcwd() exec "cd " . vimrc_git source vundle.vim -"source java.vim -source javascript.vim -source markdown.vim -source text.vim +source airline.vim +source syntastic.vim +source unite.vim +source mapping.vim exec "cd " . oldwd " turn on file type plugins @@ -42,8 +25,25 @@ syntax on set number set relativenumber -" it is a big fat key, after all -let mapleader = "\" +" even with the nice space/tab autodetect, prefer 4 for tab stops +" but let file type specifics override (for instance a setting of 2 for markdown +set tabstop=4 +" default to folding on syntax +set foldmethod=syntax +" set a readable width +set textwidth=80 +" make white space visible, where that matters +set list +" except for help +autocmd FileType help set nolist +" set up folding preferences +set fde=1 +" vim's spelling is smart enough for code, to only check comments +set spell +" add a hint for long lines +set colorcolumn=120 +" default to expanding tabs, I'm not insane +set expandtab " change buffer behaviors to no longer require changes when hiding a buffer set hidden @@ -63,8 +63,8 @@ set incsearch set wildmode=longest:full set wildmenu " line break handling -set lbr -set sbr=+ +set linebreak +set showbreak=+ " always on status line set laststatus=2 @@ -86,56 +86,6 @@ set pastetoggle= " save when moving away au FocusLost * :wa -" configure airline, advanced status line plugin -let g:airline#extensions#tagbar#enabled = 1 -let g:airline#extensions#tabline#enabled = 1 -" these symbols rely on a patched powerline font being set either as gfn within -" .gvimrc or as the font for the given terminal program -let g:airline_powerline_fonts = 1 -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.branch = '' -let g:airline_symbols.readonly = '' -let g:airline_symbols.linenr = '' - -" configure syntastic, advanced syntax checker, with some reasonable behaviors -" -" always stick detected errors in the location list -let g:syntastic_always_populate_loc_list = 1 -" open but only when errors are detected; default closes when errors are cleared -" but doesn't open the list automatically -let g:syntastic_auto_loc_list = 1 -" check when first opening a file -let g:syntastic_check_on_open = 1 -" don't check on writing and quitting -let g:syntastic_check_on_wq = 0 -" explicitly set the js checker to my preferred one -let g:syntastic_javascript_checkers = ['eslint'] - -" quickly clear Syntastic info -nmap :SyntasticReset -" toggle gundo's display -nmap :GundoToggle -" quickly toggle a right, vsplit for viewing, navigating whatever structure easy -" tags/tagbar can figure out for the current buffer -nmap :TagbarToggle -" quickly toggle a left, vsplit for an insanely powerful file explorer -nmap :NERDTreeToggle -" open tree to current buffer -nmap :NERDTreeFind - -" use the silver searcher with Unite's async file recursion -let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', ''] -" set default matcher in unite to fuzzy -call unite#filters#matcher_default#use(['matcher_fuzzy']) -" open Unite ready for recursively, fuzzy match files -nnoremap f :Unite -start-insert file_rec/async:! - " open is OS X only, the closest equiv in line, xdg-open, doesn't allow an " argument for speciying a particular app if has('gui_macvim') @@ -154,5 +104,12 @@ if has('gui_macvim') command! -bar -nargs=1 OpenWith call s:OpenWith() endif +if has("gui_running") + let narrows = ['text', 'markdown'] + " from the help, recommended for widest possible + " for text, narrow width to make side to side scanning easier + autocmd BufEnter * if index(narrows, &ft) >= 0 | set columns=120 | else | set columns=9999 | endif +endif + " make sure to set TERM to xterm-256color in terminal program or app colorscheme solarized