Changeset 34002 for dotfiles

Show
Ignore:
Timestamp:
06/16/09 12:57:15 (4 years ago)
Author:
from_kyushu
Message:

update NeoComplCache?

Location:
dotfiles/vim/from_kyushu/.vim
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • dotfiles/vim/from_kyushu/.vim/autoload/neocomplcache.vim

    r33998 r34002  
    22" FILE: neocomplcache.vim 
    33" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com> 
    4 " Last Modified: 02 Jun 2009 
     4" Last Modified: 14 Jun 2009 
    55" Usage: Just source this file. 
    66" License: MIT license  {{{ 
     
    2424"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    2525" }}} 
    26 " Version: 2.58, for Vim 7.0 
     26" Version: 2.60, for Vim 7.0 
    2727"============================================================================= 
    2828 
     
    631631            " Sort. 
    632632            call extend(l:cache_keyword_filtered, sort( 
    633                         \filter(copy(l:cache_keyword_list), 'v:val.prev_rank > 0'), 'neocomplcache#compare_prev_rank')) 
     633                        \filter(copy(l:cache_keyword_list), 'v:val.prev_rank > 0 || v:val.prepre_rank > 0'), 'neocomplcache#compare_prev_rank')) 
    634634            call filter(l:cache_keyword_lists[l:plugin], 'v:val.prev_rank == 0 && v:val.prepre_rank == 0') 
    635635        endfor 
     
    641641        call extend(l:cache_keyword_list, l:cache_keyword_lists[l:plugin]) 
    642642    endfor 
    643  
    644     " Filtering for optimize."{{{ 
    645     if !g:NeoComplCache_AlphabeticalOrder 
    646         if len(l:cache_keyword_list) > g:NeoComplCache_MaxList * 10 
    647             call filter(l:cache_keyword_list, 'v:val.rank > 2') 
    648         elseif len(l:cache_keyword_list) > g:NeoComplCache_MaxList * 5 
    649             call filter(l:cache_keyword_list, 'v:val.rank > 1') 
    650         elseif len(l:cache_keyword_list) > g:NeoComplCache_MaxList * 3 
    651             call filter(l:cache_keyword_list, 'v:val.rank > 0') 
    652         endif 
    653     endif"}}} 
    654643 
    655644    " Sort. 
     
    750739    endif 
    751740 
    752     let l:max_len = -1 
    753741    let l:num = 0 
    754742    let l:list = [] 
    755743    for word in split(glob(l:cur_keyword_str . '*'), '\n') 
    756         if len(word) > l:max_len 
    757             let l:max_len = len(word) 
    758         endif 
    759744        call add(list, { 'word' : word, 'menu' : '[F]', 'icase' : 1 }) 
    760745        let l:num += 1 
     
    767752    endif 
    768753    let l:len_prefix = len(l:prefix) 
    769     if l:max_len > g:NeoComplCache_MaxKeywordWidth 
    770         let l:prefix = '...' . l:prefix[l:max_len-g:NeoComplCache_MaxKeywordWidth+3 : ] 
    771     endif 
    772  
     754 
     755    let l:abbr_pattern = printf('%%.%ds..%%s', g:NeoComplCache_MaxKeywordWidth-10) 
    773756    if g:NeoComplCache_EnableQuickMatch"{{{ 
    774757        let l:save_list = l:list 
     
    802785        for keyword in l:save_list[:g:NeoComplCache_QuickMatchMaxLists] 
    803786            let l:abbr = keyword.word[l:len_prefix :] 
     787            if len(l:abbr) > g:NeoComplCache_MaxKeywordWidth 
     788                let l:pre = '...' . l:prefix[len(l:abbr)-g:NeoComplCache_MaxKeywordWidth+3 : ] 
     789                let l:abbr = printf(l:abbr_pattern, l:abbr, l:abbr[-8:]) 
     790            else 
     791                let l:pre = l:prefix 
     792            endif 
    804793            if isdirectory(keyword.word) 
    805794                let l:abbr .= '/' 
    806795            endif 
    807             let keyword.abbr = printf('%2d: %s%s', l:num, l:prefix, l:abbr) 
     796 
     797            let keyword.abbr = printf('%2d: %s%s', l:num, l:pre, l:abbr) 
    808798            let l:num += 1 
    809799 
     
    813803        for keyword in l:cache_keyword_filtered 
    814804            let l:abbr = keyword.word[l:len_prefix :] 
     805            if len(l:abbr) > g:NeoComplCache_MaxKeywordWidth 
     806                let l:pre = '...' . l:prefix[len(l:abbr)-g:NeoComplCache_MaxKeywordWidth+3 : ] 
     807                let l:abbr = printf(l:abbr_pattern, l:abbr, l:abbr[-8:]) 
     808            else 
     809                let l:pre = l:prefix 
     810            endif 
    815811            if isdirectory(keyword.word) 
    816812                let l:abbr .= '/' 
    817813            endif 
    818             let keyword.abbr = '    ' . l:abbr 
     814 
     815            let keyword.abbr = printf('    %s%s', l:pre, l:abbr) 
    819816            call add(l:list, keyword) 
    820817        endfor"}}} 
     
    827824        for keyword in l:list 
    828825            let l:abbr = keyword.word[l:len_prefix :] 
     826            if len(l:abbr) > g:NeoComplCache_MaxKeywordWidth 
     827                let l:pre = '...' . l:prefix[len(l:abbr)-g:NeoComplCache_MaxKeywordWidth+3 : ] 
     828                let l:abbr = printf(l:abbr_pattern, l:abbr, l:abbr[-8:]) 
     829            else 
     830                let l:pre = l:prefix 
     831            endif 
    829832            if isdirectory(keyword.word) 
    830833                let l:abbr .= '/' 
    831834            endif 
    832             let keyword.abbr = l:prefix . l:abbr 
     835 
     836            let keyword.abbr = l:pre . l:abbr 
    833837        endfor 
    834838    endif 
  • dotfiles/vim/from_kyushu/.vim/autoload/neocomplcache/keyword_complete.vim

    r33998 r34002  
    22" FILE: keyword_complete.vim 
    33" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com> 
    4 " Last Modified: 02 Jun 2009 
     4" Last Modified: 04 Jun 2009 
    55" Usage: Just source this file. 
    66" License: MIT license  {{{ 
     
    2424"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    2525" }}} 
    26 " Version: 2.58, for Vim 7.0 
     26" Version: 2.59, for Vim 7.0 
    2727"============================================================================= 
    2828 
     
    3333    augroup neocomplcache"{{{ 
    3434        " Caching events 
    35         autocmd Filetype * call s:check_source() 
     35        autocmd FileType * call s:check_source() 
    3636        autocmd BufWritePost,CursorHold * call s:update_source() 
    3737        " Caching current buffer events 
    38         autocmd InsertLeave * call s:caching_insert_leave() 
     38        autocmd InsertEnter * call s:caching_insert_enter() 
    3939        " Garbage collect. 
    4040        autocmd BufWritePost * call s:garbage_collect_keyword() 
     
    396396endfunction"}}} 
    397397 
    398 function! s:caching(srcname, start_line, end_cache_cnt, add_rank)"{{{ 
     398function! s:caching(srcname, start_line, end_cache_cnt)"{{{ 
    399399    " Check exists s:sources. 
    400400    if !has_key(s:sources, a:srcname) 
     
    454454            if len(l:match_str) >= g:NeoComplCache_MinKeywordLength 
    455455                if !has_key(l:rank_cache_line, l:match_str)  
    456                     let l:rank_cache_line[l:match_str] = { 'rank' : a:add_rank, 'prev_rank' : {}, 'prepre_rank' : {} } 
     456                    let l:rank_cache_line[l:match_str] = { 'rank' : 1, 'prev_rank' : {}, 'prepre_rank' : {} } 
    457457                    let l:match_cache_line = l:rank_cache_line[l:match_str] 
    458458 
     
    472472                else 
    473473                    let l:match_cache_line = l:rank_cache_line[l:match_str] 
    474                     let l:match_cache_line.rank += a:add_rank 
     474                    let l:match_cache_line.rank += 1 
    475475                endif 
    476476 
     
    485485 
    486486                    if has_key(l:match_cache_line.prepre_rank, l:prepre_word) 
    487                         let l:match_cache_line.prepre_rank[l:prepre_word] += a:add_rank 
     487                        let l:match_cache_line.prepre_rank[l:prepre_word] += 1 
    488488                    else 
    489                         let l:match_cache_line.prepre_rank[l:prepre_word] = a:add_rank 
     489                        let l:match_cache_line.prepre_rank[l:prepre_word] = 1 
    490490                    endif 
    491491                endif 
     
    499499 
    500500                if has_key(l:match_cache_line.prev_rank, l:prev_word) 
    501                     let l:match_cache_line.prev_rank[l:prev_word] += a:add_rank 
     501                    let l:match_cache_line.prev_rank[l:prev_word] += 1 
    502502                else 
    503                     let l:match_cache_line.prev_rank[l:prev_word] = a:add_rank 
     503                    let l:match_cache_line.prev_rank[l:prev_word] = 1 
    504504                endif 
    505505 
     
    704704endfunction"}}} 
    705705 
     706function! s:word_caching_current_line()"{{{ 
     707    let l:source = s:sources[bufnr('%')] 
     708 
     709    " Buffer. 
     710    let l:filename = '[B] ' . fnamemodify(l:source.name, ':t') 
     711 
     712    let l:menu = printf('%.' . g:NeoComplCache_MaxFilenameWidth . 's', l:filename) 
     713    let l:abbr_pattern = printf('%%.%ds..%%s', g:NeoComplCache_MaxKeywordWidth-10) 
     714    let l:keyword_pattern = l:source.keyword_pattern 
     715 
     716    " Buffer. 
     717    let l:start_line = (line('.')-1)/l:source.cache_line_cnt*l:source.cache_line_cnt+1 
     718    let l:end_line = l:start_line + l:source.cache_line_cnt 
     719    let l:buflines = join(getbufline(bufnr('%'), l:start_line, l:end_line), "\<CR>") 
     720 
     721    let l:match = match(l:buflines, l:keyword_pattern) 
     722    let l:match_num = 0 
     723    while l:match >= 0 
     724        let l:match_str = matchstr(l:buflines, l:keyword_pattern, l:match) 
     725        " Ignore too short keyword. 
     726        if len(l:match_str) >= g:NeoComplCache_MinKeywordLength 
     727                    \&& !has_key(l:source.keyword_cache, l:match_str) 
     728            " Append list. 
     729            let l:source.keyword_cache[l:match_str] = { 
     730                        \'word' : l:match_str, 'menu' : l:menu, 
     731                        \'filename' : l:filename, 'srcname' : bufnr('%'), 'icase' : 1, 
     732                        \'user_rank' : 0, 'rank' : 1 
     733                        \} 
     734 
     735            let l:source.keyword_cache[l:match_str].abbr =  
     736                        \ (len(l:match_str) > g:NeoComplCache_MaxKeywordWidth)?  
     737                        \ printf(l:abbr_pattern, l:match_str, l:match_str[-8:]) : l:match_str 
     738        endif 
     739 
     740        let l:match_num += len(l:match_str) 
     741        let l:match = match(l:buflines, l:keyword_pattern, l:match_num) 
     742    endwhile 
     743endfunction"}}} 
     744 
    706745function! s:caching_from_cache(srcname)"{{{ 
    707746    if a:srcname =~ '^\d' 
     
    801840    let l:keyword_pattern = l:source.keyword_pattern 
    802841 
    803     let l:match_str = matchstr(l:buflines, l:keyword_pattern) 
     842    let l:match = match(l:buflines, l:keyword_pattern) 
    804843    let l:match_num = 0 
    805     while l:match_str != '' 
     844    while l:match >= 0 
     845        let l:match_str = matchstr(l:buflines, l:keyword_pattern, l:match_num) 
    806846        if has_key(s:candidates, l:match_str) 
    807847            " Remove from candidate. 
     
    814854 
    815855        let l:match_num += len(l:match_str) 
    816         let l:match_str = matchstr(l:buflines, l:keyword_pattern, l:match_num) 
     856        let l:match = match(l:buflines, l:keyword_pattern, l:match_num) 
    817857    endwhile 
    818858 
     
    858898    endif 
    859899 
    860     call s:caching(a:srcname, l:start_line, a:end_cache_cnt, 1) 
     900    call s:caching(a:srcname, l:start_line, a:end_cache_cnt) 
    861901 
    862902    return 0 
     
    912952endfunction"}}} 
    913953 
    914 function! s:caching_insert_leave()"{{{ 
     954function! s:caching_insert_enter()"{{{ 
    915955    if !has_key(s:sources, bufnr('%')) || has_key(s:caching_disable_list, bufnr('%')) || @. == '' 
    916956        return 
     
    919959    if s:prev_cached_count <= 0 
    920960        " Full caching. 
    921         call s:caching(bufnr('%'), line('.'), 1, 2) 
     961        call s:caching(bufnr('%'), line('.'), 1) 
    922962        if g:NeoComplCache_CachingRandomize 
    923             let l:match_end = matchend(reltimestr(reltime()), '\d\+\.') + 1 
     963            let l:match_end = matchend(reltimestr(reltime()), '\d\+\.') 
    924964            let s:prev_cached_count = reltimestr(reltime())[l:match_end : ] % 3 
    925965        else 
     
    927967        endif 
    928968    else 
     969        " Word caching. 
     970        call s:word_caching_current_line() 
     971 
    929972        let s:prev_cached_count -= 1 
    930973    endif 
  • dotfiles/vim/from_kyushu/.vim/autoload/neocomplcache/snippets_complete/c.snip

    r33998 r34002  
    117117    printf("${1}\n"${2});${3} 
    118118 
    119 snippet fpr 
     119snippet fprintf 
    120120    fprintf(${1:stderr}, "${2}\n"${3});${4} 
     121 
     122snippet comment 
     123    /* ${1:comment} */ 
     124    ${2} 
     125 
  • dotfiles/vim/from_kyushu/.vim/plugin/neocomplcache.vim

    r33998 r34002  
    22" FILE: neocomplcache.vim 
    33" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com> 
    4 " Last Modified: 02 Jun 2009 
     4" Last Modified: 14 Jun 2009 
    55" Usage: Just source this file. 
    66" License: MIT license  {{{ 
     
    2424"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    2525" }}} 
    26 " Version: 2.58, for Vim 7.0 
     26" Version: 2.60, for Vim 7.0 
    2727"----------------------------------------------------------------------------- 
    2828" ChangeLog: "{{{ 
    2929" ChangeLog NeoComplCache2: "{{{ 
     30"   2.60: Improved filename completion. 
     31"    - Improved long filename view. 
     32"    - Improved filtering. 
     33"    - Fixed keyword sort bug. 
     34" 
     35"   2.59: Fixed caching bug. 
     36" 
    3037"   2.58: Improved caching timing. 
    3138"    - Optimized caching.