Mercurial > dotfiles
comparison vim/vimrc @ 183:8b37877d309f
Merged changes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 20 Jul 2014 19:36:55 -0700 |
parents | 94bf0bd0a788 c6a072353606 |
children | 0ed6642b8db8 |
comparison
equal
deleted
inserted
replaced
182:c1e0af8b032d | 183:8b37877d309f |
---|---|
217 | 217 |
218 " We'll set our own mappings. | 218 " We'll set our own mappings. |
219 let g:ctrlp_map = '' | 219 let g:ctrlp_map = '' |
220 | 220 |
221 " Ctrl-P should manage the working directory. | 221 " Ctrl-P should manage the working directory. |
222 let g:ctrlp_working_path_mode = 2 | 222 let g:ctrlp_working_path_mode = 'ra' |
223 | 223 |
224 " Ctrl-P should however ignore some stuff. | 224 " Ctrl-P should however ignore some stuff. |
225 let g:ctrlp_custom_ignore = { | 225 let g:ctrlp_custom_ignore = { |
226 \ 'dir': '\v[\/](\.git|\.hg|\.svn|venv|build|static|node_modules)$' | 226 \ 'dir': '\v[\/](\.git|\.hg|\.svn|venv|build|static|node_modules)$' |
227 \ } | 227 \ } |
277 | 277 |
278 " File-Specific Settings {{{ | 278 " File-Specific Settings {{{ |
279 | 279 |
280 if has("autocmd") | 280 if has("autocmd") |
281 | 281 |
282 augroup VimRCAutoCWD | |
283 au! | |
284 | |
285 autocmd BufEnter * call s:SetProjectRootCwd() | |
286 augroup END | |
287 | |
282 augroup VimRCFileTypeSettings | 288 augroup VimRCFileTypeSettings |
283 au! | 289 au! |
284 | 290 |
285 " Nice text width for text files. | 291 " Nice text width for text files. |
286 autocmd FileType text,markdown setlocal textwidth=80 | 292 autocmd FileType text,markdown setlocal textwidth=80 |
316 | 322 |
317 " Tab navigation | 323 " Tab navigation |
318 noremap <C-Tab> :tabnext<cr> | 324 noremap <C-Tab> :tabnext<cr> |
319 noremap <C-S-Tab> :tabprevious<cr> | 325 noremap <C-S-Tab> :tabprevious<cr> |
320 | 326 |
327 | |
321 " Window navigation | 328 " Window navigation |
322 nnoremap <C-up> :wincmd k<cr> | 329 nnoremap <C-up> :wincmd k<cr> |
323 nnoremap <C-down> :wincmd j<cr> | 330 nnoremap <C-down> :wincmd j<cr> |
324 nnoremap <C-left> :wincmd h<cr> | 331 nnoremap <C-left> :wincmd h<cr> |
325 nnoremap <C-right> :wincmd l<cr> | 332 nnoremap <C-right> :wincmd l<cr> |
326 | 333 |
327 " Open NERDtree. | |
328 nnoremap <F2> :NERDTreeToggle %:p:h<cr> | |
329 | |
330 " Switch buffers. | 334 " Switch buffers. |
331 nnoremap <F3> :execute ("buffer " . bufname("#"))<cr> | 335 nnoremap <F2> :execute ("buffer " . bufname("#"))<cr> |
332 | 336 |
333 " Gundo. | 337 " NERDTree. |
334 nnoremap <F5> :GundoToggle<cr> | 338 nnoremap <F3> :call <SID>ToggleNERDTree()<cr> |
339 nnoremap <F4> :call <SID>FindInNERDTree()<cr> | |
335 | 340 |
336 " Tagbar. | 341 " Tagbar. |
337 nnoremap <F8> :TagbarToggle<cr> | 342 nnoremap <F5> :TagbarToggle<cr> |
343 nnoremap <F6> :TagbarOpenAutoClose<cr> | |
338 | 344 |
339 " Common typos. | 345 " Common typos. |
340 nnoremap ; : | 346 nnoremap ; : |
341 | 347 |
342 " Split windows | 348 " Split windows |
361 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> | 367 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> |
362 | 368 |
363 " Ctrl-P mappings. | 369 " Ctrl-P mappings. |
364 nnoremap <silent> <C-p> :CtrlP<cr> | 370 nnoremap <silent> <C-p> :CtrlP<cr> |
365 nnoremap <silent> <C-o> :CtrlPBuffer<cr> | 371 nnoremap <silent> <C-o> :CtrlPBuffer<cr> |
366 nnoremap <silent> <C-i> :CtrlPMRU<cr> | 372 nnoremap <silent> <C-i> :CtrlPTag<cr> |
373 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> | |
367 | 374 |
368 " Switch between FR and US keyboard layouts. | 375 " Switch between FR and US keyboard layouts. |
369 nnoremap <C-l>f :setlocal keymap=french<cr> | 376 nnoremap <C-l>f :setlocal keymap=french<cr> |
370 nnoremap <C-l>u :setlocal keymap=<cr> | 377 nnoremap <C-l>u :setlocal keymap=<cr> |
371 | 378 |
461 %s/\s\+$//e | 468 %s/\s\+$//e |
462 let @/='' | 469 let @/='' |
463 call cursor(l, c) | 470 call cursor(l, c) |
464 endfunction | 471 endfunction |
465 | 472 |
473 function! s:FindProjectRoot(cur, marker) abort | |
474 let l:cur = a:cur | |
475 let l:previous_cur = '' | |
476 let l:slash = '/' | |
477 if has('win32') | |
478 let l:slash = '\\' | |
479 endif | |
480 while l:cur != l:previous_cur | |
481 let l:marker_path = l:cur . l:slash . a:marker | |
482 if glob(l:marker_path) != '' | |
483 return fnamemodify(l:cur, ':p') | |
484 endif | |
485 let l:previous_cur = l:cur | |
486 let l:cur = fnamemodify(l:cur, ':h') | |
487 endwhile | |
488 return '' | |
489 endfunction | |
490 | |
491 function! s:SetProjectRootCwd() abort | |
492 let l:cur_file_dir = expand('%:p:h', 1) | |
493 if l:cur_file_dir =~ '\v^.+://' | |
494 return | |
495 endif | |
496 let l:root = l:cur_file_dir | |
497 let l:markers = g:ctrlp_root_markers[:] | |
498 let l:markers += ['.git', '.hg', '.svn', '.bzr', '_darcs'] | |
499 for marker in l:markers | |
500 let l:proj_root = s:FindProjectRoot(l:cur_file_dir, marker) | |
501 if l:proj_root != '' | |
502 let l:root = l:proj_root | |
503 break | |
504 endif | |
505 endfor | |
506 execute 'lcd!' fnameescape(l:root) | |
507 endfunction | |
508 | |
509 function! s:ToggleNERDTree() abort | |
510 let l:was_open = nerdtree#isTreeOpen() | |
511 NERDTreeToggle | |
512 if !l:was_open | |
513 wincmd p | |
514 NERDTreeCWD | |
515 wincmd p | |
516 NERDTreeFind | |
517 endif | |
518 endfunction | |
519 | |
520 function! s:FindInNERDTree() abort | |
521 if !nerdtree#isTreeOpen() | |
522 call s:ToggleNERDTree() | |
523 else | |
524 if getbufvar('%', 'NERDTreeType') != '' | |
525 wincmd p | |
526 else | |
527 NERDTreeFind | |
528 endif | |
529 endif | |
530 endfunction | |
531 | |
466 " }}} | 532 " }}} |
467 | 533 |
468 " Temporary stuff {{{ | 534 " Temporary stuff {{{ |
469 | 535 |
470 " Enable debugging Lawrencium | 536 " Enable debugging Lawrencium |
472 let g:lawrencium_trace = 0 | 538 let g:lawrencium_trace = 0 |
473 | 539 |
474 command! LawrenciumEnableTrace :call lawrencium#debugtrace(1) | 540 command! LawrenciumEnableTrace :call lawrencium#debugtrace(1) |
475 command! LawrenciumDisableTrace :call lawrencium#debugtrace(0) | 541 command! LawrenciumDisableTrace :call lawrencium#debugtrace(0) |
476 | 542 |
543 let g:autotags_debug = 1 | |
544 | |
477 " Enable debugging PieCrust | 545 " Enable debugging PieCrust |
478 let g:piecrust_debug = 1 | 546 let g:piecrust_debug = 1 |
479 let g:piecrust_trace = 0 | 547 let g:piecrust_trace = 0 |
480 | 548 |
481 " }}} | 549 " }}} |
482 | 550 |
551 " Local override {{{ | |
552 | |
553 let s:local_vimrc = s:vim_home.'/vimrc.local' | |
554 if filereadable(s:local_vimrc) | |
555 execute 'source' s:local_vimrc | |
556 endif | |
557 | |
558 " }}} | |
559 |