Mercurial > dotfiles.old
comparison vimrc @ 91:97744720e080
Improved neocompleting
author | zegervdv <zegervdv@me.com> |
---|---|
date | Mon, 04 Aug 2014 19:11:35 +0200 |
parents | 3fdc762fe6bb |
children | afe2d02577c2 |
comparison
equal
deleted
inserted
replaced
90:3fdc762fe6bb | 91:97744720e080 |
---|---|
84 set viminfo='10,\"100,:20,%,n~/.viminfo | 84 set viminfo='10,\"100,:20,%,n~/.viminfo |
85 | 85 |
86 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex | 86 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex |
87 | 87 |
88 " set list | 88 " set list |
89 set listchars=tab:▸\ ,eol:¬ | 89 " set listchars=tab:▸\ ,eol:¬ |
90 " }}} | 90 " }}} |
91 " Custom remaps and tricks {{{ | 91 " Custom remaps and tricks {{{ |
92 " When editing a file, always jump to the last known cursor position. | 92 " When editing a file, always jump to the last known cursor position. |
93 " Don't do it for commit messages, when the position is invalid, or when | 93 " Don't do it for commit messages, when the position is invalid, or when |
94 " inside an event handler (happens when dropping a file on gvim). | 94 " inside an event handler (happens when dropping a file on gvim). |
445 " }}} | 445 " }}} |
446 " tComment {{{ | 446 " tComment {{{ |
447 nmap <leader>c <C-_><C-_> | 447 nmap <leader>c <C-_><C-_> |
448 " }}} | 448 " }}} |
449 " Neo Complete {{{ | 449 " Neo Complete {{{ |
450 " Taken from https://github.com/spf13/spf13-vim/blob/3.0/.vimrc | 450 let g:neocomplete#enable_at_startup = 1 |
451 let g:acp_enableAtStartup = 0 | 451 let g:neocomplet#enable_smart_case = 1 |
452 let g:neocomplete#enable_at_startup = 1 | 452 let g:jedi#auto_vim_configuration = 0 |
453 let g:neocomplete#enable_smart_case = 1 | 453 let g:jedi#completions_enabled = 0 |
454 let g:neocomplete#enable_auto_delimiter = 1 | 454 let g:marching_enable_neocomplete = 1 |
455 let g:neocomplete#max_list = 15 | 455 |
456 let g:neocomplete#force_overwrite_completefunc = 1 | 456 inoremap <expr><s-CR> pumvisible() ? neocomplete#smart_close_popup()"\<CR>" : "\<CR>" |
457 | 457 inoremap <expr><C-g> neocomplete#undo_completion() |
458 | 458 inoremap <expr><C-l> neocomplete#complete_common_string() |
459 " Define dictionary. | 459 function! CleverCr() |
460 let g:neocomplete#sources#dictionary#dictionaries = { | 460 if pumvisible() |
461 \ 'default' : '', | 461 if neosnippet#expandable() |
462 \ 'vimshell' : $HOME.'/.vimshell_hist', | 462 let exp = "\<Plug>(neosnippet_expand)" |
463 \ 'scheme' : $HOME.'/.gosh_completions' | 463 return exp . neocomplete#smart_close_popup() |
464 \ } | 464 else |
465 | 465 return neocomplete#smart_close_popup() |
466 " Define keyword. | 466 endif |
467 if !exists('g:neocomplete#keyword_patterns') | 467 else |
468 let g:neocomplete#keyword_patterns = {} | 468 return "\<CR>" |
469 endif | 469 endif |
470 let g:neocomplete#keyword_patterns['default'] = '\h\w*' | 470 endfunction |
471 | 471 " <CR> close popup and save indent or expand snippet |
472 " Plugin key-mappings { | 472 imap <expr> <CR> CleverCr() |
473 " These two lines conflict with the default digraph mapping of <C-K> | |
474 " <C-k> Complete Snippet | |
475 " <C-k> Jump to next snippet point | |
476 imap <silent><expr><C-k> neosnippet#expandable() ? | |
477 \ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ? | |
478 \ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)") | |
479 smap <TAB> <Right><Plug>(neosnippet_jump_or_expand) | |
480 | |
481 inoremap <expr><C-g> neocomplete#undo_completion() | |
482 inoremap <expr><C-l> neocomplete#complete_common_string() | |
483 "inoremap <expr><CR> neocomplete#complete_common_string() | |
484 | |
485 " <CR>: close popup | |
486 " <s-CR>: close popup and save indent. | |
487 inoremap <expr><s-CR> pumvisible() ? neocomplete#smart_close_popup()"\<CR>" : "\<CR>" | |
488 | |
489 function! CleverCr() | |
490 if pumvisible() | |
491 if neosnippet#expandable() | |
492 let exp = "\<Plug>(neosnippet_expand)" | |
493 return exp . neocomplete#smart_close_popup() | |
494 else | |
495 return neocomplete#smart_close_popup() | |
496 endif | |
497 else | |
498 return "\<CR>" | |
499 endif | |
500 endfunction | |
501 | |
502 " <CR> close popup and save indent or expand snippet | |
503 imap <expr> <CR> CleverCr() | |
504 " <C-h>, <BS>: close popup and delete backword char. | |
505 inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>" | |
506 inoremap <expr><C-y> neocomplete#smart_close_popup() | |
507 | |
508 " <TAB>: completion. | |
509 inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
510 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>" | |
511 | |
512 " Courtesy of Matteo Cavalleri | |
513 | |
514 function! CleverTab() | |
515 if pumvisible() | |
516 return "\<C-n>" | |
517 endif | |
518 let substr = strpart(getline('.'), 0, col('.') - 1) | |
519 let substr = matchstr(substr, '[^ \t]*$') | |
520 if strlen(substr) == 0 | |
521 " nothing to match on empty string | |
522 return "\<Tab>" | |
523 else | |
524 " existing text matching | |
525 if neosnippet#expandable_or_jumpable() | |
526 return "\<Plug>(neosnippet_expand_or_jump)" | |
527 else | |
528 return neocomplete#start_manual_complete() | |
529 endif | |
530 endif | |
531 endfunction | |
532 | |
533 imap <expr> <Tab> CleverTab() | |
534 " } | |
535 | |
536 " Enable heavy omni completion. | |
537 if !exists('g:neocomplete#sources#omni#input_patterns') | |
538 let g:neocomplete#sources#omni#input_patterns = {} | |
539 endif | |
540 let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' | |
541 let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::' | |
542 let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' | |
543 let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' | |
544 let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::' | |
545 " } | |
546 " }}} | 473 " }}} |
547 " Neo Snippets {{{ | 474 " Neo Snippets {{{ |
548 imap <C-k> <Plug>(neosnippet_expand_or_jump) | 475 imap <C-k> <Plug>(neosnippet_expand_or_jump) |
549 smap <C-k> <Plug>(neosnippet_expand_or_jump) | 476 smap <C-k> <Plug>(neosnippet_expand_or_jump) |
550 xmap <C-k> <Plug>(neosnippet_expand_target) | 477 xmap <C-k> <Plug>(neosnippet_expand_target) |