" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish autoload/neocomplcache/cache.vim [[[1 403 "============================================================================= " FILE: cache.vim " AUTHOR: Shougo Matsushita " Last Modified: 01 Sep 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditionneocomplcache#cache# " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= " Cache loader. function! neocomplcache#cache#load_from_cache(cache_dir, filename)"{{{ if neocomplcache#cache#check_old_cache(a:cache_dir, a:filename) return [] endif let l:keyword_lists = [] let l:lines = readfile(neocomplcache#cache#encode_name(a:cache_dir, a:filename)) let l:max_lines = len(l:lines) if empty(l:lines) return [] endif if l:max_lines > 3000 call neocomplcache#print_caching('Caching from cache "' . a:filename . '"... please wait.') endif if l:max_lines > 10000 let l:print_cache_percent = l:max_lines / 5 elseif l:max_lines > 5000 let l:print_cache_percent = l:max_lines / 4 elseif l:max_lines > 3000 let l:print_cache_percent = l:max_lines / 3 else let l:print_cache_percent = -1 endif let l:line_cnt = l:print_cache_percent try let l:line_num = 1 for l:line in l:lines"{{{ " Percentage check."{{{ if l:print_cache_percent > 0 if l:line_cnt == 0 call neocomplcache#print_caching(printf('Caching(%s): %d%%', a:filename, l:line_num*100 / l:max_lines)) let l:line_cnt = l:print_cache_percent endif let l:line_cnt -= 1 let l:line_num += 1 endif "}}} let l:cache = split(l:line, '|||', 1) let l:keyword = { \ 'word' : l:cache[0], 'abbr' : l:cache[1], 'menu' : l:cache[2], \} if l:cache[3] != '' let l:keyword.kind = l:cache[3] endif if l:cache[4] != '' let l:keyword.class = l:cache[4] endif call add(l:keyword_lists, l:keyword) endfor"}}} catch /E684:/ call neocomplcache#print_error(v:exception) call neocomplcache#print_error('Error occured while analyzing cache!') let l:cache_dir = g:neocomplcache_temporary_dir . '/' . a:cache_dir call neocomplcache#print_error('Please delete cache directory: ' . l:cache_dir) return [] endtry if l:max_lines > 3000 call neocomplcache#print_caching('') endif return l:keyword_lists endfunction"}}} function! neocomplcache#cache#index_load_from_cache(cache_dir, filename, completion_length)"{{{ let l:keyword_lists = {} for l:keyword in neocomplcache#cache#load_from_cache(a:cache_dir, a:filename) let l:key = tolower(l:keyword.word[: a:completion_length-1]) if !has_key(l:keyword_lists, l:key) let l:keyword_lists[l:key] = [] endif call add(l:keyword_lists[l:key], l:keyword) endfor return l:keyword_lists endfunction"}}} function! neocomplcache#cache#load_from_file(filename, pattern, mark)"{{{ if bufloaded(a:filename) let l:lines = getbufline(bufnr(a:filename), 1, '$') elseif filereadable(a:filename) let l:lines = readfile(a:filename) else " File not found. return [] endif let l:max_lines = len(l:lines) let l:menu = printf('[%s] %.' . g:neocomplcache_max_filename_width . 's', a:mark, fnamemodify(a:filename, ':t')) if l:max_lines > 1000 call neocomplcache#print_caching('Caching from file "' . a:filename . '"... please wait.') endif if l:max_lines > 10000 let l:print_cache_percent = l:max_lines / 9 elseif l:max_lines > 7000 let l:print_cache_percent = l:max_lines / 6 elseif l:max_lines > 5000 let l:print_cache_percent = l:max_lines / 5 elseif l:max_lines > 3000 let l:print_cache_percent = l:max_lines / 4 elseif l:max_lines > 2000 let l:print_cache_percent = l:max_lines / 3 elseif l:max_lines > 1000 let l:print_cache_percent = l:max_lines / 2 else return s:load_from_file_fast(l:lines, a:pattern, l:menu) endif let l:line_cnt = l:print_cache_percent let l:line_num = 1 let l:keyword_lists = [] let l:dup_check = {} let l:keyword_pattern2 = '^\%('.a:pattern.'\m\)' for l:line in l:lines"{{{ " Percentage check."{{{ if l:print_cache_percent > 0 if l:line_cnt == 0 call neocomplcache#print_caching(printf('Caching(%s): %d%%', a:filename, l:line_num*100 / l:max_lines)) let l:line_cnt = l:print_cache_percent endif let l:line_cnt -= 1 let l:line_num += 1 endif "}}} let l:match = match(l:line, a:pattern) while l:match >= 0"{{{ let l:match_str = matchstr(l:line, l:keyword_pattern2, l:match) " Ignore too short keyword. if !has_key(l:dup_check, l:match_str) && len(l:match_str) >= g:neocomplcache_min_keyword_length " Append list. call add(l:keyword_lists, { 'word' : l:match_str, 'menu' : l:menu }) let l:dup_check[l:match_str] = 1 endif let l:match = match(l:line, a:pattern, l:match + len(l:match_str)) endwhile"}}} endfor"}}} if l:max_lines > 1000 call neocomplcache#print_caching('') endif return l:keyword_lists endfunction"}}} function! s:load_from_file_fast(lines, pattern, menu)"{{{ let l:line_num = 1 let l:keyword_lists = [] let l:dup_check = {} let l:keyword_pattern2 = '^\%('.a:pattern.'\m\)' let l:line = join(a:lines) let l:match = match(l:line, a:pattern) while l:match >= 0"{{{ let l:match_str = matchstr(l:line, l:keyword_pattern2, l:match) " Ignore too short keyword. if !has_key(l:dup_check, l:match_str) && len(l:match_str) >= g:neocomplcache_min_keyword_length " Append list. call add(l:keyword_lists, { 'word' : l:match_str, 'menu' : a:menu }) let l:dup_check[l:match_str] = 1 endif let l:match = match(l:line, a:pattern, l:match + len(l:match_str)) endwhile"}}} return l:keyword_lists endfunction"}}} function! neocomplcache#cache#load_from_tags(cache_dir, filename, tags_list, mark, filetype)"{{{ let l:max_lines = len(a:tags_list) if l:max_lines > 1000 call neocomplcache#print_caching('Caching from tags "' . a:filename . '"... please wait.') endif if l:max_lines > 10000 let l:print_cache_percent = l:max_lines / 9 elseif l:max_lines > 7000 let l:print_cache_percent = l:max_lines / 6 elseif l:max_lines > 5000 let l:print_cache_percent = l:max_lines / 5 elseif l:max_lines > 3000 let l:print_cache_percent = l:max_lines / 4 elseif l:max_lines > 2000 let l:print_cache_percent = l:max_lines / 3 elseif l:max_lines > 1000 let l:print_cache_percent = l:max_lines / 2 else let l:print_cache_percent = -1 endif let l:line_cnt = l:print_cache_percent let l:menu_pattern = printf('[%s] %%.%ds %%.%ds', a:mark, g:neocomplcache_max_filename_width, g:neocomplcache_max_filename_width) let l:keyword_lists = [] let l:dup_check = {} let l:line_num = 1 try for l:line in a:tags_list"{{{ " Percentage check."{{{ if l:line_cnt == 0 call neocomplcache#print_caching(printf('Caching(%s): %d%%', a:filename, l:line_num*100 / l:max_lines)) let l:line_cnt = l:print_cache_percent endif let l:line_cnt -= 1"}}} let l:tag = split(substitute(l:line, "\", '', 'g'), '\t', 1) " Add keywords. if l:line !~ '^!' && len(l:tag) >= 3 && len(l:tag[0]) >= g:neocomplcache_min_keyword_length \&& !has_key(l:dup_check, l:tag[0]) let l:option = { \ 'cmd' : substitute(substitute(l:tag[2], '^\%([/?]\^\)\?\s*\|\%(\$\?[/?]\)\?;"$', '', 'g'), '\\\\', '\\', 'g'), \ 'kind' : '' \} if l:option.cmd =~ '\d\+' let l:option.cmd = l:tag[0] endif for l:opt in l:tag[3:] let l:key = matchstr(l:opt, '^\h\w*\ze:') if l:key == '' let l:option['kind'] = l:opt else let l:option[l:key] = matchstr(l:opt, '^\h\w*:\zs.*') endif endfor if has_key(l:option, 'file') || (has_key(l:option, 'access') && l:option.access != 'public') let l:line_num += 1 continue endif let l:abbr = has_key(l:option, 'signature')? l:tag[0] . l:option.signature : (l:option['kind'] == 'd' || l:option['cmd'] == '')? l:tag[0] : l:option['cmd'] let l:keyword = { \ 'word' : l:tag[0], 'abbr' : l:abbr, 'kind' : l:option['kind'], 'dup' : 1, \} if has_key(l:option, 'struct') let keyword.menu = printf(l:menu_pattern, fnamemodify(l:tag[1], ':t'), l:option.struct) let keyword.class = l:option.struct elseif has_key(l:option, 'class') let keyword.menu = printf(l:menu_pattern, fnamemodify(l:tag[1], ':t'), l:option.class) let keyword.class = l:option.class elseif has_key(l:option, 'enum') let keyword.menu = printf(l:menu_pattern, fnamemodify(l:tag[1], ':t'), l:option.enum) let keyword.class = l:option.enum elseif has_key(l:option, 'union') let keyword.menu = printf(l:menu_pattern, fnamemodify(l:tag[1], ':t'), l:option.union) let keyword.class = l:option.union else let keyword.menu = printf(l:menu_pattern, fnamemodify(l:tag[1], ':t'), '') let keyword.class = '' endif call add(l:keyword_lists, l:keyword) let l:dup_check[l:tag[0]] = 1 endif let l:line_num += 1 endfor"}}} catch /E684:/ call neocomplcache#print_warning('Error occured while analyzing tags!') call neocomplcache#print_warning(v:exception) let l:log_file = g:neocomplcache_temporary_dir . '/' . a:cache_dir . '/error_log' call neocomplcache#print_warning('Please look tags file: ' . l:log_file) call writefile(a:tags_list, l:log_file) return [] endtry if l:max_lines > 1000 call neocomplcache#print_caching('') endif if a:filetype != '' && has_key(g:neocomplcache_tags_filter_patterns, a:filetype) call filter(l:keyword_lists, g:neocomplcache_tags_filter_patterns[a:filetype]) endif return l:keyword_lists endfunction"}}} function! neocomplcache#cache#save_cache(cache_dir, filename, keyword_list)"{{{ " Create cache directory. call neocomplcache#cache#check_dir(a:cache_dir) let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) " Create dictionary key. for keyword in a:keyword_list if !has_key(keyword, 'kind') let keyword.kind = '' endif if !has_key(keyword, 'class') let keyword.class = '' endif if !has_key(keyword, 'abbr') let keyword.abbr = keyword.word endif endfor " Output cache. let l:word_list = [] for keyword in a:keyword_list call add(l:word_list, printf('%s|||%s|||%s|||%s|||%s', \keyword.word, keyword.abbr, keyword.menu, keyword.kind, keyword.class)) endfor call writefile(l:word_list, l:cache_name) endfunction"}}} " Cache helper. function! neocomplcache#cache#getfilename(cache_dir, filename)"{{{ let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) return l:cache_name endfunction"}}} function! neocomplcache#cache#filereadable(cache_dir, filename)"{{{ let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) return filereadable(l:cache_name) endfunction"}}} function! neocomplcache#cache#readfile(cache_dir, filename)"{{{ let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) return filereadable(l:cache_name) ? readfile(l:cache_name) : [] endfunction"}}} function! neocomplcache#cache#writefile(cache_dir, filename, list)"{{{ call neocomplcache#cache#check_dir(a:cache_dir) let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) call writefile(a:list, l:cache_name) endfunction"}}} function! neocomplcache#cache#encode_name(cache_dir, filename) let l:dir = printf('%s/%s/', g:neocomplcache_temporary_dir, a:cache_dir) return l:dir . s:create_hash(l:dir, a:filename) endfunction function! neocomplcache#cache#check_dir(cache_dir)"{{{ " Check cache directory. let l:cache_dir = g:neocomplcache_temporary_dir . '/' . a:cache_dir if !isdirectory(l:cache_dir) call mkdir(l:cache_dir, 'p') endif endfunction"}}} function! neocomplcache#cache#check_old_cache(cache_dir, filename)"{{{ " Check old cache file. let l:cache_name = neocomplcache#cache#encode_name(a:cache_dir, a:filename) return getftime(l:cache_name) == -1 || getftime(l:cache_name) <= getftime(a:filename) endfunction"}}} " Check md5. let s:is_md5 = exists('*md5#md5') function! s:create_hash(dir, str) if len(a:dir) + len(a:str) < 150 let l:hash = substitute(substitute(a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g') elseif s:is_md5 " Use md5.vim. let l:hash = md5#md5(a:str) else " Use simple hash. let l:sum = 0 for i in range(len(a:str)) let l:sum += char2nr(a:str[i]) * 2 endfor let l:hash = printf('%x', l:sum) endif return l:hash endfunction " vim: foldmethod=marker autoload/neocomplcache/sources/abbrev_complete.vim [[[1 65 "============================================================================= " FILE: abbrev_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 17 Aug 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'abbrev_complete', \ 'kind' : 'plugin', \} function! s:source.initialize()"{{{ " Initialize. endfunction"}}} function! s:source.finalize()"{{{ endfunction"}}} function! s:source.get_keyword_list(cur_keyword_str)"{{{ " Get current abbrev list. let l:abbrev_list = '' redir => l:abbrev_list silent! iabbrev redir END let l:list = [] for l:line in split(l:abbrev_list, '\n') let l:abbrev = split(l:line) if l:abbrev[0] !~ '^[!i]$' " No abbreviation found. return [] endif call add(l:list, \{ 'word' : l:abbrev[1], 'menu' : printf('[A] %.'. g:neocomplcache_max_filename_width.'s', l:abbrev[2]) }) endfor return neocomplcache#keyword_filter(l:list, a:cur_keyword_str) endfunction"}}} function! neocomplcache#sources#abbrev_complete#define()"{{{ return s:source endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/buffer_complete.vim [[[1 682 "============================================================================= " FILE: buffer_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 16 Sep 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= " Important variables. if !exists('s:buffer_sources') let s:buffer_sources = {} endif let s:source = { \ 'name' : 'buffer_complete', \ 'kind' : 'plugin', \} function! s:source.initialize()"{{{ augroup neocomplcache"{{{ " Caching events autocmd FileType,BufWritePost * call s:check_source() autocmd CursorHold * call s:rank_caching_current_cache_line(1) autocmd InsertEnter,CursorHoldI * call s:rank_caching_current_cache_line(0) autocmd InsertLeave * call neocomplcache#sources#buffer_complete#caching_current_cache_line() autocmd VimLeavePre * call s:save_all_cache() augroup END"}}} " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'buffer_complete', 4) " Set completion length. call neocomplcache#set_completion_length('buffer_complete', 0) " Create cache directory. if !isdirectory(g:neocomplcache_temporary_dir . '/buffer_cache') call mkdir(g:neocomplcache_temporary_dir . '/buffer_cache', 'p') endif " Initialize script variables."{{{ let s:buffer_sources = {} let s:filetype_frequencies = {} let s:cache_line_count = 70 let s:rank_cache_count = 1 let s:disable_caching_list = {} let s:completion_length = g:neocomplcache_auto_completion_start_length "}}} " Add commands."{{{ command! -nargs=? -complete=buffer NeoComplCacheCachingBuffer call s:caching_buffer() command! -nargs=? -complete=buffer NeoComplCachePrintSource call s:print_source() command! -nargs=? -complete=buffer NeoComplCacheOutputKeyword call s:output_keyword() command! -nargs=? -complete=buffer NeoComplCacheSaveCache call s:save_all_cache() command! -nargs=? -complete=buffer NeoComplCacheDisableCaching call s:disable_caching() command! -nargs=? -complete=buffer NeoComplCacheEnableCaching call s:enable_caching() "}}} " Initialize cache. call s:check_source() endfunction "}}} function! s:source.finalize()"{{{ delcommand NeoComplCacheCachingBuffer delcommand NeoComplCachePrintSource delcommand NeoComplCacheOutputKeyword delcommand NeoComplCacheSaveCache delcommand NeoComplCacheDisableCaching delcommand NeoComplCacheEnableCaching call s:save_all_cache() let s:buffer_sources = {} endfunction"}}} function! s:source.get_keyword_list(cur_keyword_str)"{{{ if neocomplcache#is_auto_complete() && len(a:cur_keyword_str) < s:completion_length " Check member prefix pattern. let l:filetype = neocomplcache#get_context_filetype() if !has_key(g:neocomplcache_member_prefix_patterns, l:filetype) \ || g:neocomplcache_member_prefix_patterns[l:filetype] == '' return [] endif let l:cur_text = neocomplcache#get_cur_text() let l:var_name = matchstr(l:cur_text, '\%(\h\w*\%(()\?\)\?\%(' . \ g:neocomplcache_member_prefix_patterns[l:filetype] . '\m\)\)\+$') if l:var_name == '' return [] endif let l:keyword_list = [] for src in s:get_sources_list() if has_key(s:buffer_sources[src].member_cache, l:var_name) let l:keyword_list += values(s:buffer_sources[src].member_cache[l:var_name]) endif endfor return l:keyword_list endif let l:keyword_list = [] let l:current = bufnr('%') if len(a:cur_keyword_str) < s:completion_length || \neocomplcache#check_match_filter(a:cur_keyword_str, s:completion_length) for src in s:get_sources_list() let l:keyword_cache = neocomplcache#keyword_filter( \neocomplcache#unpack_dictionary_dictionary(s:buffer_sources[src].keyword_cache), a:cur_keyword_str) if src == l:current call s:calc_frequency(l:keyword_cache) endif let l:keyword_list += l:keyword_cache endfor else let l:key = tolower(a:cur_keyword_str[: s:completion_length-1]) for src in s:get_sources_list() if has_key(s:buffer_sources[src].keyword_cache, l:key) let l:keyword_cache = neocomplcache#keyword_filter(values(s:buffer_sources[src].keyword_cache[l:key]), a:cur_keyword_str) if src == l:current call s:calc_frequency(l:keyword_cache) endif let l:keyword_list += l:keyword_cache endif endfor endif return l:keyword_list endfunction"}}} function! neocomplcache#sources#buffer_complete#define()"{{{ return s:source endfunction"}}} function! neocomplcache#sources#buffer_complete#get_frequencies()"{{{ let l:filetype = neocomplcache#get_context_filetype() if !has_key(s:filetype_frequencies, l:filetype) return {} endif return s:filetype_frequencies[l:filetype] endfunction"}}} function! neocomplcache#sources#buffer_complete#caching_current_cache_line()"{{{ " Current line caching. if !s:exists_current_source() || has_key(s:disable_caching_list, bufnr('%')) return endif let l:source = s:buffer_sources[bufnr('%')] let l:filename = fnamemodify(l:source.name, ':t') let l:menu = printf('[B] %.' . g:neocomplcache_max_filename_width . 's', l:filename) let l:keyword_pattern = l:source.keyword_pattern let l:keyword_pattern2 = '^\%('.l:keyword_pattern.'\m\)' let l:keywords = l:source.keyword_cache let l:line = join(getline(line('.')-1, line('.')+1)) let l:match = match(l:line, l:keyword_pattern) while l:match >= 0"{{{ let l:match_str = matchstr(l:line, l:keyword_pattern2, l:match) " Ignore too short keyword. if len(l:match_str) >= g:neocomplcache_min_keyword_length"{{{ " Check dup. let l:key = tolower(l:match_str[: s:completion_length-1]) if !has_key(l:keywords, l:key) let l:keywords[l:key] = {} endif if !has_key(l:keywords[l:key], l:match_str) " Append list. let l:keywords[l:key][l:match_str] = { 'word' : l:match_str, 'menu' : l:menu } endif endif"}}} " Next match. let l:match = match(l:line, l:keyword_pattern, l:match + len(l:match_str)) endwhile"}}} endfunction"}}} function! s:calc_frequency(list)"{{{ if !s:exists_current_source() return endif let l:list_len = len(a:list) if l:list_len > g:neocomplcache_max_list * 5 let l:calc_cnt = 15 elseif l:list_len > g:neocomplcache_max_list * 3 let l:calc_cnt = 13 elseif l:list_len > g:neocomplcache_max_list let l:calc_cnt = 10 elseif l:list_len > g:neocomplcache_max_list / 2 let l:calc_cnt = 8 elseif l:list_len > g:neocomplcache_max_list / 3 let l:calc_cnt = 5 elseif l:list_len > g:neocomplcache_max_list / 4 let l:calc_cnt = 4 else let l:calc_cnt = 3 endif let l:source = s:buffer_sources[bufnr('%')] let l:frequencies = l:source.frequencies let l:filetype = neocomplcache#get_context_filetype() if !has_key(s:filetype_frequencies, l:filetype) let s:filetype_frequencies[l:filetype] = {} endif let l:filetype_frequencies = s:filetype_frequencies[l:filetype] for keyword in a:list if s:rank_cache_count <= 0 " Set rank. let l:word = keyword.word let l:frequency = 0 for rank_lines in values(l:source.rank_lines) if has_key(rank_lines, l:word) let l:frequency += rank_lines[l:word] endif endfor if !has_key(l:filetype_frequencies, l:word) let l:filetype_frequencies[l:word] = 0 endif if has_key(l:frequencies, l:word) let l:filetype_frequencies[l:word] -= l:frequencies[l:word] endif if l:frequency == 0 " Garbage collect let l:ignorecase_save = &ignorecase let &ignorecase = 0 let l:pos = searchpos(neocomplcache#escape_match(l:word), 'ncw', 0) let &ignorecase = l:ignorecase_save if l:pos[0] == 0 " Delete. let l:key = tolower(l:word[: s:completion_length-1]) if has_key(l:source.keyword_cache[l:key], l:word) call remove(l:source.keyword_cache[l:key], l:word) endif if has_key(l:source.frequencies, l:word) call remove(l:source.frequencies, l:word) endif if l:filetype_frequencies[l:word] == 0 call remove(l:filetype_frequencies, l:word) endif else let l:frequencies[l:word] = 1 let l:filetype_frequencies[l:word] += 1 endif else let l:frequencies[l:word] = l:frequency let l:filetype_frequencies[l:word] += l:frequency endif " Reset count. let s:rank_cache_count = neocomplcache#rand(l:calc_cnt) endif let s:rank_cache_count -= 1 endfor endfunction"}}} function! s:get_sources_list()"{{{ let l:sources_list = [] let l:filetypes = neocomplcache#get_source_filetypes(neocomplcache#get_context_filetype()) for key in keys(s:buffer_sources) if has_key(l:filetypes, s:buffer_sources[key].filetype) || bufnr('%') == key call add(l:sources_list, key) endif endfor return l:sources_list endfunction"}}} function! s:rank_caching_current_cache_line(is_force)"{{{ if !s:exists_current_source() || neocomplcache#is_locked() return endif let l:source = s:buffer_sources[bufnr('%')] let l:filename = fnamemodify(l:source.name, ':t') let l:start_line = (line('.')-1)/l:source.cache_line_cnt*l:source.cache_line_cnt+1 let l:end_line = l:start_line + l:source.cache_line_cnt-1 let l:cache_num = (l:start_line-1) / l:source.cache_line_cnt " For debugging. "echomsg printf("start=%d, end=%d", l:start_line, l:end_line) if !a:is_force && has_key(l:source.rank_lines, l:cache_num) return endif " Clear cache line. let l:source.rank_lines[l:cache_num] = {} let l:rank_lines = l:source.rank_lines[l:cache_num] let l:buflines = getline(l:start_line, l:end_line) let l:menu = printf('[B] %.' . g:neocomplcache_max_filename_width . 's', l:filename) let l:keyword_pattern = l:source.keyword_pattern let l:keyword_pattern2 = '^\%('.l:keyword_pattern.'\m\)' let [l:line_num, l:max_lines] = [0, len(l:buflines)] while l:line_num < l:max_lines let l:line = buflines[l:line_num] let l:match = match(l:line, l:keyword_pattern) while l:match >= 0"{{{ let l:match_str = matchstr(l:line, l:keyword_pattern2, l:match) " Ignore too short keyword. if len(l:match_str) >= g:neocomplcache_min_keyword_length"{{{ if !has_key(l:rank_lines, l:match_str) let l:rank_lines[l:match_str] = 1 else let l:rank_lines[l:match_str] += 1 endif endif"}}} " Next match. let l:match = match(l:line, l:keyword_pattern, l:match + len(l:match_str)) endwhile"}}} let l:line_num += 1 endwhile let l:filetype = neocomplcache#get_context_filetype(1) if !has_key(g:neocomplcache_member_prefix_patterns, l:filetype) \ || g:neocomplcache_member_prefix_patterns[l:filetype] == '' return endif let l:menu = '[B] member' let l:keyword_pattern = '\%(\h\w*\%(()\?\)\?\%(' . g:neocomplcache_member_prefix_patterns[l:filetype] . '\m\)\)\+\h\w*\%(()\?\)\?' let l:keyword_pattern2 = '^'.l:keyword_pattern let l:member_pattern = '\h\w*\%(()\?\)\?$' " Cache member pattern. let [l:line_num, l:max_lines] = [0, len(l:buflines)] while l:line_num < l:max_lines let l:line = buflines[l:line_num] let l:match = match(l:line, l:keyword_pattern) while l:match >= 0"{{{ let l:match_str = matchstr(l:line, l:keyword_pattern2, l:match) " Next match. let l:match = matchend(l:line, l:keyword_pattern, l:match + len(l:match_str)) while l:match_str != '' let l:member_name = matchstr(l:match_str, l:member_pattern) let l:var_name = l:match_str[ : -len(l:member_name)-1] if !has_key(l:source.member_cache, l:var_name) let l:source.member_cache[l:var_name] = {} endif if !has_key(l:source.member_cache[l:var_name], l:member_name) let l:source.member_cache[l:var_name][l:member_name] = { 'word' : l:member_name, 'menu' : l:menu } endif let l:match_str = matchstr(l:var_name, l:keyword_pattern2) endwhile endwhile"}}} let l:line_num += 1 endwhile endfunction"}}} function! s:initialize_source(srcname)"{{{ let l:filename = fnamemodify(bufname(a:srcname), ':t') " Set cache line count. let l:buflines = getbufline(a:srcname, 1, '$') let l:end_line = len(l:buflines) if l:end_line > 150 let cnt = 0 for line in l:buflines[50:150] let cnt += len(line) endfor if cnt <= 3000 let l:cache_line_cnt = s:cache_line_count elseif cnt <= 4000 let l:cache_line_cnt = s:cache_line_count*7 / 10 elseif cnt <= 5000 let l:cache_line_cnt = s:cache_line_count / 2 elseif cnt <= 7500 let l:cache_line_cnt = s:cache_line_count / 3 elseif cnt <= 10000 let l:cache_line_cnt = s:cache_line_count / 5 elseif cnt <= 12000 let l:cache_line_cnt = s:cache_line_count / 7 elseif cnt <= 14000 let l:cache_line_cnt = s:cache_line_count / 10 else let l:cache_line_cnt = s:cache_line_count / 13 endif elseif l:end_line > 100 let l:cache_line_cnt = s:cache_line_count / 3 else let l:cache_line_cnt = s:cache_line_count / 5 endif let l:ft = getbufvar(a:srcname, '&filetype') if l:ft == '' let l:ft = 'nothing' endif let l:keyword_pattern = neocomplcache#get_keyword_pattern(l:ft) let s:buffer_sources[a:srcname] = { \'keyword_cache' : {}, 'rank_lines' : {}, 'member_cache' : {}, \'name' : l:filename, 'filetype' : l:ft, 'keyword_pattern' : l:keyword_pattern, \'end_line' : l:end_line , 'cache_line_cnt' : l:cache_line_cnt, \'frequencies' : {}, 'check_sum' : len(join(l:buflines[:4], '\n')) \} endfunction"}}} function! s:word_caching(srcname)"{{{ " Initialize source. call s:initialize_source(a:srcname) if s:caching_from_cache(a:srcname) == 0 " Caching from cache. return endif let l:bufname = bufname(str2nr(a:srcname)) if fnamemodify(l:bufname, ':t') ==# '[Command Line]' " Ignore caching. return endif let l:keyword_cache = s:buffer_sources[a:srcname].keyword_cache for l:keyword in neocomplcache#cache#load_from_file(bufname(str2nr(a:srcname)), s:buffer_sources[a:srcname].keyword_pattern, 'B') let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:keyword_cache, l:key) let l:keyword_cache[l:key] = {} endif let l:keyword_cache[l:key][l:keyword.word] = l:keyword endfor endfunction"}}} function! s:caching_from_cache(srcname)"{{{ if getbufvar(a:srcname, '&buftype') =~ 'nofile' return -1 endif let l:srcname = fnamemodify(bufname(str2nr(a:srcname)), ':p') if neocomplcache#cache#check_old_cache('buffer_cache', l:srcname) return -1 endif let l:source = s:buffer_sources[a:srcname] for l:keyword in neocomplcache#cache#load_from_cache('buffer_cache', l:srcname) let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:source.keyword_cache, l:key) let l:source.keyword_cache[l:key] = {} endif let l:source.keyword_cache[l:key][l:keyword.word] = l:keyword endfor return 0 endfunction"}}} function! s:check_changed_buffer(bufnumber)"{{{ let l:source = s:buffer_sources[a:bufnumber] if getbufvar(a:bufnumber, '&buftype') =~ 'nofile' " Check buffer changed. let l:check_sum = len(join(getbufline(a:bufnumber, 1, 5), '\n')) if l:check_sum != l:source.check_sum " Recaching. return 1 endif endif let l:ft = getbufvar(a:bufnumber, '&filetype') if l:ft == '' let l:ft = 'nothing' endif return s:buffer_sources[a:bufnumber].name != fnamemodify(bufname(a:bufnumber), ':t') \ || s:buffer_sources[a:bufnumber].filetype != l:ft endfunction"}}} function! s:check_source()"{{{ call s:check_deleted_buffer() let l:bufnumber = 1 " Check new buffer. while l:bufnumber <= bufnr('$') if bufwinnr(l:bufnumber) >= 0 let l:bufname = fnamemodify(bufname(l:bufnumber), ':p') if (!has_key(s:buffer_sources, l:bufnumber) || s:check_changed_buffer(l:bufnumber)) \&& !has_key(s:disable_caching_list, l:bufnumber) \&& (g:neocomplcache_disable_caching_buffer_name_pattern == '' || l:bufname !~ g:neocomplcache_disable_caching_buffer_name_pattern) \&& !neocomplcache#is_locked(l:bufnumber) if getfsize(l:bufname) < g:neocomplcache_caching_limit_file_size \ && ((g:neocomplcache_force_caching_buffer_name_pattern != '' && l:bufname =~ g:neocomplcache_force_caching_buffer_name_pattern) \ || (getbufvar(l:bufnumber, '&modifiable') && !getbufvar(l:bufnumber, '&readonly') && getbufvar(l:bufnumber, '&buftype') !~ 'help') \) " Caching. call s:word_caching(l:bufnumber) endif endif endif let l:bufnumber += 1 endwhile endfunction"}}} function! s:check_deleted_buffer()"{{{ " Check deleted buffer. for key in keys(s:buffer_sources) if !bufloaded(str2nr(key)) " Save cache. call s:save_cache(key) " Remove item. call remove(s:buffer_sources, key) endif endfor endfunction"}}} function! s:exists_current_source()"{{{ return has_key(s:buffer_sources, bufnr('%')) endfunction"}}} function! s:save_cache(srcname)"{{{ if s:buffer_sources[a:srcname].end_line < 500 return endif if getbufvar(a:srcname, '&buftype') =~ 'nofile' return endif let l:srcname = fnamemodify(bufname(str2nr(a:srcname)), ':p') if !filereadable(l:srcname) return endif let l:cache_name = neocomplcache#cache#encode_name('buffer_cache', l:srcname) if getftime(l:cache_name) >= getftime(l:srcname) return -1 endif " Output buffer. call neocomplcache#cache#save_cache('buffer_cache', l:srcname, neocomplcache#unpack_dictionary_dictionary(s:buffer_sources[a:srcname].keyword_cache)) endfunction "}}} function! s:save_all_cache()"{{{ for l:key in keys(s:buffer_sources) call s:save_cache(l:key) endfor endfunction"}}} " Command functions."{{{ function! s:caching_buffer(name)"{{{ if a:name == '' let l:number = bufnr('%') else let l:number = bufnr(a:name) if l:number < 0 call neocomplcache#print_error('Invalid buffer name.') return endif endif " Word recaching. call s:word_caching(l:number) endfunction"}}} function! s:print_source(name)"{{{ if a:name == '' let l:number = bufnr('%') else let l:number = bufnr(a:name) if l:number < 0 call neocomplcache#print_error('Invalid buffer name.') return endif endif if !has_key(s:buffer_sources, l:number) return endif silent put=printf('Print neocomplcache %d source.', l:number) for l:key in keys(s:buffer_sources[l:number]) silent put =printf('%s => %s', l:key, string(s:buffer_sources[l:number][l:key])) endfor endfunction"}}} function! s:output_keyword(name)"{{{ if a:name == '' let l:number = bufnr('%') else let l:number = bufnr(a:name) if l:number < 0 call neocomplcache#print_error('Invalid buffer name.') return endif endif if !has_key(s:buffer_sources, l:number) return endif " Output buffer. for keyword in neocomplcache#unpack_dictionary_dictionary(s:buffer_sources[l:number].keyword_cache) silent put=string(keyword) endfor endfunction "}}} function! s:disable_caching(name)"{{{ if a:number == '' let l:number = bufnr('%') else let l:number = bufnr(a:name) if l:number < 0 call neocomplcache#print_error('Invalid buffer name.') return endif endif let s:disable_caching_list[l:number] = 1 if has_key(s:buffer_sources, l:number) " Delete source. call remove(s:buffer_sources, l:number) endif endfunction"}}} function! s:enable_caching(name)"{{{ if a:number == '' let l:number = bufnr('%') else let l:number = bufnr(a:number) if l:number < 0 call neocomplcache#print_error('Invalid buffer name.') return endif endif if has_key(s:disable_caching_list, l:number) call remove(s:disable_caching_list, l:number) endif endfunction"}}} "}}} " vim: foldmethod=marker autoload/neocomplcache/sources/completefunc_complete.vim [[[1 114 "============================================================================= " FILE: completefunc_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 25 Jul 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'completefunc_complete', \ 'kind' : 'complfunc', \} function! s:source.initialize()"{{{ " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'completefunc_complete', 5) endfunction"}}} function! s:source.finalize()"{{{ endfunction"}}} function! s:source.get_keyword_pos(cur_text)"{{{ return -1 endfunction"}}} function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{ return [] endfunction"}}} function! neocomplcache#sources#completefunc_complete#define()"{{{ return s:source endfunction"}}} function! neocomplcache#sources#completefunc_complete#call_completefunc(funcname)"{{{ let l:cur_text = neocomplcache#get_cur_text() " Save pos. let l:pos = getpos('.') let l:line = getline('.') let l:cur_keyword_pos = call(a:funcname, [1, '']) " Restore pos. call setpos('.', l:pos) if l:cur_keyword_pos < 0 return '' endif let l:cur_keyword_str = l:cur_text[l:cur_keyword_pos :] let l:pos = getpos('.') let l:list = call(a:funcname, [0, l:cur_keyword_str]) call setpos('.', l:pos) if empty(l:list) return '' endif let l:list = s:get_completefunc_list(l:list) " Start manual complete. return neocomplcache#start_manual_complete_list(l:cur_keyword_pos, l:cur_keyword_str, l:list) endfunction"}}} function! s:get_completefunc_list(list)"{{{ let l:comp_list = [] " Convert string list. for str in filter(copy(a:list), 'type(v:val) == '.type('')) let l:dict = { 'word' : str, 'menu' : '[C]' } call add(l:comp_list, l:dict) endfor for l:comp in filter(a:list, 'type(v:val) != '.type('')) let l:dict = { \'word' : l:comp.word, 'menu' : '[C]', \'abbr' : has_key(l:comp, 'abbr')? l:comp.abbr : l:comp.word \} if has_key(l:comp, 'kind') let l:dict.kind = l:comp.kind endif if has_key(l:comp, 'menu') let l:dict.menu .= ' ' . l:comp.menu endif call add(l:comp_list, l:dict) endfor return l:comp_list endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/dictionary_complete.vim [[[1 152 "============================================================================= " FILE: dictionary_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 29 Aug 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'dictionary_complete', \ 'kind' : 'plugin', \} function! s:source.initialize()"{{{ " Initialize. let s:dictionary_list = {} let s:completion_length = neocomplcache#get_auto_completion_length('dictionary_complete') " Initialize dictionary."{{{ if !exists('g:neocomplcache_dictionary_filetype_lists') let g:neocomplcache_dictionary_filetype_lists = {} endif if !has_key(g:neocomplcache_dictionary_filetype_lists, 'default') let g:neocomplcache_dictionary_filetype_lists['default'] = '' endif "}}} " Set caching event. autocmd neocomplcache FileType * call s:caching() " Add command. command! -nargs=? -complete=customlist,neocomplcache#filetype_complete NeoComplCacheCachingDictionary call s:recaching() " Create cache directory. if !isdirectory(g:neocomplcache_temporary_dir . '/dictionary_cache') call mkdir(g:neocomplcache_temporary_dir . '/dictionary_cache') endif " Initialize check. call s:caching() endfunction"}}} function! s:source.finalize()"{{{ delcommand NeoComplCacheCachingDictionary endfunction"}}} function! s:source.get_keyword_list(cur_keyword_str)"{{{ let l:list = [] let l:key = neocomplcache#is_text_mode() ? 'text' : neocomplcache#get_context_filetype() if neocomplcache#is_text_mode() && !has_key(s:dictionary_list, 'text') " Caching. call s:caching() endif for l:source in neocomplcache#get_sources_list(s:dictionary_list, l:key) let l:list += neocomplcache#dictionary_filter(l:source, a:cur_keyword_str, s:completion_length) endfor return l:list endfunction"}}} function! neocomplcache#sources#dictionary_complete#define()"{{{ return s:source endfunction"}}} function! s:caching()"{{{ if !bufloaded(bufnr('%')) return endif let l:key = neocomplcache#is_text_mode() ? 'text' : neocomplcache#get_context_filetype() for l:filetype in keys(neocomplcache#get_source_filetypes(l:key)) if !has_key(s:dictionary_list, l:filetype) let s:dictionary_list[l:filetype] = s:initialize_dictionary(l:filetype) endif endfor endfunction"}}} function! s:recaching(filetype)"{{{ if a:filetype == '' let l:filetype = neocomplcache#get_context_filetype(1) else let l:filetype = a:filetype endif " Caching. let s:dictionary_list[l:filetype] = s:caching_from_dict(l:filetype) endfunction"}}} function! s:initialize_dictionary(filetype)"{{{ let l:keyword_lists = neocomplcache#cache#index_load_from_cache('dictionary_cache', a:filetype, s:completion_length) if !empty(l:keyword_lists) " Caching from cache. return l:keyword_lists endif return s:caching_from_dict(a:filetype) endfunction"}}} function! s:caching_from_dict(filetype)"{{{ if has_key(g:neocomplcache_dictionary_filetype_lists, a:filetype) let l:dictionaries = g:neocomplcache_dictionary_filetype_lists[a:filetype] elseif a:filetype != &filetype || &l:dictionary == '' return {} else let l:dictionaries = &l:dictionary endif let l:keyword_list = [] for l:dictionary in split(l:dictionaries, ',') if filereadable(l:dictionary) let l:keyword_list += neocomplcache#cache#load_from_file(l:dictionary, \neocomplcache#get_keyword_pattern(a:filetype), 'D') endif endfor let l:keyword_dict = {} for l:keyword in l:keyword_list let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:keyword_dict, l:key) let l:keyword_dict[l:key] = [] endif call add(l:keyword_dict[l:key], l:keyword) endfor " Save dictionary cache. call neocomplcache#cache#save_cache('dictionary_cache', a:filetype, neocomplcache#unpack_dictionary(l:keyword_dict)) return l:keyword_dict endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/filename_complete.vim [[[1 179 "============================================================================= " FILE: filename_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 29 Sep 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'filename_complete', \ 'kind' : 'complfunc', \} function! s:source.initialize()"{{{ " Initialize. let s:skip_dir = {} let s:completion_length = neocomplcache#get_auto_completion_length('filename_complete') " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'filename_complete', 2) endfunction"}}} function! s:source.finalize()"{{{ endfunction"}}} function! s:source.get_keyword_pos(cur_text)"{{{ if &filetype ==# 'vimshell' || neocomplcache#within_comment() return -1 endif let l:is_win = has('win32') || has('win64') " Not Filename pattern. if a:cur_text =~ \'\*$\|\.\.\+$\|[/\\][/\\]\f*$\|/c\%[ygdrive/]$\|\\|$\|\a:[^/]*$' return -1 endif " Filename pattern. let l:pattern = neocomplcache#get_keyword_pattern_end('filename') let [l:cur_keyword_pos, l:cur_keyword_str] = neocomplcache#match_word(a:cur_text, l:pattern) if neocomplcache#is_auto_complete() && len(l:cur_keyword_str) < s:completion_length return -1 endif " Not Filename pattern. if l:is_win && &filetype == 'tex' && l:cur_keyword_str =~ '\\' return -1 endif " Skip directory. if neocomplcache#is_auto_complete() let l:dir = simplify(fnamemodify(l:cur_keyword_str, ':p:h')) if l:dir != '' && has_key(s:skip_dir, l:dir) return -1 endif endif return l:cur_keyword_pos endfunction"}}} function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{ let l:cur_keyword_str = escape(a:cur_keyword_str, '[]') let l:is_win = has('win32') || has('win64') if a:cur_keyword_str =~ '^\$\h\w*' let l:env = matchstr(a:cur_keyword_str, '^\$\h\w*') let l:env_ev = eval(l:env) if l:is_win let l:env_ev = substitute(l:env_ev, '\\', '/', 'g') endif let l:len_env = len(l:env_ev) else let l:len_env = 0 if a:cur_keyword_str =~ '^\~\h\w*' let l:cur_keyword_str = simplify($HOME . '/../' . l:cur_keyword_str[1:]) endif endif let l:cur_keyword_str = substitute(l:cur_keyword_str, '\\ ', ' ', 'g') " Glob by directory name. let l:cur_keyword_str = substitute(l:cur_keyword_str, '\%(^\.\|/\.\?\)\?\zs[^/]*$', '', '') let l:path = (!neocomplcache#is_auto_complete() && a:cur_keyword_str !~ '^\.\.\?/')? &path : ',' let l:glob = (l:cur_keyword_str !~ '\*$')? l:cur_keyword_str . '*' : l:cur_keyword_str try let l:files = split(substitute(globpath(l:path, l:glob), '\\', '/', 'g'), '\n') catch return [] endtry if empty(l:files) " Add '*' to a delimiter. let l:cur_keyword_str = substitute(l:cur_keyword_str, '\w\+\ze[/._-]', '\0*', 'g') let l:glob = (l:cur_keyword_str !~ '\*$')? l:cur_keyword_str . '*' : l:cur_keyword_str try let l:files = split(substitute(globpath(l:path, l:glob), '\\', '/', 'g'), '\n') catch return [] endtry endif if empty(l:files) || (neocomplcache#is_auto_complete() && len(l:files) > g:neocomplcache_max_list) return [] endif let l:dir_list = [] let l:file_list = [] let l:home_pattern = '^'.substitute($HOME, '\\', '/', 'g').'/' let l:paths = map(split(&path, ','), 'substitute(v:val, "\\\\", "/", "g")') let l:exts = escape(substitute($PATHEXT, ';', '\\|', 'g'), '.') for word in l:files let l:dict = { 'word' : word, 'menu' : '[F]' } let l:cur_keyword_str = $HOME . '/../' . l:cur_keyword_str[1:] if l:len_env != 0 && l:dict.word[: l:len_env-1] == l:env_ev let l:dict.word = l:env . l:dict.word[l:len_env :] elseif a:cur_keyword_str =~ '^\~/' let l:dict.word = substitute(word, l:home_pattern, '\~/', '') elseif !neocomplcache#is_auto_complete() && a:cur_keyword_str !~ '^\.\.\?/' " Path search. for path in l:paths if path != '' && neocomplcache#head_match(word, path . '/') let l:dict.word = l:dict.word[len(path)+1 : ] break endif endfor endif let l:abbr = l:dict.word if isdirectory(l:word) let l:abbr .= '/' if g:neocomplcache_enable_auto_delimiter let l:dict.word .= '/' endif elseif l:is_win if '.'.fnamemodify(l:word, ':e') =~ l:exts let l:abbr .= '*' endif elseif executable(l:word) let l:abbr .= '*' endif let l:dict.abbr = l:abbr " Escape word. let l:dict.word = escape(l:dict.word, ' *?[]"={}') call add(isdirectory(l:word) ? l:dir_list : l:file_list, l:dict) endfor return neocomplcache#keyword_filter(l:dir_list, a:cur_keyword_str) + neocomplcache#keyword_filter(l:file_list, a:cur_keyword_str) endfunction"}} function! neocomplcache#sources#filename_complete#define()"{{{ return s:source endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/include_complete.vim [[[1 382 "============================================================================= " FILE: include_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 30 Sep 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:include_info = {} let s:source = { \ 'name' : 'include_complete', \ 'kind' : 'plugin', \} function! s:source.initialize()"{{{ " Initialize let s:include_info = {} let s:include_cache = {} let s:cached_pattern = {} let s:completion_length = neocomplcache#get_auto_completion_length('include_complete') " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'include_complete', 7) augroup neocomplcache " Caching events autocmd FileType * call s:check_buffer_all() autocmd BufWritePost * call s:check_buffer('') augroup END " Initialize include pattern."{{{ call neocomplcache#set_dictionary_helper(g:neocomplcache_include_patterns, 'java,haskell', '^import') "}}} " Initialize expr pattern."{{{ call neocomplcache#set_dictionary_helper(g:neocomplcache_include_exprs, 'haskell', \'substitute(v:fname,''\\.'',''/'',''g'')') "}}} " Initialize path pattern."{{{ "}}} " Initialize suffixes pattern."{{{ call neocomplcache#set_dictionary_helper(g:neocomplcache_include_suffixes, 'haskell', '.hs') "}}} " Create cache directory. if !isdirectory(g:neocomplcache_temporary_dir . '/include_cache') call mkdir(g:neocomplcache_temporary_dir . '/include_cache', 'p') endif " Add command. command! -nargs=? -complete=buffer NeoComplCacheCachingInclude call s:check_buffer() if neocomplcache#exists_echodoc() call echodoc#register('include_complete', s:doc_dict) endif " Initialize check. call s:check_buffer_all() endfunction"}}} function! s:source.finalize()"{{{ delcommand NeoComplCacheCachingInclude if neocomplcache#exists_echodoc() call echodoc#unregister('include_complete') endif endfunction"}}} function! s:source.get_keyword_list(cur_keyword_str)"{{{ if !has_key(s:include_info, bufnr('%')) || neocomplcache#within_comment() return [] endif let l:keyword_list = [] if len(a:cur_keyword_str) < s:completion_length || \neocomplcache#check_match_filter(a:cur_keyword_str, s:completion_length) for l:include in s:include_info[bufnr('%')].include_files if !bufloaded(l:include) let l:keyword_list += neocomplcache#unpack_dictionary(s:include_cache[l:include]) endif endfor else let l:key = tolower(a:cur_keyword_str[: s:completion_length-1]) for l:include in s:include_info[bufnr('%')].include_files if !bufloaded(l:include) && has_key(s:include_cache[l:include], l:key) let l:keyword_list += s:include_cache[l:include][l:key] endif endfor endif return neocomplcache#keyword_filter(neocomplcache#dup_filter(l:keyword_list), a:cur_keyword_str) endfunction"}}} function! neocomplcache#sources#include_complete#define()"{{{ return s:source endfunction"}}} function! neocomplcache#sources#include_complete#get_include_files(bufnumber)"{{{ if has_key(s:include_info, a:bufnumber) return s:include_info[a:bufnumber].include_files else return [] endif endfunction"}}} " For echodoc."{{{ let s:doc_dict = { \ 'name' : 'include_complete', \ 'rank' : 5, \ 'filetypes' : {}, \ } function! s:doc_dict.search(cur_text)"{{{ if &filetype ==# 'vim' || !has_key(s:include_info, bufnr('%')) return [] endif " Collect words. let l:words = [] let i = 0 while i >= 0 let l:word = matchstr(a:cur_text, '\k\+', i) if len(l:word) >= s:completion_length call add(l:words, l:word) endif let i = matchend(a:cur_text, '\k\+', i) endwhile for l:word in reverse(l:words) let l:key = tolower(l:word[: s:completion_length-1]) for l:include in s:include_info[bufnr('%')].include_files if has_key(s:include_cache[l:include], l:key) let l:cache = filter(copy(s:include_cache[l:include][l:key]), 'stridx(v:val.word, ' . string(l:word) . ') == 0') if !empty(l:cache) && has_key(l:cache[0], 'kind') && l:cache[0].kind != '' let l:match = match(neocomplcache#escape_match(l:cache[0].abbr), l:word) if l:match >= 0 let l:ret = [] if l:match > 0 call add(l:ret, { 'text' : l:cache[0].abbr[ : l:match-1] }) endif call add(l:ret, { 'text' : l:word, 'highlight' : 'Identifier' }) call add(l:ret, { 'text' : l:cache[0].abbr[l:match+len(l:word) :] }) if l:match > 0 || len(l:ret[-1].text) > 0 return l:ret endif endif endif endif endfor endfor return [] endfunction"}}} "}}} function! s:check_buffer_all()"{{{ let l:bufnumber = 1 " Check buffer. while l:bufnumber <= bufnr('$') if bufloaded(l:bufnumber) && !has_key(s:include_info, l:bufnumber) call s:check_buffer(bufname(l:bufnumber)) endif let l:bufnumber += 1 endwhile endfunction"}}} function! s:check_buffer(bufname)"{{{ let l:bufname = fnamemodify((a:bufname == '' ? bufname('%') : a:bufname), ':p') let l:bufnumber = bufnr(l:bufname) let s:include_info[l:bufnumber] = {} if (g:neocomplcache_disable_caching_buffer_name_pattern == '' || l:bufname !~ g:neocomplcache_disable_caching_buffer_name_pattern) \&& getbufvar(l:bufnumber, '&readonly') == 0 let l:filetype = getbufvar(l:bufnumber, '&filetype') if l:filetype == '' let l:filetype = 'nothing' endif " Check include. let l:include_files = s:get_buffer_include_files(l:bufnumber) for l:filename in l:include_files if !has_key(s:include_cache, l:filename) " Caching. let s:include_cache[l:filename] = s:load_from_tags(l:filename, l:filetype) endif endfor let s:include_info[l:bufnumber].include_files = l:include_files else let s:include_info[l:bufnumber].include_files = [] endif endfunction"}}} function! s:get_buffer_include_files(bufnumber)"{{{ let l:filetype = getbufvar(a:bufnumber, '&filetype') if l:filetype == '' return [] endif if l:filetype == 'python' \ && !has_key(g:neocomplcache_include_paths, 'python') \ && executable('python') " Initialize python path pattern. call neocomplcache#set_dictionary_helper(g:neocomplcache_include_paths, 'python', \ neocomplcache#system('python -', 'import sys;sys.stdout.write(",".join(sys.path))')) elseif l:filetype == 'cpp' \ && !neocomplcache#is_win() " Add cpp path. call neocomplcache#set_dictionary_helper(g:neocomplcache_include_paths, 'cpp', \ getbufvar(a:bufnumber, '&path') . ',/usr/include/c++/*') endif let l:pattern = has_key(g:neocomplcache_include_patterns, l:filetype) ? \g:neocomplcache_include_patterns[l:filetype] : getbufvar(a:bufnumber, '&include') if l:pattern == '' return [] endif let l:path = has_key(g:neocomplcache_include_paths, l:filetype) ? \g:neocomplcache_include_paths[l:filetype] : getbufvar(a:bufnumber, '&path') let l:expr = has_key(g:neocomplcache_include_exprs, l:filetype) ? \g:neocomplcache_include_exprs[l:filetype] : getbufvar(a:bufnumber, '&includeexpr') if has_key(g:neocomplcache_include_suffixes, l:filetype) let l:suffixes = &l:suffixesadd endif " Change current directory. let l:cwd_save = getcwd() if isdirectory(fnamemodify(bufname(a:bufnumber), ':p:h')) lcd `=fnamemodify(bufname(a:bufnumber), ':p:h')` endif let l:include_files = s:get_include_files(0, getbufline(a:bufnumber, 1, 100), l:filetype, l:pattern, l:path, l:expr) lcd `=l:cwd_save` " Restore option. if has_key(g:neocomplcache_include_suffixes, l:filetype) let &l:suffixesadd = l:suffixes endif return l:include_files endfunction"}}} function! s:get_include_files(nestlevel, lines, filetype, pattern, path, expr)"{{{ let l:include_files = [] for l:line in a:lines"{{{ if l:line =~ a:pattern let l:match_end = matchend(l:line, a:pattern) if a:expr != '' let l:eval = substitute(a:expr, 'v:fname', string(matchstr(l:line[l:match_end :], '\f\+')), 'g') let l:filename = fnamemodify(findfile(eval(l:eval), a:path), ':p') else let l:filename = fnamemodify(findfile(matchstr(l:line[l:match_end :], '\f\+'), a:path), ':p') endif if filereadable(l:filename) && getfsize(l:filename) < g:neocomplcache_caching_limit_file_size call add(l:include_files, l:filename) if (a:filetype == 'c' || a:filetype == 'cpp') && a:nestlevel < 1 let l:include_files += s:get_include_files(a:nestlevel + 1, readfile(l:filename)[:100], \a:filetype, a:pattern, a:path, a:expr) endif endif endif endfor"}}} return l:include_files endfunction"}}} function! s:load_from_tags(filename, filetype)"{{{ " Initialize include list from tags. let l:keyword_lists = s:load_from_cache(a:filename) if !empty(l:keyword_lists) || getfsize(neocomplcache#cache#encode_name('include_cache', a:filename)) == 0 return l:keyword_lists endif if !executable(g:neocomplcache_ctags_program) return s:load_from_file(a:filename, a:filetype) endif let l:args = has_key(g:neocomplcache_ctags_arguments_list, a:filetype) ? \g:neocomplcache_ctags_arguments_list[a:filetype] : g:neocomplcache_ctags_arguments_list['default'] let l:command = has('win32') || has('win64') ? \printf('%s -f - %s %s', g:neocomplcache_ctags_program, l:args, fnamemodify(a:filename, ':p:.')) : \printf('%s -f /dev/stdout 2>/dev/null %s %s', g:neocomplcache_ctags_program, l:args, fnamemodify(a:filename, ':p:.')) let l:lines = split(neocomplcache#system(l:command), '\n') if !empty(l:lines) " Save ctags file. call neocomplcache#cache#writefile('include_tags', a:filename, l:lines) endif let l:keyword_lists = {} for l:keyword in neocomplcache#cache#load_from_tags('include_cache', a:filename, l:lines, 'I', a:filetype) let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:keyword_lists, l:key) let l:keyword_lists[l:key] = [] endif call add(l:keyword_lists[l:key], l:keyword) endfor call neocomplcache#cache#save_cache('include_cache', a:filename, neocomplcache#unpack_dictionary(l:keyword_lists)) if empty(l:keyword_lists) return s:load_from_file(a:filename, a:filetype) endif return l:keyword_lists endfunction"}}} function! s:load_from_file(filename, filetype)"{{{ " Initialize include list from file. let l:keyword_lists = {} let l:loaded_list = neocomplcache#cache#load_from_file(a:filename, neocomplcache#get_keyword_pattern(), 'I') if len(l:loaded_list) > 300 call neocomplcache#cache#save_cache('include_cache', a:filename, l:loaded_list) endif for l:keyword in l:loaded_list let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:keyword_lists, l:key) let l:keyword_lists[l:key] = [] endif call add(l:keyword_lists[l:key], l:keyword) endfor"}}} return l:keyword_lists endfunction"}}} function! s:load_from_cache(filename)"{{{ let l:keyword_lists = {} for l:keyword in neocomplcache#cache#load_from_cache('include_cache', a:filename) let l:keyword.dup = 1 let l:key = tolower(l:keyword.word[: s:completion_length-1]) if !has_key(l:keyword_lists, l:key) let l:keyword_lists[l:key] = [] endif call add(l:keyword_lists[l:key], l:keyword) endfor return l:keyword_lists endfunction"}}} " Global options definition."{{{ if !exists('g:neocomplcache_include_patterns') let g:neocomplcache_include_patterns = {} endif if !exists('g:neocomplcache_include_exprs') let g:neocomplcache_include_exprs = {} endif if !exists('g:neocomplcache_include_paths') let g:neocomplcache_include_paths = {} endif if !exists('g:neocomplcache_include_suffixes') let g:neocomplcache_include_suffixes = {} endif "}}} " vim: foldmethod=marker autoload/neocomplcache/sources/keyword_complete.vim [[[1 96 "============================================================================= " FILE: keyword_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 20 Aug 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'keyword_complete', \ 'kind' : 'complfunc', \} function! s:source.initialize()"{{{ " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'keyword_complete', 5) " Set completion length. call neocomplcache#set_completion_length('keyword_complete', 0) " Initialize. for l:plugin in values(neocomplcache#available_plugins()) call l:plugin.initialize() endfor endfunction"}}} function! s:source.finalize()"{{{ for l:plugin in values(neocomplcache#available_plugins()) call l:plugin.finalize() endfor endfunction"}}} function! s:source.get_keyword_pos(cur_text)"{{{ let [l:cur_keyword_pos, l:cur_keyword_str] = neocomplcache#match_word(a:cur_text) if l:cur_keyword_pos < 0 " Empty string. return len(a:cur_text) endif return l:cur_keyword_pos endfunction"}}} function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{ " Get keyword list. let l:cache_keyword_list = [] for [l:name, l:plugin] in items(neocomplcache#available_plugins()) if (has_key(g:neocomplcache_plugin_disable, l:name) \ && g:neocomplcache_plugin_disable[l:name]) \ || len(a:cur_keyword_str) < neocomplcache#get_completion_length(l:name) " Skip plugin. continue endif try let l:list = l:plugin.get_keyword_list(a:cur_keyword_str) catch call neocomplcache#print_error(v:throwpoint) call neocomplcache#print_error(v:exception) call neocomplcache#print_error('Error occured in plugin''s get_keyword_list()!') call neocomplcache#print_error('Plugin name is ' . l:name) return [] endtry let l:rank = has_key(g:neocomplcache_plugin_rank, l:name)? \ g:neocomplcache_plugin_rank[l:name] : g:neocomplcache_plugin_rank['keyword_complete'] for l:keyword in l:list let l:keyword.rank = l:rank endfor let l:cache_keyword_list += l:list endfor return l:cache_keyword_list endfunction"}}} function! neocomplcache#sources#keyword_complete#define()"{{{ return s:source endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/omni_complete.vim [[[1 253 "============================================================================= " FILE: omni_complete.vim " AUTHOR: Shougo Matsushita " Last Modified: 04 Sep 2010 " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " }}} "============================================================================= let s:source = { \ 'name' : 'omni_complete', \ 'kind' : 'complfunc', \} function! s:source.initialize()"{{{ " Initialize omni completion pattern."{{{ if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif "if has('ruby') "try "ruby 1 "call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'ruby', "\'[^. *\t]\.\h\w*\|\h\w*::') "catch "endtry "endif if has('python') try python 1 call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'python', \'[^. \t]\.\w*') catch endtry endif call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'html,xhtml,xml,markdown', \'<[^>]*') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'css', \'^\s\+\w+\|\w+[):;]?\s\+\|[@!]') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'javascript', \'[^. \t]\.\%(\h\w*\)\?') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'actionscript', \'[^. \t][.:]\h\w*') "call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'php', "\'[^. \t]->\h\w*\|\$\h\w*\|\%(=\s*new\|extends\)\s\+\|\h\w*::') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'java', \'\%(\h\w*\|)\)\.') "call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'perl', "\'\h\w*->\h\w*\|\h\w*::') "call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'c', "\'\h\w\+\|\%(\h\w*\|)\)\%(\.\|->\)\h\w*') "call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'cpp', "\'\h\w*\%(\.\|->\)\h\w*\|\h\w*::') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'vimshell', \'\%(\\[^[:alnum:].-]\|[[:alnum:]@/.-_+,#$%~=*]\)\{2,}') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'objc', \'\h\w\+\|\h\w*\%(\.\|->\)\h\w*') call neocomplcache#set_dictionary_helper(g:neocomplcache_omni_patterns, 'objj', \'[\[ \.]\w\+$\|:\w*$') "}}} " Initialize omni function list."{{{ if !exists('g:neocomplcache_omni_functions') let g:neocomplcache_omni_functions = {} endif "}}} " Set rank. call neocomplcache#set_dictionary_helper(g:neocomplcache_plugin_rank, 'omni_complete', 100) " Set completion length. call neocomplcache#set_completion_length('omni_complete', 0) endfunction"}}} function! s:source.finalize()"{{{ endfunction"}}} function! s:source.get_keyword_pos(cur_text)"{{{ if neocomplcache#within_comment() return -1 endif let l:filetype = neocomplcache#get_context_filetype() if neocomplcache#is_eskk_enabled() let l:omnifunc = &l:omnifunc elseif has_key(g:neocomplcache_omni_functions, l:filetype) let l:omnifunc = g:neocomplcache_omni_functions[l:filetype] elseif &filetype == l:filetype let l:omnifunc = &l:omnifunc else " &omnifunc is irregal. return -1 endif if l:omnifunc == '' return -1 endif if has_key(g:neocomplcache_omni_patterns, l:omnifunc) let l:pattern = g:neocomplcache_omni_patterns[l:omnifunc] elseif l:filetype != '' && has_key(g:neocomplcache_omni_patterns, l:filetype) let l:pattern = g:neocomplcache_omni_patterns[l:filetype] else let l:pattern = '' endif if !neocomplcache#is_eskk_enabled() && l:pattern == '' return -1 endif let l:is_wildcard = g:neocomplcache_enable_wildcard && a:cur_text =~ '\*\w\+$' \&& neocomplcache#is_auto_complete() " Check wildcard. if l:is_wildcard " Check wildcard. let l:cur_text = a:cur_text[: match(a:cur_text, '\%(\*\w\+\)\+$') - 1] else let l:cur_text = a:cur_text endif if !neocomplcache#is_eskk_enabled() \ && l:cur_text !~ '\%(' . l:pattern . '\m\)$' return -1 endif " Save pos. let l:pos = getpos('.') let l:line = getline('.') if neocomplcache#is_auto_complete() && l:is_wildcard call setline('.', l:cur_text) endif try let l:cur_keyword_pos = call(l:omnifunc, [1, '']) catch call neocomplcache#print_error(v:exception) let l:cur_keyword_pos = -1 endtry " Restore pos. if neocomplcache#is_auto_complete() && l:is_wildcard call setline('.', l:line) endif call setpos('.', l:pos) return l:cur_keyword_pos endfunction"}}} function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{ let l:is_wildcard = g:neocomplcache_enable_wildcard && a:cur_keyword_str =~ '\*\w\+$' \&& neocomplcache#is_eskk_enabled() && neocomplcache#is_auto_complete() let l:filetype = neocomplcache#get_context_filetype() if neocomplcache#is_eskk_enabled() let l:omnifunc = &l:omnifunc elseif has_key(g:neocomplcache_omni_functions, l:filetype) let l:omnifunc = g:neocomplcache_omni_functions[l:filetype] elseif &filetype == l:filetype let l:omnifunc = &l:omnifunc endif let l:pos = getpos('.') if l:is_wildcard " Check wildcard. let l:cur_keyword_str = a:cur_keyword_str[: match(a:cur_keyword_str, '\%(\*\w\+\)\+$') - 1] else let l:cur_keyword_str = a:cur_keyword_str endif try if l:filetype == 'ruby' && l:is_wildcard let l:line = getline('.') let l:cur_text = neocomplcache#get_cur_text() call setline('.', l:cur_text[: match(l:cur_text, '\%(\*\w\+\)\+$') - 1]) endif let l:list = call(l:omnifunc, [0, (l:filetype == 'ruby')? '' : l:cur_keyword_str]) if l:filetype == 'ruby' && l:is_wildcard call setline('.', l:line) endif catch call neocomplcache#print_error(v:exception) let l:list = [] endtry call setpos('.', l:pos) if empty(l:list) return [] endif if l:is_wildcard let l:list = neocomplcache#keyword_filter(s:get_omni_list(l:list), a:cur_keyword_str) else let l:list = s:get_omni_list(l:list) endif return l:list endfunction"}}} function! neocomplcache#sources#omni_complete#define()"{{{ return s:source endfunction"}}} function! s:get_omni_list(list)"{{{ let l:omni_list = [] " Convert string list. for str in filter(copy(a:list), 'type(v:val) == '.type('')) let l:dict = { 'word' : str, 'menu' : '[O]' } call add(l:omni_list, l:dict) endfor for l:omni in filter(a:list, 'type(v:val) != '.type('')) let l:dict = { \'word' : l:omni.word, 'menu' : '[O]', \'abbr' : has_key(l:omni, 'abbr')? l:omni.abbr : l:omni.word, \} if has_key(l:omni, 'kind') let l:dict.kind = l:omni.kind endif if has_key(l:omni, 'menu') let l:dict.menu .= ' ' . l:omni.menu endif call add(l:omni_list, l:dict) endfor return l:omni_list endfunction"}}} " vim: foldmethod=marker autoload/neocomplcache/sources/snippets_complete/_.snip [[[1 56 # Global snippets snippet date `strftime("%d %b %Y")` snippet date_full alias df `strftime("%Y-%m-%dT%H:%M:%S")` snippet date_day alias dd `strftime("%Y-%m-%d")` snippet date_time alias dt `strftime("%H:%M:%S")` snippet register* `@*` snippet register+ `@+` snippet register" `@"` snippet register0 `@0` snippet register1 `@1` snippet register2 `@2` snippet register3 `@3` snippet register4 `@4` snippet register5 `@5` snippet register6 `@6` snippet register7 `@7` snippet register8 `@8` snippet register9 `@9` autoload/neocomplcache/sources/snippets_complete/actionscript.snip [[[1 273 snippet ec #endinitclip snippet inc #include "${1}" snippet br break; snippet ca call(${1:frame}); snippet case abbr ce case ${1:expression} : ${1:statement} snippet catch abbr ch catch ($1) { $2 } snippet class class ${1:ClassName} { var _${2}; function ${1}(${2}){ _${2} = ${2};${0} } } snippet co continue; snippet dt default : ${1:statement} snippet de delete ${1}; snippet do do { ${1} } while (${2:condition}); snippet dm duplicateMovieClip(${1:target}, ${2:newName}, ${3:depth}); snippet ei else if (${1}) { ${2} } snippet fori abbr fi for ( var ${1} in ${2} ){ ${3} }; snippet for abbr fr for ( var ${1}=0; ${1}<${3}.length; ${1}++ ) { ${4} }; snippet fs fscommand(${1:command}, ${2:paramaters}); snippet fn function ${1}(${2}):${3}{ ${4} }; snippet gu getURL(${1}); snippet gp gotoAndPlay(${1}); snippet gs gotoAndStop(${1}); snippet if if (${1}) { ${2} } snippet il ifFrameLoaded (${1}) { ${2} } snippet ip import ${1}; snippet it interface ${1}{ ${2} } snippet lm loadMovie( ${1:url}, ${2:target}, ${3:method}); snippet ln loadMovieNum( ${1:url}, ${2:level}, ${3:method}); snippet lv loadVariables( ${1:url}, ${2:target}, ${3:method}); snippet vn loadVariables( ${1:url}, ${2:level}, ${3:method}); snippet mc MovieClip snippet nf nextFrame(); snippet ns nextScene(); snippet on on (${1}) { ${2} }; snippet oc onClipEvent (${1}) { ${2} }; snippet pl play(); snippet pf pravFrame(); snippet ps prevScene(); snippet pr print( ${1:target}, ${2:type} ); snippet bn printAsBitmapNum( ${1:level}, ${2:type} ); snippet pn printNum( ${1:level}, ${2:type} ); snippet rm removeMovieClip( ${1:target} ); snippet rt return ${1}; snippet sp setProperty( ${1:target}, ${2:property}, ${3:value} ); snippet sv set( ${1:name}, ${2:value} ); snippet dr startDrag(${1:target}, ${2:lockcenter}, ${3:l}, ${4:t}, ${5:r}, ${6:b} ); snippet st stop(); snippet ss stopAllSounds(); snippet sd stopDrag(); snippet sw switch ( ${1:condition} ) { ${2} } snippet tt tellTarget( ${1:target} ) { ${2} } snippet th throw ${1}; snippet tq toggleHighQuality(); snippet tr trace(${1:"$0"}); snippet ty try { ${1} }; snippet um unloadMovie(${1:target}); snippet un unloadMovieNum(${1:level}); snippet vr var ${1}:${2}; snippet wh while (${1:condition}) { ${2} }; snippet wt with (${1:target}); ${2} }; autoload/neocomplcache/sources/snippets_complete/apache.snip [[[1 23 snippet allow AllowOverride ${1:AuthConfig} ${2:FileInfo} ${3:Indexes} ${4:Limit} ${5:Options} snippet opt Options ${1:All} ${2:ExecCGI} ${3:FollowSymLinks} ${4:Includes} ${5:IncludesNOEXEC} ${6:Indexes} ${7:MultiViews} ${8:SymLinksIfOwnerMatch} snippet vhost ServerAdmin webmaster@${1} DocumentRoot /www/vhosts/${1} ServerName ${1} ErrorLog logs/${1}-error_log CustomLog logs/${1}-access_log common snippet dir ${0} autoload/neocomplcache/sources/snippets_complete/applescript.snip [[[1 201 snippet script script ${1:new_object} on run ${2:-- do something interesting} end run end script snippet on on ${1:functionName}(${2:arguments}) ${3:-- function actions} end ${1} snippet tell tell ${1:app} ${0:-- insert actions here} end tell snippet terms using terms from ${1:app} ${0:-- insert actions here} end using terms from snippet if if ${1:true} then ${0:-- insert actions here} end if snippet rept abbr rep repeat ${1} times} ${0:-- insert actions here} end repeat snippet repwh abbr rep repeat while ${1:condition} ${0} end repeat snippet repwi abbr rep repeat with ${1} in ${2} ${0} end repeat snippet try try ${0:-- actions to try} on error -- error handling end try snippet timeout with timeout ${1:number} seconds ${0:-- insert actions here} end timeout snippet con considering ${1:case} ${0:-- insert actions here} end considering snippet ign ignoring ${1:application responses} ${0:-- insert actions here} end ignoring snippet shell ${1:set shell_stdout to }do shell script ${3:"${2:#script}"} without altering line endings ${0} snippet delim set oldDelims to AppleScript's text item delimiters set AppleScript's text item delimiters to {"${1:,}"} ${0:-- insert actions here} set AppleScript's text item delimiters to oldDelims snippet parent prop parent : app "${1}" snippet alert display alert "${1:alert text}" ${2:message} "${3:message text}" ${4:as warning} snippet dialog_OK abbr dialog display dialog "${1:text}" ${2:with icon} ${3:1} buttons {"${4:OK}"} default button 1 snippet dialog_OK/Cancel abbr dialog display dialog "${1:text}" ${2:with icon} buttons {"${3:Cancel}", "${4:OK}"} default button "${4}" set button_pressed to button returned of result if button_pressed is "${4}" then ${5:-- action for default button button goes here} else -- action for cancel button goes here end if snippet dialog_OK/Cancel/Other abbr dialog display dialog "${1:text}" ${2:with icon} buttons {"${3:Cancel}", "${4:Other Choice}", "${5:OK}"} default button "${5}" set button_pressed to button returned of result if button_pressed is "${5}" then ${6:-- action for default button button goes here} else if button_pressed is "${3}" then -- action for cancel button goes here else -- action for other button goes here end if snippet dialog_TextFierld abbr dialog set the_result to display dialog "${1:text}" default answer "${2:type here}" ${3:with icon} buttons {"${4:Cancel}", "${5:OK}"} default button "${5}" set button_pressed to button returned of the_result set text_typed to text returned of the_result if button_pressed is "${5}" then ${6:-- action for default button button goes here} else -- action for cancel button goes here end if snippet choose_Applications abbr choose ${1:set the_application to }choose application with prompt "${2:Choose an application:}"${3:with multiple selections allowed} snippet choose_Files abbr choose ${1:set the_file to }choose file with prompt "${2:Pick a file:}" ${3:default location path to home folder} ${4:with invisibles} ${5:with multiple selections allowed} ${6:with showing package contents} snippet choose_Folders abbr choose ${1:set the_folder to }choose folder with prompt "${2:Pick a folder:}" ${3:default location path to home folder} ${4:with invisibles} ${5:with multiple selections allowed} ${6:with showing package contents} ${0} snippet choose_NewFile abbr choose ${1:set the_filename to }choose file name with prompt "${2:Name this file:}" default name "${3:untitled}" default location ${4:path to home folder} snippet choose_URL abbr choose ${1:set the_url to }choose URL showing ${2:Web} servers with editable URL snippet choose_Color abbr choose ${1:set the_color to }choose color default color ${2:{65536, 65536, 65536\}} snippet choose_ItemFromList abbr choose set the_choice to choose from list ${1}"\}} autoload/neocomplcache/sources/snippets_complete/c.snip [[[1 124 snippet if abbr if () {} if (${1:/* condition */}) { ${0:/* code */} } snippet else else { ${0} } snippet elseif else if (${1:/* condition */}) { ${0} } snippet ifelse abbr if () {} else {} if (${1:condition}) { ${2} } else { ${3} } snippet for abbr for () {} for (${1} = 0; $1 < ${2}; $1++) { ${0} } snippet while abbr while () {} while (${1:/* condition */}) { ${0:/* code */} } snippet do_while do { ${0:/* code */} } while (${1:/* condition */}); snippet switch abbr switch () {} switch (${1:var}) { case ${2:val}: ${0} break; } snippet function abbr func() {} ${1:void} ${2:func_name}(${3}) { ${0} } snippet struct abbr struct {} struct ${1:name} { ${0:/* data */} }; # Typedef struct snippet struct_typedef typedef struct ${1:name}{ ${0:/* data */} }; snippet enum abbr enum {} enum ${1:name} { ${0} }; # main function. snippet main int main(int argc, char const* argv[]) { ${0} return 0; } # #include <...> snippet inc #include <${1:stdio}.h>${0} # #include "..." snippet Inc #include "${1:}.h"${0} snippet Def abbr #ifndef ... #define ... #endif #ifndef $1 #define ${1:SYMBOL} ${2:value} #endif${0} snippet def #define # Include-Guard snippet once abbr include-guard #ifndef ${1:SYMBOL} #define $1 ${0} #endif /* end of include guard */ # Tertiary conditional snippet conditional (${1:/* condition */})? ${2:a} : ${3:b} # Typedef snippet typedef typedef ${1:base_type} ${2:custom_type}; snippet printf printf("${1}\n"${2});${0} snippet fprintf fprintf(${1:stderr}, "${2}\n"${3});${0} snippet comment alias /* /* ${1:comment} */ ${0} autoload/neocomplcache/sources/snippets_complete/cpp.snip [[[1 20 include c snippet template abbr template template snippet class abbr class {} class ${1:name} { ${2} }; snippet try abbr try catch try { ${1} } catch (${2:exception}) { ${3} } autoload/neocomplcache/sources/snippets_complete/css.snip [[[1 252 snippet background alias bg background:${1};${2} snippet backattachment alias ba background-attachment:${1};${2} snippet backcolor alias bc background-color:${1};${2} snippet backimage alias bi background-image:${1};${2} snippet backposition alias bp background-position:${1};${2} snippet backrepeat alias br background-repeat:${1};${2} snippet border alias b border:${1};${2} snippet border-style alias bs border-style:${1};${2} snippet border-color alias bc border-color:${1};${2} snippet border-width alias bw border-width:${1};${2} snippet border-bottom-width alias bbw border-bottom-width:${1};${2} snippet border-top-width alias btw border-top-width:${1};${2} snippet border-left-width alias blw border-left-width:${1};${2} snippet border-right-width alias brw border-right-width:${1};${2} snippet border-bottom-style alias bbs border-bottom-style:${1};${2} snippet border-top-style alias bts border-top-style:${1};${2} snippet border-left-style alias bls border-left-style:${1};${2} snippet border-right-style alias brs border-right-style:${1};${2} snippet border-bottom-color alias bbc border-bottom-color:${1};${2} snippet border-top-color alias btc border-top-color:${1};${2} snippet border-left-color alias blc border-left-color:${1};${2} snippet border-right-color alias brc border-right-color:${1};${2} snippet outline alias ol outline:${1};${2} snippet outline-color alias oc outline-color:${1};${2} snippet outline-style alias os outline-style:${1};${2} snippet outline-width alias ow outline-width:${1};${2} snippet color alias c color:${1};${2} snippet direction alias d direction:${1};${2} snippet letter-spacing alias ls letter-spacing:${1};${2} snippet line-height alias lh line-height:${1};${2} snippet text-align alias ta text-align:${1};${2} snippet text-decoration alias td text-decoration:${1};${2} snippet text-indent alias ti text-indent:${1};${2} snippet text-transform alias tt text-transform:${1};${2} snippet unicode-bidi alias ub unicode-bidi:${1};${2} snippet white-space alias ws white-space:${1};${2} snippet word-spacing alias ws word-spacing:${1};${2} snippet font alias f font:${1};${2} snippet font-family alias ff font-family:${1:"Times New Roman",Georgia,Serif};${2} snippet font-size alias fs font-size:${1};${2} snippet font-style alias fs font-style:${1};${2} snippet font-weight alias fw font-weight:${1};${2} snippet margin alias m margin:${1};${2} snippet margin-bottom alias mb margin-bottom:${1};${2} snippet margin-top alias mt margin-top:${1};${2} snippet margin-left alias ml margin-left:${1};${2} snippet margin-right alias mr margin-right:${1};${2} snippet padding alias p padding:${1};${2} snippet padding-bottom alias pb padding-bottom:${1};${2} snippet padding-top alias pt padding-top:${1};${2} snippet padding-left alias pl padding-left:${1};${2} snippet padding-right alias pr padding-right:${1};${2} snippet list-style alias ls list-style:${1};${2} snippet list-style-image alias lsi list-style-image:${1};${2} snippet list-style-position alias lsp list-style-position:${1};${2} snippet list-style-type alias lst list-style-type:${1};${2} snippet content alias c content:${1};${2} snippet height alias h height:${1};${2} snippet max-height alias mah max-height:${1};${2} snippet max-width alias maw max-width:${1};${2} snippet min-height alias mih min-height:${1};${2} snippet min-width alias miw min-width:${1};${2} snippet width alias w width:${1};${2} autoload/neocomplcache/sources/snippets_complete/d.snip [[[1 38 include c # Delete snippet depended on C. delete struct delete struct_typedef delete enum delete main delete inc delete Inc delete Def delete def delete once delete printf delete fprintf snippet foreach abbr foreach() {} foreach (${1:var}; ${2:list}) { ${3} } snippet class abbr class {} class ${1:name} { ${2} } snippet struct abbr struct {} struct ${1:name} { ${2} } snippet enum abbr enum {} enum ${1:name} { ${2} } autoload/neocomplcache/sources/snippets_complete/eruby.snip [[[1 19 snippet ruby_print abbr <%= %> <%= ${1:Ruby print code} %>${2} snippet ruby_code abbr <% %> <% ${1:Ruby code} %>${2} snippet ruby_print_nonl abbr <%= -%> <%= ${1:Ruby print code} -%>${2} snippet ruby_code_nonl abbr <% -%> <% ${1:Ruby code} -%>${2} snippet comment abbr <%# %> <%# ${1:Comment} %>${2} autoload/neocomplcache/sources/snippets_complete/java.snip [[[1 274 snippet pu public snippet po protected snippet pr private snippet st static snippet fi final snippet ab abstract snippet cl class ${1} ${2:extends} ${3:Parent} ${4:implements} ${5:Interface} { ${0} } snippet in interface ${1} ${2:extends} ${3:Parent} { ${0} } snippet m ${1:void} ${2:method}(${3}) ${4:throws} { ${0} } snippet v ${1:String} ${2:var}${3}; snippet co static public final ${1:String} ${2:var} = ${3};${4} snippet cos static public final String ${1:var} = "${2}";${4} snippet re return snippet as assert ${1:test} ${2:Failure message};${3} snippet if if (${1}) { ${2} } snippet elif else if (${1}) { ${2} } snippet wh while (${1}) { ${2} } snippet for for (${1}; ${2}; ${3}) { ${4} } snippet fore for (${1} : ${2}) { ${3} } snippet sw switch (${1}) { ${2} } snippet case abbr ce case ${1}: ${2} ${0} snippet br break; snippet de default: ${0} snippet ca catch (${1:Exception} ${2:e}) { ${0} } snippet th throw ${0} snippet sy synchronized snippet im import snippet pa package snippet tc public class ${1} extends ${2:TestCase} { ${0} } snippet test public void test${1:Name}() throws Exception { ${0} } snippet imt import junit.framework.TestCase; ${0} snippet j.u java.util. snippet j.i java.io. snippet j.b java.beans. snippet j.n java.net snippet j.m java.math. snippet main public static void main(String[] args) { ${0} } snippet pl System.out.println(${1});${0} snippet p System.out.print(${1});${0} #javadoc snippet c /** * ${0} */ snippet a @author ${0:$TM_FULLNAME} snippet {code abbr { {@code ${0} snippet d @deprecated ${0:description} snippet {docRoot abbr { {@docRoot snippet {inheritDoc abbr { {@inheritDoc snippet {link abbr { {@link ${1:target} ${0:label} snippet {linkplain abbr { {@linkplain ${1:target} ${0:label} snippet {literal abbr { {@literal ${0} snippet param @param ${1:var} ${0:description} snippet r @return ${0:description} snippet s @see ${0:reference} snippet se @serial ${0:description} snippet sd @serialField ${0:description} snippet sf @serialField ${1:name} ${2:type} ${0:description} snippet si @since ${0:version} snippet t @throws ${1:class} ${0:description} snippet {value abbr { {@value ${0} snippet ver @version ${0:version} snippet null {@code null} autoload/neocomplcache/sources/snippets_complete/javascript.snip [[[1 47 snippet :f ${1:method_name}: function(${2:attribute}){ ${0} } snippet func function ${1:function_name} (${2:argument}) { ${0:// body...} } snippet proto ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { ${0:// body...} }; snippet f function(${1}) {${0:$TM_SELECTED_TEXT}}; snippet if if (${1:true}) {${0:$TM_SELECTED_TEXT}}; snippet ife if (${1:true}) {${0:$TM_SELECTED_TEXT}} else{}; snippet for for (var ${2:i}=0; ${2:i} < ${1:Things}.length; ${2:i}++) { ${0} }; snippet ;, ${1:value_name}:${0:value}, snippet key ${1:key}: "${2:value}"}${3:, } snippet timeout setTimeout(function() {${0}}${2:}, ${1:10}); autoload/neocomplcache/sources/snippets_complete/markdown.snip [[[1 51 snippet link abbr [link][] [${1:link_id}][]${2} snippet linkid abbr [link][id] [${1:link}][${2:id}]${3} snippet linkurl abbr [link](url) [${1:link}](http://${2:url})${3} snippet linkemail abbr [link](email) [${1:link}](mailto:${2:email})${3} snippet linkurltitle abbr [link](url "title") [${1:link}](${2:url} "${3:title}")${4} snippet idurl abbr [id]: url "title" [${1:id}]: http://${2:url} "${3:title}" snippet idemail abbr [id]: email "title" [${1:id}]: mailto:${2:url} "${3:title}" snippet altid abbr ![alt][id] ![${1:alt}][${2:id}]${3} snippet alturl abbr ![alt](url) ![${1:alt}](${2:url})${3} snippet alturltitle abbr ![alt](url "title") ![${1:alt}](${2:url} "${3:title}")${4} snippet emphasis1 abbr *emphasis* *${1}*${2} snippet emphasis2 abbr _emphasis_ _${1}_${2} snippet strong1 abbr **strong** **${1}**${2} snippet strong2 abbr __strong__ __${1}__${2} snippet code abbr `code` `${1}`${2} autoload/neocomplcache/sources/snippets_complete/objc.snip [[[1 352 snippet sel @selector(${1:method}:) snippet imp #import <${1:Cocoa/Cocoa.h}> snippet Imp #import "${1}}" snippet log abbr NSLog(...) NSLog(@"${1}") snippet cl abbr Class @interface ${1} : ${2:NSObject} { } @end @implementation ${1} - (id)init { if((self = [super init])) {${0} } return self; } @end snippet cli abbr ClassInterface @interface ${1} : ${2:NSObject} {${3} } ${0} @end snippet clm abbr ClassImplementation @implementation ${1:object} - (id)init { if((self = [super init])) {${0} } return self; } @end snippet cat abbr Category @interface ${1:NSObject} (${2:Category}) @end @implementation ${1} (${2}) ${0} @end snippet cati abbr CategoryInterface @interface ${1:NSObject)} (${2:Category)}) ${0} @end snippet array NSMutableArray *${1:array} = [NSMutableArray array]; snippet dict NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary]; snippet bez NSBezierPath *${1:path} = [NSBezierPath bezierPath]; ${0} snippet m abbr Method - (${1:id})${2:method}${3:(id)}${4:anArgument} { ${0} return nil; } snippet M abbr Method - (${1:id})${2:method}${3:(id)}${4:anArgument}; snippet cm abbr ClassMethod + (${1:id})${2:method}${3:(id)}${4:anArgument} { ${0} return nil; } snippet icm abbr InterfaceClassMethod + (${1:id})${0:method}; snippet sm abbr SubMethod - (${1:id})${2:method}${3:(id)}${4:anArgument} { ${1} res = [super ${2:method}] return res; } snippet mi abbr MethodInitialize + (void)initialize { [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: ${0}@"value", @"key", nil]]; } snippet obj - (${1:id})${2:thing} { return ${2}; } - (void)set${2}:(${1})aValue { ${0}${1}old${2} = ${2}; ${2} = [aValue retain]; [old${2} release]; } snippet iobj - (${1:id})${2:thing}; - (void)set${2}:(${1})aValue; snippet str - (NSString${$1: *)})${1:thing} { return ${2}; } - (void)set${1}:(NSString${2: *})${3} { ${3} = [${3} copy]; [${2} release]; ${2} = ${3}; } snippet istr - (NSString${1: *)}${1:thing}; - (void)set${1}:(NSString${2: *})${2}; snippet cd abbr CoreData - (${1:id})${2:attribute} { [self willAccessValueForKey:@"${2: attribute}"]; ${1:id} value = [self primitiveValueForKey:@"${2: attribute}"]; [self didAccessValueForKey:@"${2: attribute}"]; return value; } - (void)set${2}:(${1})aValue { [self willChangeValueForKey:@"${2: attribute}"]; [self setPrimitiveValue:aValue forKey:@"${2: attribute}"]; [self didChangeValueForKey:@"${2: attribute}"]; } snippet karray abbr KVCArry - (void)addObjectTo${1:Things}:(${2:id})anObject { [${3}} addObject:anObject]; } - (void)insertObject:(${2})anObject in${1}AtIndex:(unsigned int)i { [${3} insertObject:anObject atIndex:i]; } - (${2})objectIn${1}AtIndex:(unsigned int)i { return [${3} objectAtIndex:i]; } - (unsigned int)indexOfObjectIn${1}:(${2})anObject { return [${3} indexOfObject:anObject]; } - (void)removeObjectFrom${1}AtIndex:(unsigned int)i { [${3} removeObjectAtIndex:i]; } - (unsigned int)countOf${1} { return [${3} count]; } - (NSArray${4: *}${1} { return ${3} } - (void)set${1}:(NSArray${4: *})new${1} { [${3} setArray:new${1}]; } snippet iarray abbr InterfaceAccessorsForKVCArray - (void)addObjectTo${1:Things}:(${2:id})anObject; - (void)insertObject:(${2})anObject in${1}AtIndex:(unsigned int)i; - (${2})objectIn${1}AtIndex:(unsigned int)i; - (unsigned int)indexOfObjectIn${1}:(${2})anObject; - (void)removeObjectFrom${1}AtIndex:(unsigned int)i; - (unsigned int)countOf${1}; - (NSArray${3: *})${1}; - (void)set${1}:(NSArray${3: *})new${1}; snippet acc abbr PrimitiveType - (${1:unsigned int})${2:thing} { return ${3}; } - (void)set${2}:(${1:unsigned int})new${2} { ${3} = new${2}; } snippet iacc abbr Interface:AccessorsForPrimitiveType - (${1:unsigned int})${2:thing}; - (void)set${2}:($1)new${2}; snippet rdef abbr ReadDefaultsValue [[NSUserDefaults standardUserDefaults] objectForKey:${1:key}]; snippet wdef abbr WriteDefaultsValue [[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}]; snippet ibo abbr IBOutlet IBOutlet ${1}${2: *}${3}; snippet syn @synthesize ${1:property}; snippet bind bind:@"${2:binding}" toObject:${3:observableController} withKeyPath:@"${4:keyPath}" options:${5:nil} snippet reg [[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3}) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}]; snippet focus [self lockFocus]; ${0} [self unlockFocus]; snippet forarray unsigned int ${1:object}Count = [${2:array} count]; for(unsigned int index = 0; index < ${1}Count; index += 1) { ${3:id} ${1} = [${2} objectAtIndex:index]; ${0} } snippet alert int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil); if(choice == NSAlertDefaultReturn) // "${3:Continue}" { ${0}; } else if(choice == NSAlertAlternateReturn) // "${4:Cancel}" { } snippet res ${1} Send ${2} to ${1}, if ${1} supports it}${3} if ([${1:self} respondsToSelector:@selector(${2:someSelector:})]) { [${1} ${3}]; } snippet del if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})]) [${1} ${3}]; snippet format [NSString stringWithFormat:@"${1}", ${2}]${0} snippet save [NSGraphicsContext saveGraphicsState]; ${0} [NSGraphicsContext restoreGraphicsState]; snippet thread [NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}] snippet pool NSAutoreleasePool${TM_C_POINTER: *}pool = [NSAutoreleasePool new]; ${0} [pool drain]; autoload/neocomplcache/sources/snippets_complete/perl.snip [[[1 76 snippet perl #!/opt/local/bin/perl use strict; use warnings; ${1} snippet sub sub ${1:function_name} { ${2:# body...} } snippet if if (${1}) { ${2:# body...} } snippet ife if (${1}) { ${2:# body...} } else { ${3:# else...} } snippet ifee if (${1}) { ${2:# body...} } elsif (${3}) { ${4:# elsif...} } else { ${5:# else...} } snippet xif ${1:expression} if ${2:condition}; snippet while abbr wh while (${1}) { ${2:# body...} } snippet xwhile abbr xwh ${1:expression} while ${2:condition}; snippet for for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { ${3:# body...} } snippet fore for ${1} (${2:expression}){ ${3:# body...} } snippet xfor ${1:expression} for @${2:array}; snippet unless abbr un unless (${1}) { ${2:# body...} } snippet xunless abbr xun ${1:expression} unless ${2:condition}; snippet eval eval { ${1:# do something risky...} }; if ($@) { ${2:# handle failure...} } autoload/neocomplcache/sources/snippets_complete/php.snip [[[1 266 snippet function abbr func ${1:public }function ${2:FunctionName}(${3}) { ${4:// code...} } snippet php snippet pecho ${0} snippet echoh ${0} snippet pfore }): ?> ${0} snippet pife ${2} ${0} snippet pif ${0} snippet pelse snippet this ${0} ?> snippet ethis ${0} ?> snippet docc /** * ${3:undocumented class variable} * * @var ${4:string} **/ ${1:var} \$${2};${0} snippet docd /** * ${3:undocumented constant} **/ define(${1} ${2});${0} snippet docs /** * ${4:undocumented function} * * @return ${5:void} * @author ${6} **/ ${1}function ${2}(${3});${0} snippet docf /** * ${4:undocumented function} * * @return ${5:void} * @author ${6} **/ ${1}function ${2}(${3}) { ${0} } snippet doch /** * ${1} * * @author ${2} * @version ${3} * @copyright ${4} * @package ${5:default} **/ /** * Define DocBlock **/ snippet doci /** * ${2:undocumented class} * * @package ${3:default} * @author ${4} **/ interface ${1} { ${0} } // END interface ${1} snippet c /** * $0 */ snippet class /** * ${1} */ class ${2:ClassName}${3:extends}} { $5 function ${4:__construct}(${5:argument}) { ${0:# code...} } } snippet def ${1}defined('${2}')${0} snippet do do { ${0:# code...} } while (${1}); snippet if? $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ; snippet ifelse if (${1:condition}) { ${2:# code...} } else { ${3:# code...} } ${0} snippet if if (${1:condition}) { ${0:# code...} } snippet echo echo "${1:string}"${0}; snippet else else { ${0:# code...} } snippet elseif elseif (${1:condition}) { ${0:# code...} } snippet for for ($${1:i}=${2:0}; $${1:i} < ${3}; $${1:i}++) { ${0:# code...} } snippet fore foreach ($${1:variable} as $${2:key}${3: =>} ${4:value}) { ${0:# code...} } snippet func ${1:public }function ${2:FunctionName}(${3}}) { ${0:# code...} } snippet con function __construct(${1}) { ${0} } snippet here <<<${1:HTML} ${2:content here} $1; snippet inc include '${1:file}';${0} snippet inco include_once '${1:file}';${0} snippet array $${1:arrayName} = array('${2}' => ${3} ${0}); snippet req require '${1:file}';${0} snippet reqo require_once '${1:file}';${0} snippet ret return${1};${0} snippet retf return false; snippet rett return true; snippet case case '${1:variable}': ${0:# code...} break; snippet switch abbr sw switch (${1:variable}) { case '${2:value}': ${3:# code...} break; ${0} default: ${4:# code...} break; } snippet throw throw new ${1}Exception(${2:"${3:Error Processing Request}"}${4:}); ${0} snippet while abbr wh while (${1}) { ${0:# code...} } snippet gloabals \$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${0} snippet cookie \$_COOKIE['${1:variable}'] snippet env \$_ENV['${1:variable}'] snippet files \$_FILES['${1:variable}'] snippet get \$_GET['${1:variable}'] snippet post \$_POST['${1:variable}'] snippet request \$_REQUEST['${1:variable}'] snippet server \$_SERVER['${1:variable}'] snippet session \$_SESSION['${1:variable}'] autoload/neocomplcache/sources/snippets_complete/python.snip [[[1 85 snippet class abbr class Class(...): ... prev_word '^' class ${1:name}(${2:object}): """${3:class documentation}""" def __init__(self, ${4}): """${5:__init__ documentation}""" ${6:pass} snippet def abbr def function(...): ... prev_word '^' def ${1:name}(${2}): """${3:function documentation}""" ${4:pass} snippet defm abbr def method(self, ...): ... prev_word '^' def ${1:name}(self, ${2}): """${3:method documentation}""" ${4:pass} snippet elif abbr elif ...: ... prev_word '^' elif ${1:condition}: ${2:pass} snippet else abbr else: ... prev_word '^' else: ${1:pass} snippet fileidiom abbr f = None try: f = open(...) finally: ... prev_word '^' ${1:f} = None try: $1 = open(${2}) ${3} finally: if $1: $1.close() snippet for abbr for ... in ...: ... prev_word '^' for ${1:value} in ${2:list}: ${3:pass} snippet if abbr if ...: ... prev_word '^' if ${1:condition}: ${2:pass} snippet ifmain abbr if __name__ == '__main__': ... prev_word '^' if __name__ == '__main__': ${1:pass} snippet tryexcept abbr try: ... except ...: ... prev_word '^' try: ${1:pass} except ${2:ExceptionClass}: ${3:pass} snippet tryfinally abbr try: ... finally: ... prev_word '^' try: ${1:pass} finally: ${2:pass} snippet while abbr while ...: ... prev_word '^' while ${1:condition}: ${2:pass} autoload/neocomplcache/sources/snippets_complete/rails.snip [[[1 167 snippet rr abbr render render snippet ra abbr render :action render :action => snippet rc abbr render :controller render :controller => snippet rf abbr render :file render :file => snippet ri abbr render :inline render :inline => snippet rj abbr render :json render :json => snippet rl abbr render :layout render :layout => snippet rp abbr render :partial render :partial => snippet rt abbr render :text render :text => snippet rx abbr render :xml render :xml => snippet dotiw abbr distance_of_time_in_words distance_of_time_in_words snippet taiw abbr time_ago_in_words time_ago_in_words snippet re abbr redirect_to redirect_to snippet rea abbr redirect_to :action redirect_to :action => snippet rec abbr redirect_to :controller redirect_to :controller => snippet rst abbr respond_to respond_to snippet bt abbr belongs_to belongs_to snippet ho abbr has_one has_one snippet hm abbr has_many has_many snippet habtm abbr has_and_belongs_to_many has_and_belongs_to_many snippet co abbr composed_of composed_of snippet va abbr validates_associated validates_associated snippet vb abbr validates_acceptance_of validates_acceptance_of snippet vc abbr validates_confirmation_of validates_confirmation_of snippet ve abbr validates_exclusion_of validates_exclusion_of snippet vf abbr validates_format_of validates_format_of snippet vi abbr validates_inclusion_of validates_inclusion_of snippet vl abbr validates_length_of validates_length_of snippet vn abbr validates_numericality_of validates_numericality_of snippet vp abbr validates_presence_of validates_presence_of snippet vu abbr validates_uniqueness_of validates_uniqueness_of snippet vu abbr validates_uniqueness_of validates_uniqueness_of snippet logd abbr logger.debug logger.debug snippet logi abbr logger.info logger.info snippet logw abbr logger.warn logger.warn snippet loge abbr logger.error logger.error snippet logf abbr logger.fatal logger.fatal snippet action abbr :action => :action => snippet co abbr :co________ => :co________ => snippet id abbr :id => :id => snippet object abbr :object => :object => snippet partial abbr :partial => :partial => autoload/neocomplcache/sources/snippets_complete/ruby.snip [[[1 40 snippet if abbr if end if ${1:condition} ${2} end snippet def abbr def end def ${1:func_name} ${2} end snippet do abbr do end do ${1} end snippet dovar abbr do |var| end do |${1:var}| ${2} end snippet block abbr { |var| } { ${1} } snippet blockvar abbr { |var| } { |${1:var}| ${2} } snippet edn abbr => end? end autoload/neocomplcache/sources/snippets_complete/sh.snip [[[1 59 snippet if if [ ${1:condition} ]; then ${0:#statements} fi snippet el else ${0:#statements} snippet elif elif [ ${1:condition} ]; then ${0:#statements} snippet for for ${1:i} in ${2:words}; do ${0:#statements} done snippet wh abbr while while ${1:condition} ; do ${0:#statements} done snippet until until ${1:condition} ; do ${0:#statements} done snippet case case ${1:word} in ${2:pattern} ) ${0} ;; esac snippet h <<${1} ${0} snippet env #!/usr/bin/env ${1} snippet tmp ${1:TMPFILE}="mktemp -t ${2:untitled}" trap "rm -f '$${1}'" 0 # EXIT trap "rm -f '$${1}'; exit 1" 2 # INT trap "rm -f '$${1}'; exit 1" 1 15 # HUP TERM ${0} autoload/neocomplcache/sources/snippets_complete/snippet.snip [[[1 8 snippet snippet abbr snippet abbr prev_word alias snip prev_word '^' snippet ${1:trigger} abbr ${2:abbr} prev_word '^' ${3:snippet code} autoload/neocomplcache/sources/snippets_complete/tex.snip [[[1 15 snippet math abbr $ expression $ $${1:expression}$${2} snippet begin \begin{${1:type}} ${2} \end{$1} ${0} snippet \begin \begin{${1:type}} ${2} \end{$1} ${0} autoload/neocomplcache/sources/snippets_complete/vim.snip [[[1 56 snippet if abbr if endif prev_word '^' if ${1:condition} ${0} endif snippet elseif prev_word '^' else if ${1:/* condition */} ${0} snippet ifelse abbr if else endif prev_word '^' if ${1:condition} ${2} else ${3} endif snippet for abbr for in endfor prev_word '^' for ${1:var} in ${2:list} ${0} endfor snippet while abbr while endwhile prev_word '^' while ${1:condition} ${0} endwhile snippet function abbr func endfunc alias func prev_word '^' function! ${1:func_name}(${2}) ${0} endfunction snippet try abbr try endtry prev_word '^' try ${1} catch /${2:pattern}/ ${3} endtry snippet log prev_word '^' echomsg string(${1}) autoload/neocomplcache/sources/snippets_complete/vimshell.snip [[[1 4 snippet sl abbr => ls? ls autoload/neocomplcache/sources/snippets_complete/xhtml.snip [[[1 235 snippet doctypetransitional snippet doctypeframeset snippet doctypestrict snippet xhtml ${1} snippet head ${2} ${4} ${5} snippet metaauthor ${2} snippet keywords ${2} snippet metaothers ${2} snippet metagenerator ${2} snippet metadescription ${2} snippet scriptcharset ${3} snippet script ${2} snippet body ${1} snippet h ${2}${3} snippet p

${1}

${2} snippet br
snippet hr
snippet comment ${2} snippet b ${1}${2} snippet small ${1}${2} snippet strong ${1}${2} snippet sub ${1}${2} snippet sup ${1}${2} snippet ins ${1}${2} snippet del ${1}${2} snippet em ${1}${2} snippet bdo ${2}${3} snippet pre
    ${1}
    
${2} snippet blockquote
${1}
${2} snippet link abbr link stylesheet css ${4} snippet alignl text-align="left" snippet alignr text-align="right" snippet alignc text-align="center" snippet bgcolor bgcolor="${1}"${2} snippet ahref ${2}${3} snippet ahref_blank ${2}${3} snippet ahref_parent ${2}${3} snippet ahref_top ${2}${3} snippet aname ${2}${3} snippet framesetcols ${2} ${3} snippet framesetrows ${3} snippet iframe ${2} snippet table ${2}
${3} snippet th ${1}${2} snippet ulsquare
    ${1}
${2} snippet uldisc
    ${1}
${2} snippet ulcicle
    ${1}
${2} snippet ol
    ${1}
${2} snippet olA
    ${1}
${2} snippet ola
    ${1}
${2} snippet olI
    ${1}
${2} snippet oli
    ${1}
${2} snippet li
  • ${1}
  • ${2} snippet dl
    ${1}
    ${2} snippet dt
    ${1}
    ${2} snippet dd
    ${1}
    ${2} snippet form
    ${1}
    ${2} snippet inputtext ${2} snippet inputpassword ${2} snippet inputradio ${2} snippet inputcheckbox ${2} snippet textarea ${4} snippet button ${2} snippet select ${2} snippet optgroup ${2} ${3} snippet option ${3} snippet label