1 " vim: et sts=2 sw=2 |
1 " vim: et sts=2 sw=2 |
2 " vim: fdm=marker |
2 " vim: fdm=marker |
3 |
3 |
4 set nocompatible |
4 set nocompatible |
5 |
5 |
6 let on_windows=0 |
6 " on windows and not cygwin |
7 if has('win32') || has('win64') |
7 let s:on_windows=(has('win32') || has('win64')) |
8 " vim in cygwin has win32 = 0 and win32unix = 1 |
8 let s:filename=expand('<sfile>') |
9 let on_windows=1 |
|
10 endif |
|
11 |
9 |
12 " Set up Vundle and plugins {{{ |
10 " Set up Vundle and plugins {{{ |
13 let installed_vundle=0 |
11 let s:installed_vundle=0 |
14 |
12 |
15 if on_windows == 0 |
13 let s:vundle_readme=expand(s:on_windows |
16 let vundle_readme=expand('~/.vim/bundle/vundle/README.md') |
14 \ ? '~/vimfiles/bundle/vundle/README.md' |
17 else |
15 \ : '~/.vim/bundle/vundle/README.md') |
18 let vundle_readme=expand('~/vimfiles/bundle/vundle/README.md') |
16 |
19 endif |
17 if !filereadable(s:vundle_readme) |
20 |
|
21 if !filereadable(vundle_readme) |
|
22 if !executable('git') |
18 if !executable('git') |
23 echo "You probably want git installed and in PATH." |
19 echo "You probably want git installed and in PATH." |
24 if on_windows == 1 |
|
25 echo " http://chocolatey.org " |
|
26 endif |
|
27 quit |
20 quit |
28 endif |
21 endif |
29 |
22 |
30 let installed_vundle=1 |
23 echo "Installing Vundle and Plugins...\n" |
31 if on_windows == 0 |
24 if s:on_windows == 0 |
32 echo "Installing Vundle..." |
|
33 echo "" |
|
34 silent !mkdir -p ~/.vim/bundle |
25 silent !mkdir -p ~/.vim/bundle |
35 silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle |
26 silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle |
36 else |
27 else |
37 echo "Installing Vundle and Plugins..." |
|
38 " This happens in a series of minimized cmd windows rather than the cool |
|
39 " progress display we normally get. |
|
40 |
|
41 " Also windows is weird about args and quoting: |
|
42 silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"' |
28 silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"' |
43 silent execute '!git clone https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"' |
29 silent execute '!git clone https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"' |
44 endif |
30 endif |
45 endif |
31 let s:installed_vundle=1 |
46 |
32 endif |
47 if on_windows == 0 |
33 |
|
34 if s:on_windows == 0 |
48 set rtp+=~/.vim/bundle/vundle/ |
35 set rtp+=~/.vim/bundle/vundle/ |
49 call vundle#rc() |
36 call vundle#rc() |
50 else |
37 else |
51 set rtp+=~/vimfiles/bundle/vundle/ |
38 set rtp+=~/vimfiles/bundle/vundle/ |
52 call vundle#rc('~/vimfiles/bundle') |
39 call vundle#rc('~/vimfiles/bundle') |
94 let g:no_viewdoc_maps = 1 |
81 let g:no_viewdoc_maps = 1 |
95 Plugin 'powerman/vim-plugin-viewdoc' |
82 Plugin 'powerman/vim-plugin-viewdoc' |
96 Plugin 'powerman/vim-plugin-AnsiEsc' |
83 Plugin 'powerman/vim-plugin-AnsiEsc' |
97 |
84 |
98 try |
85 try |
99 if on_windows == 1 |
86 execute 'source ' . s:filename . '.local-pre' |
100 source ~/_vimrc.local-pre |
|
101 else |
|
102 source ~/.vimrc.local-pre |
|
103 endif |
|
104 catch |
87 catch |
105 endtry |
88 endtry |
106 |
89 |
107 if installed_vundle == 1 |
90 if s:installed_vundle == 1 |
108 echo "Installing Plugins, please ignore key map error messages" |
91 echo "Installing Plugins, please ignore key map error messages\n" |
109 echo "" |
92 call PluginInstall |
110 :PluginInstall |
|
111 if on_windows == 1 |
|
112 " Windows build just isn't there with exec $0, so we already have some |
|
113 " odd errors and get a weird UI at the end. |
|
114 echo "Please restart vim to continue with plugins installed." |
|
115 quit |
|
116 endif |
|
117 endif |
93 endif |
118 " }}} |
94 " }}} |
119 |
95 |
120 |
96 |
121 " Key maps {{{ |
97 " Key maps {{{ |
130 nmap <silent> <F5> :GundoToggle<CR> |
106 nmap <silent> <F5> :GundoToggle<CR> |
131 nmap <silent> <F8> :TagbarToggle<CR> |
107 nmap <silent> <F8> :TagbarToggle<CR> |
132 |
108 |
133 " This is supposed to get a CtrlP workalike with fuzzy match but i need to fix |
109 " This is supposed to get a CtrlP workalike with fuzzy match but i need to fix |
134 " ignores and always chdir to a good place |
110 " ignores and always chdir to a good place |
135 if on_windows == 1 |
111 if s:on_windows == 1 |
136 nmap <silent> <S-F2> :Unite -start-insert file_rec:!<CR> |
112 nmap <silent> <S-F2> :Unite -start-insert file_rec:!<CR> |
137 else |
113 else |
138 nmap <silent> <S-F2> :Unite -start-insert file_rec/async:!<CR> |
114 nmap <silent> <S-F2> :Unite -start-insert file_rec/async:!<CR> |
139 endif |
115 endif |
140 |
116 |
166 nnoremap <silent> <leader><leader>k :call UncolorAllWords()<CR> |
142 nnoremap <silent> <leader><leader>k :call UncolorAllWords()<CR> |
167 |
143 |
168 nnoremap <silent> <leader>gt :SignifyToggle<CR> |
144 nnoremap <silent> <leader>gt :SignifyToggle<CR> |
169 |
145 |
170 " K: doc, gK: Doc w/o using syntax hints, gKK: doc current filename |
146 " K: doc, gK: Doc w/o using syntax hints, gKK: doc current filename |
171 nmap K :call ViewDoc('doc', '<cword>')<CR> |
147 nmap K :call ViewDoc('doc', expand('<cword>'))<CR> |
172 nmap gK :call ViewDoc('doc', expand('<cword>'))<CR> |
|
173 nmap gKK :call ViewDoc('doc', expand('%'))<CR> |
148 nmap gKK :call ViewDoc('doc', expand('%'))<CR> |
174 |
149 |
175 " Tabular shortcuts |
150 " Tabular shortcuts |
176 map <leader>ta :Tabularize first_arrow<CR> |
151 map <leader>ta :Tabularize first_arrow<CR> |
177 map <leader>te :Tabularize first_eq<CR> |
152 map <leader>te :Tabularize first_eq<CR> |
245 |
220 |
246 set tags+=.tags |
221 set tags+=.tags |
247 |
222 |
248 " Ignore compiled files and repositories |
223 " Ignore compiled files and repositories |
249 set wildignore=*.o,*~,*.pyc |
224 set wildignore=*.o,*~,*.pyc |
250 if on_windows == 1 |
225 if s:on_windows == 1 |
251 set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store |
226 set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store |
252 else |
227 else |
253 set wildignore+=.git\*,.hg\*,.svn\* |
228 set wildignore+=.git\*,.hg\*,.svn\* |
254 endif |
229 endif |
255 |
230 |
270 |
245 |
271 " Superseded by vim-airline |
246 " Superseded by vim-airline |
272 "set statusline=%f%m%r%h%w\ %y\ %=%l,%c\ %p%%\ %L |
247 "set statusline=%f%m%r%h%w\ %y\ %=%l,%c\ %p%%\ %L |
273 set laststatus=2 |
248 set laststatus=2 |
274 |
249 |
275 if on_windows == 1 |
250 if s:on_windows == 1 |
276 let $MYVIM=$HOME.'/vimfiles' |
251 let $MYVIM=$HOME.'/vimfiles' |
277 |
252 |
278 if !filewritable( $MYVIM . '/var' ) |
253 if !filewritable( $MYVIM . '/var' ) |
279 silent execute '!mkdir "'.$HOME.'\vimfiles\var"' |
254 silent execute '!mkdir "'.$HOME.'\vimfiles\var"' |
280 endif |
255 endif |
340 endfunction |
315 endfunction |
341 |
316 |
342 augroup vimrc |
317 augroup vimrc |
343 autocmd! |
318 autocmd! |
344 |
319 |
345 autocmd VimEnter * call AutoSessionConfig() |
320 " set and load a session based on servername |
346 |
321 autocmd VimEnter * call AutoSessionConfig() |
|
322 |
|
323 " complement to autowriteall |
347 autocmd FocusLost * silent! wa |
324 autocmd FocusLost * silent! wa |
348 |
|
349 " preload templates into new buffers by file extension |
|
350 "autocmd BufNewFile * silent! 0r $MYVIM/templates/%:e.template |
|
351 |
|
352 " double-click to edit |
|
353 autocmd FileType vimfiler nmap <buffer> <2-LeftMouse> <Plug>(vimfiler_edit_file) |
|
354 |
325 |
355 " Jump to last known pos |
326 " Jump to last known pos |
356 autocmd BufReadPost * |
327 autocmd BufReadPost * |
357 \ if &filetype != 'mail' && line("'\"") >= 1 && line("'\"") <= line("$") | |
328 \ if &filetype != 'mail' && line("'\"") >= 1 && line("'\"") <= line("$") | |
358 \ exe "normal! g`\"" | |
329 \ exe "normal! g`\"" | |
359 \ endif |
330 \ endif |
|
331 |
|
332 " double-click to edit in vimfiler |
|
333 autocmd FileType vimfiler nmap <buffer> <2-LeftMouse> <Plug>(vimfiler_edit_file) |
|
334 |
360 augroup END |
335 augroup END |
361 |
336 |
|
337 " Make paths when writing, as necessary |
362 function! s:MkNonExDir(file, buf) |
338 function! s:MkNonExDir(file, buf) |
363 if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' |
339 if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' |
364 let dir=fnamemodify(a:file, ':h') |
340 let dir=fnamemodify(a:file, ':h') |
365 if !isdirectory(dir) |
341 if !isdirectory(dir) |
366 call mkdir(dir, 'p') |
342 call mkdir(dir, 'p') |
408 let g:viewdoc_perldoc_format = 'ansi' |
384 let g:viewdoc_perldoc_format = 'ansi' |
409 let g:viewdoc_winwidth_max = 100 |
385 let g:viewdoc_winwidth_max = 100 |
410 |
386 |
411 ">> Gundo |
387 ">> Gundo |
412 " I prefer python3 on windows if I have to use it. Needs a dll in path. |
388 " I prefer python3 on windows if I have to use it. Needs a dll in path. |
413 if on_windows == 1 |
389 if s:on_windows == 1 |
414 let g:gundo_prefer_python3=1 |
390 let g:gundo_prefer_python3=1 |
415 endif |
391 endif |
416 |
392 |
417 |
393 |
418 ">> Tagbar |
394 ">> Tagbar |
419 if on_windows == 1 |
395 if s:on_windows == 1 |
420 if executable('ctags') == 0 |
396 if executable('ctags') == 0 |
421 " if i haven't installed from chocolatey... |
397 " if i haven't installed from chocolatey... |
422 let g:tagbar_ctags_bin = 'C:\Users\mhoward\bin\ctags.exe' |
398 let g:tagbar_ctags_bin = 'C:\Users\mhoward\bin\ctags.exe' |
423 endif |
399 endif |
424 endif |
400 endif |