diff --git a/README.md b/README.md new file mode 100644 index 0000000..90cdf96 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +LLVIMRC +======= + +llvimrc is a distribution of vim plugins and resources for Vim. diff --git a/vim/bundle/neocomplcache/.gitignore b/vim/bundle/neocomplcache/.gitignore new file mode 100644 index 0000000..734e95b --- /dev/null +++ b/vim/bundle/neocomplcache/.gitignore @@ -0,0 +1,2 @@ +doc/tags* +*.swp diff --git a/vim/bundle/neocomplcache/README.md b/vim/bundle/neocomplcache/README.md new file mode 100644 index 0000000..55e5862 --- /dev/null +++ b/vim/bundle/neocomplcache/README.md @@ -0,0 +1,156 @@ +**neocomplcache** +================= + +Note: It is not maintained well. You should use neocomplete instead. + +https://github.com/Shougo/neocomplete.vim + + +Description +----------- + +neocomplcache is the abbreviation of "neo-completion with cache". It +provides keyword completion system by maintaining a cache of keywords in the +current buffer. neocomplcache could be customized easily and has a lot more +features than the Vim's standard completion feature. + +If you use Vim 7.3.885 or above with if\_lua feature, you should use +neocomplete. It is faster than neocomplcache. + +https://github.com/Shougo/neocomplete.vim + +Installation +============ + +* Extract the file and put files in your Vim directory + (usually ~/.vim/ or Program Files/Vim/vimfiles on Windows). +* Execute `|:NeoComplCacheEnable|` command or +`let g:neocomplcache_enable_at_startup = 1` +in your `.vimrc`. Not in `.gvimrc`(`_gvimrc`)! + +Caution +------- + +Because all variable names were changed in neocomplcache Ver.5, it is not +backwards compatible. If you want to upgrade, you should use the following +script from Mr.thinca. + +http://gist.github.com/422503 + +Snippets feature(snippets\_complete source) was split from Ver.7. +If you used it, please install neosnippet source manually. + +https://github.com/Shougo/neosnippet + +Screen shots +============ + +Original filename completion. +----------- +![Original filename completion.](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1O5_bOQ2I/AAAAAAAAADE/vHf9Xg_mrTI/s1600/filename_complete.png) + +Omni completion. +---------------- +![Omni completion.](http://2.bp.blogspot.com/_ci2yBnqzJgM/TD1PTolkTBI/AAAAAAAAADU/knJ3eniuHWI/s1600/omni_complete.png) + +Completion with vimshell(http://github.com/Shougo/vimshell). +------------------------------------------------------------ +![Completion with vimshell(http://github.com/Shougo/vimshell).](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1PLfdQrwI/AAAAAAAAADM/2pSFRTHwYOY/s1600/neocomplcache_with_vimshell.png) + +Vim completion +------------------------------------------------------------ +![Vim completion.](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1PfKTlwnI/AAAAAAAAADs/nOGWTRLuae8/s1600/vim_complete.png) + +Setting examples + +```vim +"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! +" Disable AutoComplPop. +let g:acp_enableAtStartup = 0 +" Use neocomplcache. +let g:neocomplcache_enable_at_startup = 1 +" Use smartcase. +let g:neocomplcache_enable_smart_case = 1 +" Set minimum syntax keyword length. +let g:neocomplcache_min_syntax_length = 3 +let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' + +" Enable heavy features. +" Use camel case completion. +"let g:neocomplcache_enable_camel_case_completion = 1 +" Use underbar completion. +"let g:neocomplcache_enable_underbar_completion = 1 + +" Define dictionary. +let g:neocomplcache_dictionary_filetype_lists = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + +" Define keyword. +if !exists('g:neocomplcache_keyword_patterns') + let g:neocomplcache_keyword_patterns = {} +endif +let g:neocomplcache_keyword_patterns['default'] = '\h\w*' + +" Plugin key-mappings. +inoremap neocomplcache#undo_completion() +inoremap neocomplcache#complete_common_string() + +" Recommended key-mappings. +" : close popup and save indent. +inoremap =my_cr_function() +function! s:my_cr_function() + return neocomplcache#smart_close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplcache#close_popup() : "\" +endfunction +" : completion. +inoremap pumvisible() ? "\" : "\" +" , : close popup and delete backword char. +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#close_popup() +inoremap neocomplcache#cancel_popup() +" Close popup by . +"inoremap pumvisible() ? neocomplcache#close_popup() : "\" + +" For cursor moving in insert mode(Not recommended) +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +" Or set this. +"let g:neocomplcache_enable_cursor_hold_i = 1 +" Or set this. +"let g:neocomplcache_enable_insert_char_pre = 1 + +" AutoComplPop like behavior. +"let g:neocomplcache_enable_auto_select = 1 + +" Shell like behavior(not recommended). +"set completeopt+=longest +"let g:neocomplcache_enable_auto_select = 1 +"let g:neocomplcache_disable_auto_complete = 1 +"inoremap pumvisible() ? "\" : "\\" + +" Enable omni completion. +autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS +autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags +autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS +autocmd FileType python setlocal omnifunc=pythoncomplete#Complete +autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags + +" Enable heavy omni completion. +if !exists('g:neocomplcache_force_omni_patterns') + let g:neocomplcache_force_omni_patterns = {} +endif +let g:neocomplcache_force_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +let g:neocomplcache_force_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' +let g:neocomplcache_force_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + +" For perlomni.vim setting. +" https://github.com/c9s/perlomni.vim +let g:neocomplcache_force_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::' +``` diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache.vim b/vim/bundle/neocomplcache/autoload/neocomplcache.vim new file mode 100644 index 0000000..f8204b2 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache.vim @@ -0,0 +1,404 @@ +"============================================================================= +" FILE: neocomplcache.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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. +" }}} +"============================================================================= + +if !exists('g:loaded_neocomplcache') + runtime! plugin/neocomplcache.vim +endif + +let s:save_cpo = &cpo +set cpo&vim + +scriptencoding utf-8 + +function! neocomplcache#initialize() "{{{ + return neocomplcache#init#enable() +endfunction"}}} + +function! neocomplcache#get_current_neocomplcache() "{{{ + if !exists('b:neocomplcache') + call neocomplcache#init#_current_neocomplcache() + endif + + return b:neocomplcache +endfunction"}}} +function! neocomplcache#get_context() "{{{ + return neocomplcache#get_current_neocomplcache().context +endfunction"}}} + +" Source helper. "{{{ +function! neocomplcache#define_source(source) "{{{ + let sources = neocomplcache#variables#get_sources() + for source in neocomplcache#util#convert2list(a:source) + let sources[source.name] = neocomplcache#init#_source(source) + endfor +endfunction"}}} +function! neocomplcache#define_filter(filter) "{{{ + let filters = neocomplcache#variables#get_filters() + for filter in neocomplcache#util#convert2list(a:filter) + let filters[filter.name] = neocomplcache#init#_filter(filter) + endfor +endfunction"}}} +function! neocomplcache#available_sources() "{{{ + return copy(neocomplcache#variables#get_sources()) +endfunction"}}} +function! neocomplcache#custom_source(source_name, option_name, value) "{{{ + let custom_sources = neocomplcache#variables#get_custom().sources + + for key in split(a:source_name, '\s*,\s*') + if !has_key(custom_sources, key) + let custom_sources[key] = {} + endif + + let custom_sources[key][a:option_name] = a:value + endfor +endfunction"}}} + +function! neocomplcache#is_enabled_source(source_name) "{{{ + return neocomplcache#helper#is_enabled_source(a:source_name) +endfunction"}}} +function! neocomplcache#is_disabled_source(source_name) "{{{ + let filetype = neocomplcache#get_context_filetype() + + let disabled_sources = get( + \ g:neocomplcache_disabled_sources_list, filetype, + \ get(g:neocomplcache_disabled_sources_list, '_', [])) + return index(disabled_sources, a:source_name) >= 0 +endfunction"}}} +function! neocomplcache#keyword_escape(complete_str) "{{{ + return neocomplcache#helper#keyword_escape(a:complete_str) +endfunction"}}} +function! neocomplcache#keyword_filter(list, complete_str) "{{{ + return neocomplcache#filters#keyword_filter(a:list, a:complete_str) +endfunction"}}} +function! neocomplcache#dup_filter(list) "{{{ + return neocomplcache#util#dup_filter(a:list) +endfunction"}}} +function! neocomplcache#check_match_filter(complete_str) "{{{ + return neocomplcache#keyword_escape(a:complete_str) =~ '[^\\]\*\|\\+' +endfunction"}}} +function! neocomplcache#check_completion_length_match(complete_str, completion_length) "{{{ + return neocomplcache#keyword_escape( + \ a:complete_str[: a:completion_length-1]) =~ + \'[^\\]\*\|\\+\|\\%(\|\\|' +endfunction"}}} +function! neocomplcache#dictionary_filter(dictionary, complete_str) "{{{ + return neocomplcache#filters#dictionary_filter(a:dictionary, a:complete_str) +endfunction"}}} +function! neocomplcache#unpack_dictionary(dict) "{{{ + let ret = [] + let values = values(a:dict) + for l in (type(values) == type([]) ? + \ values : values(values)) + let ret += (type(l) == type([])) ? copy(l) : values(l) + endfor + + return ret +endfunction"}}} +function! neocomplcache#pack_dictionary(list) "{{{ + let completion_length = 2 + let ret = {} + for candidate in a:list + let key = tolower(candidate.word[: completion_length-1]) + if !has_key(ret, key) + let ret[key] = {} + endif + + let ret[key][candidate.word] = candidate + endfor + + return ret +endfunction"}}} +function! neocomplcache#add_dictionaries(dictionaries) "{{{ + if empty(a:dictionaries) + return {} + endif + + let ret = a:dictionaries[0] + for dict in a:dictionaries[1:] + for [key, value] in items(dict) + if has_key(ret, key) + let ret[key] += value + else + let ret[key] = value + endif + endfor + endfor + + return ret +endfunction"}}} + +function! neocomplcache#system(...) "{{{ + let V = vital#of('neocomplcache') + return call(V.system, a:000) +endfunction"}}} +function! neocomplcache#has_vimproc() "{{{ + return neocomplcache#util#has_vimproc() +endfunction"}}} + +function! neocomplcache#get_cur_text(...) "{{{ + " Return cached text. + let neocomplcache = neocomplcache#get_current_neocomplcache() + return (a:0 == 0 && mode() ==# 'i' && + \ neocomplcache.cur_text != '') ? + \ neocomplcache.cur_text : neocomplcache#helper#get_cur_text() +endfunction"}}} +function! neocomplcache#get_next_keyword() "{{{ + " Get next keyword. + let pattern = '^\%(' . neocomplcache#get_next_keyword_pattern() . '\m\)' + + return matchstr('a'.getline('.')[len(neocomplcache#get_cur_text()) :], pattern)[1:] +endfunction"}}} +function! neocomplcache#get_completion_length(source_name) "{{{ + let sources = neocomplcache#variables#get_sources() + if !has_key(sources, a:source_name) + " Unknown. + return -1 + endif + + if neocomplcache#is_auto_complete() + \ && neocomplcache#get_current_neocomplcache().completion_length >= 0 + return neocomplcache#get_current_neocomplcache().completion_length + else + return sources[a:source_name].min_pattern_length + endif +endfunction"}}} +function! neocomplcache#set_completion_length(source_name, length) "{{{ + let custom = neocomplcache#variables#get_custom().sources + if !has_key(custom, a:source_name) + let custom[a:source_name] = {} + endif + + if !has_key(custom[a:source_name], 'min_pattern_length') + let custom[a:source_name].min_pattern_length = a:length + endif +endfunction"}}} +function! neocomplcache#get_keyword_pattern(...) "{{{ + let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() + + return neocomplcache#helper#unite_patterns( + \ g:neocomplcache_keyword_patterns, filetype) +endfunction"}}} +function! neocomplcache#get_next_keyword_pattern(...) "{{{ + let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() + let next_pattern = neocomplcache#helper#unite_patterns( + \ g:neocomplcache_next_keyword_patterns, filetype) + + return (next_pattern == '' ? '' : next_pattern.'\m\|') + \ . neocomplcache#get_keyword_pattern(filetype) +endfunction"}}} +function! neocomplcache#get_keyword_pattern_end(...) "{{{ + let filetype = a:0 != 0? a:000[0] : neocomplcache#get_context_filetype() + + return '\%('.neocomplcache#get_keyword_pattern(filetype).'\m\)$' +endfunction"}}} +function! neocomplcache#match_word(...) "{{{ + return call('neocomplcache#helper#match_word', a:000) +endfunction"}}} +function! neocomplcache#is_enabled() "{{{ + return neocomplcache#init#is_enabled() +endfunction"}}} +function! neocomplcache#is_locked(...) "{{{ + let bufnr = a:0 > 0 ? a:1 : bufnr('%') + return !neocomplcache#is_enabled() || &paste + \ || g:neocomplcache_disable_auto_complete + \ || neocomplcache#get_current_neocomplcache().lock + \ || (g:neocomplcache_lock_buffer_name_pattern != '' && + \ bufname(bufnr) =~ g:neocomplcache_lock_buffer_name_pattern) + \ || &l:omnifunc ==# 'fuf#onComplete' +endfunction"}}} +function! neocomplcache#is_plugin_locked(source_name) "{{{ + if !neocomplcache#is_enabled() + return 1 + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + return get(neocomplcache.lock_sources, a:source_name, 0) +endfunction"}}} +function! neocomplcache#is_auto_select() "{{{ + return g:neocomplcache_enable_auto_select && !neocomplcache#is_eskk_enabled() +endfunction"}}} +function! neocomplcache#is_auto_complete() "{{{ + return &l:completefunc == 'neocomplcache#complete#auto_complete' +endfunction"}}} +function! neocomplcache#is_sources_complete() "{{{ + return &l:completefunc == 'neocomplcache#complete#sources_manual_complete' +endfunction"}}} +function! neocomplcache#is_eskk_enabled() "{{{ + return exists('*eskk#is_enabled') && eskk#is_enabled() +endfunction"}}} +function! neocomplcache#is_eskk_convertion(cur_text) "{{{ + return neocomplcache#is_eskk_enabled() + \ && eskk#get_preedit().get_henkan_phase() !=# + \ g:eskk#preedit#PHASE_NORMAL +endfunction"}}} +function! neocomplcache#is_multibyte_input(cur_text) "{{{ + return (exists('b:skk_on') && b:skk_on) + \ || char2nr(split(a:cur_text, '\zs')[-1]) > 0x80 +endfunction"}}} +function! neocomplcache#is_text_mode() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + return get(g:neocomplcache_text_mode_filetypes, + \ neocomplcache.context_filetype, 0) +endfunction"}}} +function! neocomplcache#is_windows() "{{{ + return neocomplcache#util#is_windows() +endfunction"}}} +function! neocomplcache#is_win() "{{{ + return neocomplcache#util#is_windows() +endfunction"}}} +function! neocomplcache#is_prefetch() "{{{ + return !neocomplcache#is_locked() && + \ (g:neocomplcache_enable_prefetch || &l:formatoptions =~# 'a') +endfunction"}}} +function! neocomplcache#exists_echodoc() "{{{ + return exists('g:loaded_echodoc') && g:loaded_echodoc +endfunction"}}} +function! neocomplcache#within_comment() "{{{ + return neocomplcache#helper#get_syn_name(1) ==# 'Comment' +endfunction"}}} +function! neocomplcache#print_caching(string) "{{{ + if g:neocomplcache_enable_caching_message + redraw + echon a:string + endif +endfunction"}}} +function! neocomplcache#print_error(string) "{{{ + echohl Error | echomsg a:string | echohl None +endfunction"}}} +function! neocomplcache#print_warning(string) "{{{ + echohl WarningMsg | echomsg a:string | echohl None +endfunction"}}} +function! neocomplcache#head_match(checkstr, headstr) "{{{ + let checkstr = &ignorecase ? + \ tolower(a:checkstr) : a:checkstr + let headstr = &ignorecase ? + \ tolower(a:headstr) : a:headstr + return stridx(checkstr, headstr) == 0 +endfunction"}}} +function! neocomplcache#get_source_filetypes(filetype) "{{{ + return neocomplcache#helper#get_source_filetypes(a:filetype) +endfunction"}}} +function! neocomplcache#get_sources_list(dictionary, filetype) "{{{ + return neocomplcache#helper#ftdictionary2list(a:dictionary, a:filetype) +endfunction"}}} +function! neocomplcache#escape_match(str) "{{{ + return escape(a:str, '~"*\.^$[]') +endfunction"}}} +function! neocomplcache#get_context_filetype(...) "{{{ + if !neocomplcache#is_enabled() + return &filetype + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + if a:0 != 0 || mode() !=# 'i' || + \ neocomplcache.context_filetype == '' + call neocomplcache#context_filetype#set() + endif + + return neocomplcache.context_filetype +endfunction"}}} +function! neocomplcache#get_context_filetype_range(...) "{{{ + if !neocomplcache#is_enabled() + return [[1, 1], [line('$'), len(getline('$'))+1]] + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + if a:0 != 0 || mode() !=# 'i' || + \ neocomplcache.context_filetype == '' + call neocomplcache#context_filetype#set() + endif + + if neocomplcache.context_filetype ==# &filetype + return [[1, 1], [line('$'), len(getline('$'))+1]] + endif + + return neocomplcache.context_filetype_range +endfunction"}}} +function! neocomplcache#print_debug(expr) "{{{ + if g:neocomplcache_enable_debug + echomsg string(a:expr) + endif +endfunction"}}} +function! neocomplcache#get_temporary_directory() "{{{ + let directory = neocomplcache#util#substitute_path_separator( + \ neocomplcache#util#expand(g:neocomplcache_temporary_dir)) + if !isdirectory(directory) && !neocomplcache#util#is_sudo() + call mkdir(directory, 'p') + endif + + return directory +endfunction"}}} +function! neocomplcache#complete_check() "{{{ + return neocomplcache#helper#complete_check() +endfunction"}}} +function! neocomplcache#check_invalid_omnifunc(omnifunc) "{{{ + return a:omnifunc == '' || (a:omnifunc !~ '#' && !exists('*' . a:omnifunc)) +endfunction"}}} +function! neocomplcache#skip_next_complete() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.skip_next_complete = 1 +endfunction"}}} + +function! neocomplcache#set_dictionary_helper(variable, keys, value) "{{{ + return neocomplcache#util#set_dictionary_helper( + \ a:variable, a:keys, a:value) +endfunction"}}} +function! neocomplcache#disable_default_dictionary(variable) "{{{ + return neocomplcache#util#disable_default_dictionary(a:variable) +endfunction"}}} +function! neocomplcache#filetype_complete(arglead, cmdline, cursorpos) "{{{ + return neocomplcache#helper#filetype_complete(a:arglead, a:cmdline, a:cursorpos) +endfunction"}}} +"}}} + +" Key mapping functions. "{{{ +function! neocomplcache#smart_close_popup() + return neocomplcache#mappings#smart_close_popup() +endfunction +function! neocomplcache#close_popup() + return neocomplcache#mappings#close_popup() +endfunction +function! neocomplcache#cancel_popup() + return neocomplcache#mappings#cancel_popup() +endfunction +function! neocomplcache#undo_completion() + return neocomplcache#mappings#undo_completion() +endfunction +function! neocomplcache#complete_common_string() + return neocomplcache#mappings#complete_common_string() +endfunction +function! neocomplcache#start_manual_complete(...) + return call('neocomplcache#mappings#start_manual_complete', a:000) +endfunction +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/async_cache.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/async_cache.vim new file mode 100644 index 0000000..90ddea3 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/async_cache.vim @@ -0,0 +1,315 @@ +"============================================================================= +" FILE: async_cache.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 16 Jul 2013. +" 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 condition +" +" 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:save_cpo = &cpo +set cpo&vim + +function! s:main(argv) "{{{ + " args: funcname, outputname filename pattern_file_name mark minlen maxfilename + let [funcname, outputname, filename, pattern_file_name, mark, minlen, maxfilename, fileencoding] + \ = a:argv + + if funcname ==# 'load_from_file' + let keyword_list = s:load_from_file( + \ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, 1) + else + let keyword_list = s:load_from_tags( + \ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding) + endif + + if empty(keyword_list) + return + endif + + " Output cache. + call writefile([string(keyword_list)], outputname) +endfunction"}}} + +function! s:load_from_file(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, is_string) "{{{ + if !filereadable(a:filename) + " File not found. + return [] + endif + + let lines = map(readfile(a:filename), + \ 's:iconv(v:val, a:fileencoding, &encoding)') + + let pattern = get(readfile(a:pattern_file_name), 0, '\h\w*') + + let max_lines = len(lines) + + let keyword_list = [] + let dup_check = {} + let keyword_pattern2 = '^\%('.pattern.'\m\)' + + for line in lines "{{{ + let match = match(line, pattern) + while match >= 0 "{{{ + let match_str = matchstr(line, keyword_pattern2, match) + + if !has_key(dup_check, match_str) && len(match_str) >= a:minlen + " Append list. + call add(keyword_list, (a:is_string ? + \ match_str : { 'word' : match_str })) + + let dup_check[match_str] = 1 + endif + + let match += len(match_str) + + let match = match(line, pattern, match) + endwhile"}}} + endfor"}}} + + return keyword_list +endfunction"}}} + +function! s:load_from_tags(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding) "{{{ + let keyword_lists = [] + let dup_check = {} + + let [pattern, tags_file_name, filter_pattern, filetype] = + \ readfile(a:pattern_file_name)[: 4] + if tags_file_name !=# '$dummy$' + " Check output. + let tags_list = [] + + let i = 0 + while i < 2 + if filereadable(tags_file_name) + " Use filename. + let tags_list = map(readfile(tags_file_name), + \ 's:iconv(v:val, a:fileencoding, &encoding)') + break + endif + + sleep 500m + let i += 1 + endwhile + else + if !filereadable(a:filename) + return [] + endif + + " Use filename. + let tags_list = map(readfile(a:filename), + \ 's:iconv(v:val, a:fileencoding, &encoding)') + endif + + if empty(tags_list) + " File caching. + return s:load_from_file(a:filename, a:pattern_file_name, + \ a:mark, a:minlen, a:maxfilename, a:fileencoding, 0) + endif + + for line in tags_list "{{{ + let tag = split(substitute(line, "\", '', 'g'), '\t', 1) + + " Add keywords. + if line =~ '^!' || len(tag) < 3 || len(tag[0]) < a:minlen + \ || has_key(dup_check, tag[0]) + continue + endif + + let opt = join(tag[2:], "\") + let cmd = matchstr(opt, '.*/;"') + + let option = { + \ 'cmd' : substitute(substitute(substitute(cmd, + \'^\%([/?]\^\?\)\?\s*\|\%(\$\?[/?]\)\?;"$', '', 'g'), + \ '\\\\', '\\', 'g'), '\\/', '/', 'g'), + \ 'kind' : '' + \} + if option.cmd =~ '\d\+' + let option.cmd = tag[0] + endif + + for opt in split(opt[len(cmd):], '\t', 1) + let key = matchstr(opt, '^\h\w*\ze:') + if key == '' + let option['kind'] = opt + else + let option[key] = matchstr(opt, '^\h\w*:\zs.*') + endif + endfor + + if has_key(option, 'file') + \ || (has_key(option, 'access') && option.access != 'public') + continue + endif + + let abbr = has_key(option, 'signature')? tag[0] . option.signature : + \ (option['kind'] == 'd' || option['cmd'] == '') ? + \ tag[0] : option['cmd'] + let abbr = substitute(abbr, '\s\+', ' ', 'g') + " Substitute "namespace foobar" to "foobar ". + let abbr = substitute(abbr, + \'^\(namespace\|class\|struct\|enum\|union\)\s\+\(.*\)$', + \'\2 <\1>', '') + " Substitute typedef. + let abbr = substitute(abbr, + \'^typedef\s\+\(.*\)\s\+\(\h\w*\%(::\w*\)*\);\?$', + \'\2 ', 'g') + + let keyword = { + \ 'word' : tag[0], 'abbr' : abbr, + \ 'kind' : option['kind'], 'dup' : 1, + \ } + if has_key(option, 'struct') + let keyword.menu = option.struct + elseif has_key(option, 'class') + let keyword.menu = option.class + elseif has_key(option, 'enum') + let keyword.menu = option.enum + elseif has_key(option, 'union') + let keyword.menu = option.union + endif + + call add(keyword_lists, keyword) + let dup_check[tag[0]] = 1 + endfor"}}} + + if filter_pattern != '' + call filter(keyword_lists, filter_pattern) + endif + + return keyword_lists +endfunction"}}} + +function! s:truncate(str, width) "{{{ + " Original function is from mattn. + " http://github.com/mattn/googlereader-vim/tree/master + + if a:str =~# '^[\x00-\x7f]*$' + return len(a:str) < a:width ? + \ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width) + endif + + let ret = a:str + let width = s:wcswidth(a:str) + if width > a:width + let ret = s:strwidthpart(ret, a:width) + let width = s:wcswidth(ret) + endif + + if width < a:width + let ret .= repeat(' ', a:width - width) + endif + + return ret +endfunction"}}} + +function! s:strwidthpart(str, width) "{{{ + let ret = a:str + let width = s:wcswidth(a:str) + while width > a:width + let char = matchstr(ret, '.$') + let ret = ret[: -1 - len(char)] + let width -= s:wcwidth(char) + endwhile + + return ret +endfunction"}}} + +function! s:iconv(expr, from, to) + if a:from == '' || a:to == '' || a:from ==? a:to + return a:expr + endif + let result = iconv(a:expr, a:from, a:to) + return result != '' ? result : a:expr +endfunction + +if v:version >= 703 + " Use builtin function. + function! s:wcswidth(str) "{{{ + return strdisplaywidth(a:str) + endfunction"}}} + function! s:wcwidth(str) "{{{ + return strwidth(a:str) + endfunction"}}} +else + function! s:wcswidth(str) "{{{ + if a:str =~# '^[\x00-\x7f]*$' + return strlen(a:str) + end + + let mx_first = '^\(.\)' + let str = a:str + let width = 0 + while 1 + let ucs = char2nr(substitute(str, mx_first, '\1', '')) + if ucs == 0 + break + endif + let width += s:wcwidth(ucs) + let str = substitute(str, mx_first, '', '') + endwhile + return width + endfunction"}}} + + " UTF-8 only. + function! s:wcwidth(ucs) "{{{ + let ucs = a:ucs + if (ucs >= 0x1100 + \ && (ucs <= 0x115f + \ || ucs == 0x2329 + \ || ucs == 0x232a + \ || (ucs >= 0x2e80 && ucs <= 0xa4cf + \ && ucs != 0x303f) + \ || (ucs >= 0xac00 && ucs <= 0xd7a3) + \ || (ucs >= 0xf900 && ucs <= 0xfaff) + \ || (ucs >= 0xfe30 && ucs <= 0xfe6f) + \ || (ucs >= 0xff00 && ucs <= 0xff60) + \ || (ucs >= 0xffe0 && ucs <= 0xffe6) + \ || (ucs >= 0x20000 && ucs <= 0x2fffd) + \ || (ucs >= 0x30000 && ucs <= 0x3fffd) + \ )) + return 2 + endif + return 1 + endfunction"}}} +endif + +if argc() == 8 && + \ (argv(0) ==# 'load_from_file' || argv(0) ==# 'load_from_tags') + try + call s:main(argv()) + catch + call writefile([v:throwpoint, v:exception], + \ fnamemodify(argv(1), ':h:h').'/async_error_log') + endtry + + qall! +else + function! neocomplcache#async_cache#main(argv) "{{{ + call s:main(a:argv) + endfunction"}}} +endif + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/cache.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/cache.vim new file mode 100644 index 0000000..b6353f6 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/cache.vim @@ -0,0 +1,340 @@ +"============================================================================= +" FILE: cache.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:Cache = vital#of('neocomplcache').import('System.Cache') + +" Cache loader. +function! neocomplcache#cache#check_cache_list(cache_dir, key, async_cache_dictionary, index_keyword_list, ...) "{{{ + if !has_key(a:async_cache_dictionary, a:key) + return + endif + + let is_string = get(a:000, 0, 0) + + let keyword_list = [] + let cache_list = a:async_cache_dictionary[a:key] + for cache in cache_list + if filereadable(cache.cachename) + let keyword_list += neocomplcache#cache#load_from_cache( + \ a:cache_dir, cache.filename, is_string) + endif + endfor + + call neocomplcache#cache#list2index(keyword_list, a:index_keyword_list, is_string) + call filter(cache_list, '!filereadable(v:val.cachename)') + + if empty(cache_list) + " Delete from dictionary. + call remove(a:async_cache_dictionary, a:key) + endif +endfunction"}}} +function! neocomplcache#cache#check_cache(cache_dir, key, async_cache_dictionary, keyword_list_dictionary, ...) "{{{ + let is_string = get(a:000, 0, 0) + + " Caching. + if !has_key(a:keyword_list_dictionary, a:key) + let a:keyword_list_dictionary[a:key] = {} + endif + return neocomplcache#cache#check_cache_list( + \ a:cache_dir, a:key, a:async_cache_dictionary, + \ a:keyword_list_dictionary[a:key], is_string) +endfunction"}}} +function! neocomplcache#cache#load_from_cache(cache_dir, filename, ...) "{{{ + let is_string = get(a:000, 0, 0) + + try + let list = eval(get(neocomplcache#cache#readfile( + \ a:cache_dir, a:filename), 0, '[]')) + if !empty(list) && is_string && type(list[0]) != type('') + " Type check. + throw 'Type error' + endif + + return list + catch + " Delete old cache file. + let cache_name = + \ neocomplcache#cache#encode_name(a:cache_dir, a:filename) + if filereadable(cache_name) + call delete(cache_name) + endif + + return [] + endtry +endfunction"}}} +function! neocomplcache#cache#index_load_from_cache(cache_dir, filename, ...) "{{{ + let is_string = get(a:000, 0, 0) + let keyword_lists = {} + + let completion_length = 2 + for keyword in neocomplcache#cache#load_from_cache( + \ a:cache_dir, a:filename, is_string) + let key = tolower( + \ (is_string ? keyword : keyword.word)[: completion_length-1]) + if !has_key(keyword_lists, key) + let keyword_lists[key] = [] + endif + call add(keyword_lists[key], keyword) + endfor + + return keyword_lists +endfunction"}}} +function! neocomplcache#cache#list2index(list, dictionary, is_string) "{{{ + let completion_length = 2 + for keyword in a:list + let word = a:is_string ? keyword : keyword.word + + let key = tolower(word[: completion_length-1]) + if !has_key(a:dictionary, key) + let a:dictionary[key] = {} + endif + let a:dictionary[key][word] = keyword + endfor + + return a:dictionary +endfunction"}}} + +function! neocomplcache#cache#save_cache(cache_dir, filename, keyword_list) "{{{ + if neocomplcache#util#is_sudo() + return + endif + + call neocomplcache#cache#writefile( + \ a:cache_dir, a:filename, [string(a:keyword_list)]) +endfunction"}}} +function! neocomplcache#cache#save_cache_old(cache_dir, filename, keyword_list) "{{{ + if neocomplcache#util#is_sudo() + return + endif + + " Create dictionary key. + for keyword in a:keyword_list + if !has_key(keyword, 'abbr') + let keyword.abbr = keyword.word + endif + if !has_key(keyword, 'kind') + let keyword.kind = '' + endif + if !has_key(keyword, 'menu') + let keyword.menu = '' + endif + endfor + + " Output cache. + let word_list = [] + for keyword in a:keyword_list + call add(word_list, printf('%s|||%s|||%s|||%s', + \keyword.word, keyword.abbr, keyword.menu, keyword.kind)) + endfor + + call neocomplcache#cache#writefile( + \ a:cache_dir, a:filename, word_list) +endfunction"}}} + +" Cache helper. +function! neocomplcache#cache#getfilename(cache_dir, filename) "{{{ + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.getfilename(cache_dir, a:filename) +endfunction"}}} +function! neocomplcache#cache#filereadable(cache_dir, filename) "{{{ + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.filereadable(cache_dir, a:filename) +endfunction"}}} +function! neocomplcache#cache#readfile(cache_dir, filename) "{{{ + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.readfile(cache_dir, a:filename) +endfunction"}}} +function! neocomplcache#cache#writefile(cache_dir, filename, list) "{{{ + if neocomplcache#util#is_sudo() + return + endif + + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.writefile(cache_dir, a:filename, a:list) +endfunction"}}} +function! neocomplcache#cache#encode_name(cache_dir, filename) + " Check cache directory. + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.getfilename(cache_dir, a:filename) +endfunction +function! neocomplcache#cache#check_old_cache(cache_dir, filename) "{{{ + let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir + return s:Cache.check_old_cache(cache_dir, a:filename) +endfunction"}}} + +let s:sdir = neocomplcache#util#substitute_path_separator( + \ fnamemodify(expand(''), ':p:h')) + +function! neocomplcache#cache#async_load_from_file(cache_dir, filename, pattern, mark) "{{{ + if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename) + \ || neocomplcache#util#is_sudo() + return neocomplcache#cache#encode_name(a:cache_dir, a:filename) + endif + + let pattern_file_name = + \ neocomplcache#cache#encode_name('keyword_patterns', a:filename) + let cache_name = + \ neocomplcache#cache#encode_name(a:cache_dir, a:filename) + + " Create pattern file. + call neocomplcache#cache#writefile( + \ 'keyword_patterns', a:filename, [a:pattern]) + + " args: funcname, outputname, filename pattern mark + " minlen maxlen encoding + let fileencoding = + \ &fileencoding == '' ? &encoding : &fileencoding + let argv = [ + \ 'load_from_file', cache_name, a:filename, pattern_file_name, a:mark, + \ g:neocomplcache_min_keyword_length, + \ g:neocomplcache_max_menu_width, fileencoding + \ ] + return s:async_load(argv, a:cache_dir, a:filename) +endfunction"}}} +function! neocomplcache#cache#async_load_from_tags(cache_dir, filename, filetype, mark, is_create_tags) "{{{ + if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename) + \ || neocomplcache#util#is_sudo() + return neocomplcache#cache#encode_name(a:cache_dir, a:filename) + endif + + let cache_name = + \ neocomplcache#cache#encode_name(a:cache_dir, a:filename) + let pattern_file_name = + \ neocomplcache#cache#encode_name('tags_pattens', a:filename) + + if a:is_create_tags + if !executable(g:neocomplcache_ctags_program) + echoerr 'Create tags error! Please install ' + \ . g:neocomplcache_ctags_program . '.' + return neocomplcache#cache#encode_name(a:cache_dir, a:filename) + endif + + " Create tags file. + let tags_file_name = + \ neocomplcache#cache#encode_name('tags_output', a:filename) + + let default = get(g:neocomplcache_ctags_arguments_list, '_', '') + let args = get(g:neocomplcache_ctags_arguments_list, a:filetype, default) + + if has('win32') || has('win64') + let filename = + \ neocomplcache#util#substitute_path_separator(a:filename) + let command = printf('%s -f "%s" %s "%s" ', + \ g:neocomplcache_ctags_program, tags_file_name, args, filename) + else + let command = printf('%s -f ''%s'' 2>/dev/null %s ''%s''', + \ g:neocomplcache_ctags_program, tags_file_name, args, a:filename) + endif + + if neocomplcache#has_vimproc() + call vimproc#system_bg(command) + else + call system(command) + endif + else + let tags_file_name = '$dummy$' + endif + + let filter_pattern = + \ get(g:neocomplcache_tags_filter_patterns, a:filetype, '') + call neocomplcache#cache#writefile('tags_pattens', a:filename, + \ [neocomplcache#get_keyword_pattern(), + \ tags_file_name, filter_pattern, a:filetype]) + + " args: funcname, outputname, filename pattern mark + " minlen maxlen encoding + let fileencoding = &fileencoding == '' ? &encoding : &fileencoding + let argv = [ + \ 'load_from_tags', cache_name, a:filename, pattern_file_name, a:mark, + \ g:neocomplcache_min_keyword_length, + \ g:neocomplcache_max_menu_width, fileencoding + \ ] + return s:async_load(argv, a:cache_dir, a:filename) +endfunction"}}} +function! s:async_load(argv, cache_dir, filename) "{{{ + " if 0 + if neocomplcache#has_vimproc() + let paths = vimproc#get_command_name(v:progname, $PATH, -1) + if empty(paths) + if has('gui_macvim') + " MacVim check. + if !executable('/Applications/MacVim.app/Contents/MacOS/Vim') + call neocomplcache#print_error( + \ 'You installed MacVim in not default directory!'. + \ ' You must add MacVim installed path in $PATH.') + let g:neocomplcache_use_vimproc = 0 + return + endif + + let vim_path = '/Applications/MacVim.app/Contents/MacOS/Vim' + else + call neocomplcache#print_error( + \ printf('Vim path : "%s" is not found.'. + \ ' You must add "%s" installed path in $PATH.', + \ v:progname, v:progname)) + let g:neocomplcache_use_vimproc = 0 + return + endif + else + let base_path = neocomplcache#util#substitute_path_separator( + \ fnamemodify(paths[0], ':p:h')) + + let vim_path = base_path . + \ (neocomplcache#util#is_windows() ? '/vim.exe' : '/vim') + endif + + if !executable(vim_path) && neocomplcache#util#is_mac() + " Note: Search "Vim" instead of vim. + let vim_path = base_path. '/Vim' + endif + + if !executable(vim_path) + call neocomplcache#print_error( + \ printf('Vim path : "%s" is not executable.', vim_path)) + let g:neocomplcache_use_vimproc = 0 + return + endif + + let args = [vim_path, '-u', 'NONE', '-i', 'NONE', '-n', + \ '-N', '-S', s:sdir.'/async_cache.vim'] + \ + a:argv + call vimproc#system_bg(args) + " call vimproc#system(args) + " call system(join(args)) + else + call neocomplcache#async_cache#main(a:argv) + endif + + return neocomplcache#cache#encode_name(a:cache_dir, a:filename) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/commands.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/commands.vim new file mode 100644 index 0000000..12f647c --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/commands.vim @@ -0,0 +1,277 @@ +"============================================================================= +" FILE: commands.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 12 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#commands#_initialize() "{{{ + command! -nargs=? Neco call s:display_neco() + command! -nargs=1 NeoComplCacheAutoCompletionLength + \ call s:set_auto_completion_length() +endfunction"}}} + +function! neocomplcache#commands#_toggle_lock() "{{{ + if neocomplcache#get_current_neocomplcache().lock + echo 'neocomplcache is unlocked!' + call neocomplcache#commands#_unlock() + else + echo 'neocomplcache is locked!' + call neocomplcache#commands#_lock() + endif +endfunction"}}} + +function! neocomplcache#commands#_lock() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.lock = 1 +endfunction"}}} + +function! neocomplcache#commands#_unlock() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.lock = 0 +endfunction"}}} + +function! neocomplcache#commands#_lock_source(source_name) "{{{ + if !neocomplcache#is_enabled() + call neocomplcache#print_warning( + \ 'neocomplcache is disabled! This command is ignored.') + return + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let neocomplcache.lock_sources[a:source_name] = 1 +endfunction"}}} + +function! neocomplcache#commands#_unlock_source(source_name) "{{{ + if !neocomplcache#is_enabled() + call neocomplcache#print_warning( + \ 'neocomplcache is disabled! This command is ignored.') + return + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let neocomplcache.lock_sources[a:source_name] = 1 +endfunction"}}} + +function! neocomplcache#commands#_clean() "{{{ + " Delete cache files. + for directory in filter(neocomplcache#util#glob( + \ g:neocomplcache_temporary_dir.'/*'), 'isdirectory(v:val)') + for filename in filter(neocomplcache#util#glob(directory.'/*'), + \ '!isdirectory(v:val)') + call delete(filename) + endfor + endfor + + echo 'Cleaned cache files in: ' . g:neocomplcache_temporary_dir +endfunction"}}} + +function! neocomplcache#commands#_set_file_type(filetype) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.filetype = a:filetype +endfunction"}}} + +function! s:display_neco(number) "{{{ + let cmdheight_save = &cmdheight + + let animation = [ + \[ + \[ + \ " A A", + \ "~(-'_'-)" + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A ", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-^_^-)", + \], + \], + \[ + \[ + \ " A A", + \ "~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A ", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A ", + \ " ~(-'_'-)" + \], + \[ + \ " A A", + \ " ~(-'_'-)" + \], + \[ + \ " A A", + \ " ~(-'_'-)" + \], + \[ + \ " A A", + \ "~(-'_'-)" + \], + \], + \[ + \[ + \ " A A", + \ "~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A", + \ " ~(-'_'-)", + \], + \[" A A", + \ " ~(-'_'-)", + \], + \], + \[ + \[ + \ "", + \ " A A", + \ "~(-'_'-)", + \], + \[" A A", + \ " ~(-'_'-)", + \ "", + \], + \[ + \ "", + \ " A A", + \ " ~(-'_'-)", + \], + \[ + \ " A A ", + \ " ~(-'_'-)", + \ "", + \], + \[ + \ "", + \ " A A", + \ " ~(-^_^-)", + \], + \], + \[ + \[ + \ " A A A A", + \ "~(-'_'-) -8(*'_'*)" + \], + \[ + \ " A A A A", + \ " ~(-'_'-) -8(*'_'*)" + \], + \[ + \ " A A A A", + \ " ~(-'_'-) -8(*'_'*)" + \], + \[ + \ " A A A A", + \ " ~(-'_'-) -8(*'_'*)" + \], + \[ + \ " A A A A", + \ "~(-'_'-) -8(*'_'*)" + \], + \], + \[ + \[ + \ " A\\_A\\", + \ "(=' .' ) ~w", + \ "(,(\")(\")", + \], + \], + \] + + let number = (a:number != '') ? a:number : len(animation) + let anim = get(animation, number, animation[s:rand(len(animation) - 1)]) + let &cmdheight = len(anim[0]) + + for frame in anim + echo repeat("\n", &cmdheight-2) + redraw + echon join(frame, "\n") + sleep 300m + endfor + redraw + + let &cmdheight = cmdheight_save +endfunction"}}} + +function! s:rand(max) "{{{ + if !has('reltime') + " Same value. + return 0 + endif + + let time = reltime()[1] + return (time < 0 ? -time : time)% (a:max + 1) +endfunction"}}} + +function! s:set_auto_completion_length(len) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.completion_length = a:len +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/complete.vim new file mode 100644 index 0000000..59e20b9 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/complete.vim @@ -0,0 +1,383 @@ +"============================================================================= +" FILE: complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 06 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#complete#manual_complete(findstart, base) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + if a:findstart + let cur_text = neocomplcache#get_cur_text() + if !neocomplcache#is_enabled() + \ || neocomplcache#helper#is_omni_complete(cur_text) + call neocomplcache#helper#clear_result() + let &l:completefunc = 'neocomplcache#complete#manual_complete' + + return (neocomplcache#is_prefetch() + \ || g:neocomplcache_enable_insert_char_pre) ? + \ -1 : -3 + endif + + " Get complete_pos. + if neocomplcache#is_prefetch() && !empty(neocomplcache.complete_results) + " Use prefetch results. + else + let neocomplcache.complete_results = + \ neocomplcache#complete#_get_results(cur_text) + endif + let complete_pos = + \ neocomplcache#complete#_get_complete_pos(neocomplcache.complete_results) + + if complete_pos < 0 + call neocomplcache#helper#clear_result() + + let neocomplcache = neocomplcache#get_current_neocomplcache() + let complete_pos = (neocomplcache#is_prefetch() || + \ g:neocomplcache_enable_insert_char_pre || + \ neocomplcache#get_current_neocomplcache().skipped) ? -1 : -3 + let neocomplcache.skipped = 0 + endif + + return complete_pos + else + let complete_pos = neocomplcache#complete#_get_complete_pos( + \ neocomplcache.complete_results) + let neocomplcache.candidates = neocomplcache#complete#_get_words( + \ neocomplcache.complete_results, complete_pos, a:base) + let neocomplcache.complete_str = a:base + + if v:version > 703 || v:version == 703 && has('patch418') + let dict = { 'words' : neocomplcache.candidates } + + if (g:neocomplcache_enable_cursor_hold_i + \ || v:version > 703 || v:version == 703 && has('patch561')) + \ && len(a:base) < g:neocomplcache_auto_completion_start_length + " Note: If Vim is less than 7.3.561, it have broken register "." problem. + let dict.refresh = 'always' + endif + return dict + else + return neocomplcache.candidates + endif + endif +endfunction"}}} + +function! neocomplcache#complete#sources_manual_complete(findstart, base) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + if a:findstart + if !neocomplcache#is_enabled() + call neocomplcache#helper#clear_result() + return -2 + endif + + " Get complete_pos. + let complete_results = neocomplcache#complete#_get_results( + \ neocomplcache#get_cur_text(1), neocomplcache.manual_sources) + let neocomplcache.complete_pos = + \ neocomplcache#complete#_get_complete_pos(complete_results) + + if neocomplcache.complete_pos < 0 + call neocomplcache#helper#clear_result() + + return -2 + endif + + let neocomplcache.complete_results = complete_results + + return neocomplcache.complete_pos + endif + + let neocomplcache.complete_pos = + \ neocomplcache#complete#_get_complete_pos( + \ neocomplcache.complete_results) + let candidates = neocomplcache#complete#_get_words( + \ neocomplcache.complete_results, + \ neocomplcache.complete_pos, a:base) + + let neocomplcache.candidates = candidates + let neocomplcache.complete_str = a:base + + return candidates +endfunction"}}} + +function! neocomplcache#complete#unite_complete(findstart, base) "{{{ + " Dummy. + return a:findstart ? -1 : [] +endfunction"}}} + +function! neocomplcache#complete#auto_complete(findstart, base) "{{{ + return neocomplcache#complete#manual_complete(a:findstart, a:base) +endfunction"}}} + +function! neocomplcache#complete#_get_results(cur_text, ...) "{{{ + if g:neocomplcache_enable_debug + echomsg 'start get_complete_results' + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.start_time = reltime() + + let complete_results = call( + \ 'neocomplcache#complete#_set_results_pos', [a:cur_text] + a:000) + call neocomplcache#complete#_set_results_words(complete_results) + + return filter(complete_results, + \ '!empty(v:val.neocomplcache__context.candidates)') +endfunction"}}} + +function! neocomplcache#complete#_get_complete_pos(sources) "{{{ + if empty(a:sources) + return -1 + endif + + return min([col('.')] + map(copy(a:sources), + \ 'v:val.neocomplcache__context.complete_pos')) +endfunction"}}} + +function! neocomplcache#complete#_get_words(sources, complete_pos, complete_str) "{{{ + let frequencies = neocomplcache#variables#get_frequencies() + if exists('*neocomplcache#sources#buffer_complete#get_frequencies') + let frequencies = extend(copy( + \ neocomplcache#sources#buffer_complete#get_frequencies()), + \ frequencies) + endif + + " Append prefix. + let candidates = [] + let len_words = 0 + for source in sort(filter(copy(a:sources), + \ '!empty(v:val.neocomplcache__context.candidates)'), + \ 's:compare_source_rank') + let context = source.neocomplcache__context + let words = + \ type(context.candidates[0]) == type('') ? + \ map(copy(context.candidates), "{'word': v:val}") : + \ deepcopy(context.candidates) + let context.candidates = words + + call neocomplcache#helper#call_hook( + \ source, 'on_post_filter', {}) + + if context.complete_pos > a:complete_pos + let prefix = a:complete_str[: context.complete_pos + \ - a:complete_pos - 1] + + for candidate in words + let candidate.word = prefix . candidate.word + endfor + endif + + for candidate in words + if !has_key(candidate, 'menu') && has_key(source, 'mark') + " Set default menu. + let candidate.menu = source.mark + endif + if has_key(frequencies, candidate.word) + let candidate.rank = frequencies[candidate.word] + endif + endfor + + let words = neocomplcache#helper#call_filters( + \ source.sorters, source, {}) + + if source.max_candidates > 0 + let words = words[: len(source.max_candidates)-1] + endif + + let words = neocomplcache#helper#call_filters( + \ source.converters, source, {}) + + let candidates += words + let len_words += len(words) + + if g:neocomplcache_max_list > 0 + \ && len_words > g:neocomplcache_max_list + break + endif + + if neocomplcache#complete_check() + return [] + endif + endfor + + if g:neocomplcache_max_list > 0 + let candidates = candidates[: g:neocomplcache_max_list] + endif + + " Check dup and set icase. + let icase = g:neocomplcache_enable_ignore_case && + \!(g:neocomplcache_enable_smart_case && a:complete_str =~ '\u') + \ && !neocomplcache#is_text_mode() + for candidate in candidates + if has_key(candidate, 'kind') && candidate.kind == '' + " Remove kind key. + call remove(candidate, 'kind') + endif + + let candidate.icase = icase + endfor + + if neocomplcache#complete_check() + return [] + endif + + return candidates +endfunction"}}} +function! neocomplcache#complete#_set_results_pos(cur_text, ...) "{{{ + " Set context filetype. + call neocomplcache#context_filetype#set() + + " Initialize sources. + let neocomplcache = neocomplcache#get_current_neocomplcache() + for source in filter(values(neocomplcache#variables#get_sources()), + \ '!v:val.loaded && (empty(v:val.filetypes) || + \ get(v:val.filetypes, + \ neocomplcache.context_filetype, 0))') + call neocomplcache#helper#call_hook(source, 'on_init', {}) + let source.loaded = 1 + endfor + + let sources = filter(copy(get(a:000, 0, + \ neocomplcache#helper#get_sources_list())), 'v:val.loaded') + if a:0 < 1 + call filter(sources, '!neocomplcache#is_plugin_locked(v:key)') + endif + + " Try source completion. "{{{ + let complete_sources = [] + for source in values(sources) + let context = source.neocomplcache__context + let context.input = a:cur_text + let context.complete_pos = -1 + let context.complete_str = '' + let context.candidates = [] + + let pos = winsaveview() + + try + let complete_pos = + \ has_key(source, 'get_keyword_pos') ? + \ source.get_keyword_pos(context.input) : + \ has_key(source, 'get_complete_position') ? + \ source.get_complete_position(context) : + \ neocomplcache#match_word(context.input)[0] + catch + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + call neocomplcache#print_error( + \ 'Error occurred in source''s get_complete_position()!') + call neocomplcache#print_error( + \ 'Source name is ' . source.name) + return complete_sources + finally + if winsaveview() != pos + call winrestview(pos) + endif + endtry + + if complete_pos < 0 + continue + endif + + let complete_str = context.input[complete_pos :] + if neocomplcache#is_auto_complete() && + \ neocomplcache#util#mb_strlen(complete_str) + \ < neocomplcache#get_completion_length(source.name) + " Skip. + continue + endif + + let context.complete_pos = complete_pos + let context.complete_str = complete_str + call add(complete_sources, source) + endfor + "}}} + + return complete_sources +endfunction"}}} +function! neocomplcache#complete#_set_results_words(sources) "{{{ + " Try source completion. + for source in a:sources + if neocomplcache#complete_check() + return + endif + + " Save options. + let ignorecase_save = &ignorecase + + let context = source.neocomplcache__context + + if neocomplcache#is_text_mode() + let &ignorecase = 1 + elseif g:neocomplcache_enable_smart_case + \ && context.complete_str =~ '\u' + let &ignorecase = 0 + else + let &ignorecase = g:neocomplcache_enable_ignore_case + endif + + let pos = winsaveview() + + try + let context.candidates = has_key(source, 'get_keyword_list') ? + \ source.get_keyword_list(context.complete_str) : + \ has_key(source, 'get_complete_words') ? + \ source.get_complete_words( + \ context.complete_pos, context.complete_str) : + \ source.gather_candidates(context) + catch + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + call neocomplcache#print_error( + \ 'Source name is ' . source.name) + call neocomplcache#print_error( + \ 'Error occurred in source''s gather_candidates()!') + return + finally + if winsaveview() != pos + call winrestview(pos) + endif + endtry + + if g:neocomplcache_enable_debug + echomsg source.name + endif + + let &ignorecase = ignorecase_save + endfor +endfunction"}}} + +" Source rank order. "{{{ +function! s:compare_source_rank(i1, i2) + return a:i2.rank - a:i1.rank +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/context_filetype.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/context_filetype.vim new file mode 100644 index 0000000..c023941 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/context_filetype.vim @@ -0,0 +1,207 @@ +"============================================================================= +" FILE: context_filetype.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 18 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#context_filetype#initialize() "{{{ + " Initialize context filetype lists. + call neocomplcache#util#set_default( + \ 'g:neocomplcache_context_filetype_lists', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'c,cpp', [ + \ {'filetype' : 'masm', + \ 'start' : '_*asm_*\s\+\h\w*', 'end' : '$'}, + \ {'filetype' : 'masm', + \ 'start' : '_*asm_*\s*\%(\n\s*\)\?{', 'end' : '}'}, + \ {'filetype' : 'gas', + \ 'start' : '_*asm_*\s*\%(_*volatile_*\s*\)\?(', 'end' : ');'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'd', [ + \ {'filetype' : 'masm', + \ 'start' : 'asm\s*\%(\n\s*\)\?{', 'end' : '}'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'perl6', [ + \ {'filetype' : 'pir', 'start' : 'Q:PIR\s*{', 'end' : '}'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'vimshell', [ + \ {'filetype' : 'vim', + \ 'start' : 'vexe \([''"]\)', 'end' : '\\\@'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'vim', [ + \ {'filetype' : 'python', + \ 'start' : '^\s*py\%[thon\]3\? <<\s*\(\h\w*\)', 'end' : '^\1'}, + \ {'filetype' : 'ruby', + \ 'start' : '^\s*rub\%[y\] <<\s*\(\h\w*\)', 'end' : '^\1'}, + \ {'filetype' : 'lua', + \ 'start' : '^\s*lua <<\s*\(\h\w*\)', 'end' : '^\1'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'html,xhtml', [ + \ {'filetype' : 'javascript', 'start' : + \']*\)\? type="text/javascript"\%( [^>]*\)\?>', + \ 'end' : ''}, + \ {'filetype' : 'coffee', 'start' : + \']*\)\? type="text/coffeescript"\%( [^>]*\)\?>', + \ 'end' : ''}, + \ {'filetype' : 'css', 'start' : + \']*\)\? type="text/css"\%( [^>]*\)\?>', + \ 'end' : ''}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'python', [ + \ {'filetype' : 'vim', + \ 'start' : 'vim.command\s*(\([''"]\)', 'end' : '\\\@', 'end' : '^<'}, + \]) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_context_filetype_lists', + \ 'nyaos,int-nyaos', [ + \ {'filetype' : 'lua', + \ 'start' : '\ new filetype graph. + let dup_check[old_filetype] = new_filetype + let old_filetype = new_filetype + endwhile + + return neocomplcache.context_filetype +endfunction"}}} +function! neocomplcache#context_filetype#get(filetype) "{{{ + " Default. + let filetype = a:filetype + if filetype == '' + let filetype = 'nothing' + endif + + " Default range. + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let pos = [line('.'), col('.')] + for include in get(g:neocomplcache_context_filetype_lists, filetype, []) + let start_backward = searchpos(include.start, 'bneW') + + " Check pos > start. + if start_backward[0] == 0 || s:compare_pos(start_backward, pos) > 0 + continue + endif + + let end_pattern = include.end + if end_pattern =~ '\\1' + let match_list = matchlist(getline(start_backward[0]), include.start) + let end_pattern = substitute(end_pattern, '\\1', '\=match_list[1]', 'g') + endif + let end_forward = searchpos(end_pattern, 'nW') + if end_forward[0] == 0 + let end_forward = [line('$'), len(getline('$'))+1] + endif + + " Check end > pos. + if s:compare_pos(pos, end_forward) > 0 + continue + endif + + let end_backward = searchpos(end_pattern, 'bnW') + + " Check start <= end. + if s:compare_pos(start_backward, end_backward) < 0 + continue + endif + + if start_backward[1] == len(getline(start_backward[0])) + " Next line. + let start_backward[0] += 1 + let start_backward[1] = 1 + endif + if end_forward[1] == 1 + " Previous line. + let end_forward[0] -= 1 + let end_forward[1] = len(getline(end_forward[0])) + endif + + let neocomplcache.context_filetype_range = + \ [ start_backward, end_forward ] + return include.filetype + endfor + + return filetype +endfunction"}}} + +function! s:compare_pos(i1, i2) + return a:i1[0] == a:i2[0] ? a:i1[1] - a:i2[1] : a:i1[0] - a:i2[0] +endfunction" + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters.vim new file mode 100644 index 0000000..8615c42 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters.vim @@ -0,0 +1,132 @@ +"============================================================================= +" FILE: filters.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 28 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#keyword_filter(list, complete_str) "{{{ + let complete_str = a:complete_str + + if g:neocomplcache_enable_debug + echomsg len(a:list) + endif + + " Delimiter check. + let filetype = neocomplcache#get_context_filetype() + for delimiter in get(g:neocomplcache_delimiter_patterns, filetype, []) + let complete_str = substitute(complete_str, + \ delimiter, '*' . delimiter, 'g') + endfor + + if complete_str == '' || + \ &l:completefunc ==# 'neocomplcache#complete#unite_complete' || + \ empty(a:list) + return a:list + elseif neocomplcache#check_match_filter(complete_str) + " Match filter. + let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word' + + let expr = printf('%s =~ %s', + \ word, string('^' . + \ neocomplcache#keyword_escape(complete_str))) + if neocomplcache#is_auto_complete() + " Don't complete cursor word. + let expr .= printf(' && %s !=? a:complete_str', word) + endif + + " Check head character. + if complete_str[0] != '\' && complete_str[0] != '.' + let expr = word.'[0] == ' . + \ string(complete_str[0]) .' && ' . expr + endif + + call neocomplcache#print_debug(expr) + + return filter(a:list, expr) + else + " Use fast filter. + return s:head_filter(a:list, complete_str) + endif +endfunction"}}} + +function! s:head_filter(list, complete_str) "{{{ + let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word' + + if &ignorecase + let expr = printf('!stridx(tolower(%s), %s)', + \ word, string(tolower(a:complete_str))) + else + let expr = printf('!stridx(%s, %s)', + \ word, string(a:complete_str)) + endif + + if neocomplcache#is_auto_complete() + " Don't complete cursor word. + let expr .= printf(' && %s !=? a:complete_str', word) + endif + + return filter(a:list, expr) +endfunction"}}} + +function! neocomplcache#filters#dictionary_filter(dictionary, complete_str) "{{{ + if empty(a:dictionary) + return [] + endif + + let completion_length = 2 + if len(a:complete_str) < completion_length || + \ neocomplcache#check_completion_length_match( + \ a:complete_str, completion_length) || + \ &l:completefunc ==# 'neocomplcache#cunite_complete' + return neocomplcache#keyword_filter( + \ neocomplcache#unpack_dictionary(a:dictionary), a:complete_str) + endif + + let key = tolower(a:complete_str[: completion_length-1]) + + if !has_key(a:dictionary, key) + return [] + endif + + let list = a:dictionary[key] + if type(list) == type({}) + " Convert dictionary dictionary. + unlet list + let list = values(a:dictionary[key]) + else + let list = copy(list) + endif + + return (len(a:complete_str) == completion_length && &ignorecase + \ && !neocomplcache#check_completion_length_match( + \ a:complete_str, completion_length)) ? + \ list : neocomplcache#keyword_filter(list, a:complete_str) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_abbr.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_abbr.vim new file mode 100644 index 0000000..8019cf2 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_abbr.vim @@ -0,0 +1,63 @@ +"============================================================================= +" FILE: converter_abbr.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 06 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#converter_abbr#define() "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_abbr', + \ 'description' : 'abbr converter', + \} + +function! s:converter.filter(context) "{{{ + if g:neocomplcache_max_keyword_width < 0 + return a:context.candidates + endif + + for candidate in a:context.candidates + let abbr = get(candidate, 'abbr', candidate.word) + if len(abbr) > g:neocomplcache_max_keyword_width + let len = neocomplcache#util#wcswidth(abbr) + + if len > g:neocomplcache_max_keyword_width + let candidate.abbr = neocomplcache#util#truncate_smart( + \ abbr, g:neocomplcache_max_keyword_width, + \ g:neocomplcache_max_keyword_width/2, '..') + endif + endif + endfor + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_case.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_case.vim new file mode 100644 index 0000000..2699a77 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_case.vim @@ -0,0 +1,79 @@ +"============================================================================= +" FILE: converter_case.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 02 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#converter_case#define() "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_case', + \ 'description' : 'case converter', + \} + +function! s:converter.filter(context) "{{{ + if !neocomplcache#is_text_mode() && !neocomplcache#within_comment() + return a:context.candidates + endif + + let convert_candidates = filter(copy(a:context.candidates), + \ "get(v:val, 'neocomplcache__convertable', 1) + \ && v:val.word =~ '^[a-zA-Z0-9_''-]\\+$'") + + if a:context.complete_str =~ '^\l\+$' + for candidate in convert_candidates + let candidate.word = tolower(candidate.word) + if has_key(candidate, 'abbr') + let candidate.abbr = tolower(candidate.abbr) + endif + endfor + elseif a:context.complete_str =~ '^\u\+$' + for candidate in convert_candidates + let candidate.word = toupper(candidate.word) + if has_key(candidate, 'abbr') + let candidate.abbr = toupper(candidate.abbr) + endif + endfor + elseif a:context.complete_str =~ '^\u\l\+$' + for candidate in convert_candidates + let candidate.word = toupper(candidate.word[0]). + \ tolower(candidate.word[1:]) + if has_key(candidate, 'abbr') + let candidate.abbr = toupper(candidate.abbr[0]). + \ tolower(candidate.abbr[1:]) + endif + endfor + endif + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_delimiter.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_delimiter.vim new file mode 100644 index 0000000..cac3a32 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_delimiter.vim @@ -0,0 +1,94 @@ +"============================================================================= +" FILE: converter_delimiter.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 06 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#converter_delimiter#define() "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_delimiter', + \ 'description' : 'delimiter converter', + \} + +function! s:converter.filter(context) "{{{ + if g:neocomplcache_max_keyword_width < 0 + return a:context.candidates + endif + + " Delimiter check. + let filetype = neocomplcache#get_context_filetype() + + let next_keyword = neocomplcache#filters# + \converter_remove_next_keyword#get_next_keyword(a:context.source_name) + for delimiter in ['/'] + + \ get(g:neocomplcache_delimiter_patterns, filetype, []) + " Count match. + let delim_cnt = 0 + let matchend = matchend(a:context.complete_str, delimiter) + while matchend >= 0 + let matchend = matchend(a:context.complete_str, + \ delimiter, matchend) + let delim_cnt += 1 + endwhile + + for candidate in a:context.candidates + let split_list = split(candidate.word, delimiter.'\ze.', 1) + if len(split_list) > 1 + let delimiter_sub = substitute( + \ delimiter, '\\\([.^$]\)', '\1', 'g') + let candidate.word = join(split_list[ : delim_cnt], delimiter_sub) + let candidate.abbr = join( + \ split(get(candidate, 'abbr', candidate.word), + \ delimiter.'\ze.', 1)[ : delim_cnt], + \ delimiter_sub) + + if g:neocomplcache_max_keyword_width >= 0 + \ && len(candidate.abbr) > g:neocomplcache_max_keyword_width + let candidate.abbr = substitute(candidate.abbr, + \ '\(\h\)\w*'.delimiter, '\1'.delimiter_sub, 'g') + endif + if delim_cnt+1 < len(split_list) + let candidate.abbr .= delimiter_sub . '~' + let candidate.dup = 0 + + if g:neocomplcache_enable_auto_delimiter && next_keyword == '' + let candidate.word .= delimiter_sub + endif + endif + endif + endfor + endfor + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_nothing.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_nothing.vim new file mode 100644 index 0000000..4e3d6dc --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_nothing.vim @@ -0,0 +1,47 @@ +"============================================================================= +" FILE: converter_nothing.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#converter_nothing#define() "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_nothing', + \ 'description' : 'nothing converter', + \} + +function! s:converter.filter(context) "{{{ + " Nothing. + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_remove_next_keyword.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_remove_next_keyword.vim new file mode 100644 index 0000000..d186db7 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/converter_remove_next_keyword.vim @@ -0,0 +1,87 @@ +"============================================================================= +" FILE: converter_remove_next_keyword.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 31 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#converter_remove_next_keyword#define() "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_remove_next_keyword', + \ 'description' : 'remove next keyword converter', + \} + +function! s:converter.filter(context) "{{{ + " Remove next keyword. + let next_keyword = neocomplcache#filters# + \converter_remove_next_keyword#get_next_keyword(a:context.source_name) + if next_keyword == '' + return a:context.candidates + endif + + let next_keyword = substitute( + \ substitute(escape(next_keyword, + \ '~" \.^$*[]'), "'", "''", 'g'), ')$', '', '').'$' + + " No ignorecase. + let ignorecase_save = &ignorecase + let &ignorecase = 0 + try + for r in a:context.candidates + let pos = match(r.word, next_keyword) + if pos >= 0 + if !has_key(r, 'abbr') + let r.abbr = r.word + endif + + let r.word = r.word[: pos-1] + endif + endfor + finally + let &ignorecase = ignorecase_save + endtry + + return a:context.candidates +endfunction"}}} + +function! neocomplcache#filters#converter_remove_next_keyword#get_next_keyword(source_name) "{{{ + let pattern = '^\%(' . + \ ((a:source_name ==# 'filename_complete' || + \ a:source_name ==# 'filename_complete') ? + \ neocomplcache#get_next_keyword_pattern('filename') : + \ neocomplcache#get_next_keyword_pattern()) . '\m\)' + + let next_keyword = matchstr('a'. + \ getline('.')[len(neocomplcache#get_cur_text(1)) :], pattern)[1:] + return next_keyword +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_fuzzy.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_fuzzy.vim new file mode 100644 index 0000000..838cf55 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_fuzzy.vim @@ -0,0 +1,47 @@ +"============================================================================= +" FILE: matcher_fuzzy.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#matcher_fuzzy#define() "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_fuzzy', + \ 'description' : 'fuzzy matcher', + \} + +function! s:matcher.filter(context) "{{{ + " Todo: + return [] +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_head.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_head.vim new file mode 100644 index 0000000..275e3b6 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_head.vim @@ -0,0 +1,47 @@ +"============================================================================= +" FILE: matcher_head.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 25 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#matcher_head#define() "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_head', + \ 'description' : 'head matcher', + \} + +function! s:matcher.filter(context) "{{{ + " Todo: + return [] +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_old.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_old.vim new file mode 100644 index 0000000..89da149 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/matcher_old.vim @@ -0,0 +1,57 @@ +"============================================================================= +" FILE: matcher_old.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 25 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#matcher_old#define() "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_old', + \ 'description' : 'old matcher', + \} + +function! s:matcher.filter(candidates, context) "{{{ + if a:context.input == '' + return neocomplcache#util#filter_matcher( + \ a:candidates, '', a:context) + endif + + let candidates = a:candidates + for input in a:context.input_list + let candidates = neocomplcache#filters#matcher_old#glob_matcher( + \ candidates, input, a:context) + endfor + + return candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_length.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_length.vim new file mode 100644 index 0000000..8020de1 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_length.vim @@ -0,0 +1,54 @@ +"============================================================================= +" FILE: sorter_length.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 09 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#sorter_length#define() "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_length', + \ 'description' : 'sort by length order', + \} + +function! s:sorter.filter(context) "{{{ + return sort(a:context.candidates, 's:compare') +endfunction"}}} + +function! s:compare(i1, i2) + let diff = len(a:i1.word) - len(a:i2.word) + if !diff + let diff = (a:i1.word ># a:i2.word) ? 1 : -1 + endif + return diff +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_nothing.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_nothing.vim new file mode 100644 index 0000000..4535f13 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_nothing.vim @@ -0,0 +1,47 @@ +"============================================================================= +" FILE: sorter_nothing.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#sorter_nothing#define() "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_nothing', + \ 'description' : 'nothing sorter', + \} + +function! s:sorter.filter(context) "{{{ + " Nothing. + return a:candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_rank.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_rank.vim new file mode 100644 index 0000000..cc1355b --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/filters/sorter_rank.vim @@ -0,0 +1,51 @@ +"============================================================================= +" FILE: sorter_rank.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 09 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#sorter_rank#define() "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_rank', + \ 'description' : 'sort by matched rank order', + \} + +function! s:sorter.filter(context) "{{{ + return sort(a:context.candidates, 's:compare') +endfunction"}}} + +function! s:compare(i1, i2) + let diff = (get(a:i2, 'rank', 0) - get(a:i1, 'rank', 0)) + return (diff != 0) ? diff : (a:i1.word ># a:i2.word) ? 1 : -1 +endfunction" + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/handler.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/handler.vim new file mode 100644 index 0000000..7b7a620 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/handler.vim @@ -0,0 +1,300 @@ +"============================================================================= +" FILE: handler.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 02 Oct 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#handler#_on_moved_i() "{{{ + " Get cursor word. + let cur_text = neocomplcache#get_cur_text(1) + + call s:close_preview_window() +endfunction"}}} +function! neocomplcache#handler#_on_insert_enter() "{{{ + if &l:foldmethod ==# 'expr' && foldlevel('.') != 0 + foldopen + endif +endfunction"}}} +function! neocomplcache#handler#_on_insert_leave() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let neocomplcache.cur_text = '' + let neocomplcache.old_cur_text = '' + + call s:close_preview_window() +endfunction"}}} +function! neocomplcache#handler#_on_write_post() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + " Restore foldinfo. + for winnr in filter(range(1, winnr('$')), + \ "!empty(getwinvar(v:val, 'neocomplcache_foldinfo'))") + let neocomplcache_foldinfo = + \ getwinvar(winnr, 'neocomplcache_foldinfo') + call setwinvar(winnr, '&foldmethod', + \ neocomplcache_foldinfo.foldmethod) + call setwinvar(winnr, '&foldexpr', + \ neocomplcache_foldinfo.foldexpr) + call setwinvar(winnr, + \ 'neocomplcache_foldinfo', {}) + endfor +endfunction"}}} +function! neocomplcache#handler#_on_complete_done() "{{{ + " Get cursor word. + let [_, candidate] = neocomplcache#match_word( + \ neocomplcache#get_cur_text(1)) + if candidate == '' + return + endif + + let frequencies = neocomplcache#variables#get_frequencies() + if !has_key(frequencies, candidate) + let frequencies[candidate] = 20 + else + let frequencies[candidate] += 20 + endif +endfunction"}}} +function! neocomplcache#handler#_change_update_time() "{{{ + if &updatetime > g:neocomplcache_cursor_hold_i_time + " Change updatetime. + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.update_time_save = &updatetime + let &updatetime = g:neocomplcache_cursor_hold_i_time + endif +endfunction"}}} +function! neocomplcache#handler#_restore_update_time() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + if &updatetime < neocomplcache.update_time_save + " Restore updatetime. + let &updatetime = neocomplcache.update_time_save + endif +endfunction"}}} + +function! neocomplcache#handler#_do_auto_complete(event) "{{{ + if s:check_in_do_auto_complete() + return + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.skipped = 0 + let neocomplcache.event = a:event + + let cur_text = neocomplcache#get_cur_text(1) + + if g:neocomplcache_enable_debug + echomsg 'cur_text = ' . cur_text + endif + + " Prevent infinity loop. + if s:is_skip_auto_complete(cur_text) + " Make cache. + if cur_text =~ '^\s*$\|\s\+$' + if neocomplcache#is_enabled_source('buffer_complete') + " Caching current cache line. + call neocomplcache#sources#buffer_complete#caching_current_line() + endif + if neocomplcache#is_enabled_source('member_complete') + " Caching current cache line. + call neocomplcache#sources#member_complete#caching_current_line() + endif + endif + + if g:neocomplcache_enable_debug + echomsg 'Skipped.' + endif + + call neocomplcache#helper#clear_result() + return + endif + + let neocomplcache.old_cur_text = cur_text + + if neocomplcache#helper#is_omni_complete(cur_text) + call feedkeys("\(neocomplcache_start_omni_complete)") + return + endif + + " Check multibyte input or eskk. + if neocomplcache#is_eskk_enabled() + \ || neocomplcache#is_multibyte_input(cur_text) + if g:neocomplcache_enable_debug + echomsg 'Skipped.' + endif + + return + endif + + " Check complete position. + let complete_results = neocomplcache#complete#_set_results_pos(cur_text) + if empty(complete_results) + if g:neocomplcache_enable_debug + echomsg 'Skipped.' + endif + + return + endif + + let &l:completefunc = 'neocomplcache#complete#auto_complete' + + if neocomplcache#is_prefetch() + " Do prefetch. + let neocomplcache.complete_results = + \ neocomplcache#complete#_get_results(cur_text) + + if empty(neocomplcache.complete_results) + if g:neocomplcache_enable_debug + echomsg 'Skipped.' + endif + + " Skip completion. + let &l:completefunc = 'neocomplcache#complete#manual_complete' + call neocomplcache#helper#clear_result() + return + endif + endif + + call s:save_foldinfo() + + " Set options. + set completeopt-=menu + set completeopt-=longest + set completeopt+=menuone + + " Start auto complete. + call feedkeys(&l:formatoptions !~ 'a' ? + \ "\(neocomplcache_start_auto_complete)": + \ "\(neocomplcache_start_auto_complete_no_select)") +endfunction"}}} + +function! s:save_foldinfo() "{{{ + " Save foldinfo. + let winnrs = filter(range(1, winnr('$')), + \ "winbufnr(v:val) == bufnr('%')") + + " Note: for foldmethod=expr or syntax. + call filter(winnrs, " + \ (getwinvar(v:val, '&foldmethod') ==# 'expr' || + \ getwinvar(v:val, '&foldmethod') ==# 'syntax') && + \ getwinvar(v:val, '&modifiable')") + for winnr in winnrs + call setwinvar(winnr, 'neocomplcache_foldinfo', { + \ 'foldmethod' : getwinvar(winnr, '&foldmethod'), + \ 'foldexpr' : getwinvar(winnr, '&foldexpr') + \ }) + call setwinvar(winnr, '&foldmethod', 'manual') + call setwinvar(winnr, '&foldexpr', 0) + endfor +endfunction"}}} +function! s:check_in_do_auto_complete() "{{{ + if neocomplcache#is_locked() + return 1 + endif + + if &l:completefunc == '' + let &l:completefunc = 'neocomplcache#complete#manual_complete' + endif + + " Detect completefunc. + if &l:completefunc !~# '^neocomplcache#' + if &l:buftype =~ 'nofile' + return 1 + endif + + if g:neocomplcache_force_overwrite_completefunc + " Set completefunc. + let &l:completefunc = 'neocomplcache#complete#manual_complete' + else + " Warning. + redir => output + 99verbose setl completefunc? + redir END + call neocomplcache#print_error(output) + call neocomplcache#print_error( + \ 'Another plugin set completefunc! Disabled neocomplcache.') + NeoComplCacheLock + return 1 + endif + endif + + " Detect AutoComplPop. + if exists('g:acp_enableAtStartup') && g:acp_enableAtStartup + call neocomplcache#print_error( + \ 'Detected enabled AutoComplPop! Disabled neocomplcache.') + NeoComplCacheLock + return 1 + endif +endfunction"}}} +function! s:is_skip_auto_complete(cur_text) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + if a:cur_text =~ '^\s*$\|\s\+$' + \ || a:cur_text == neocomplcache.old_cur_text + \ || (g:neocomplcache_lock_iminsert && &l:iminsert) + \ || (&l:formatoptions =~# '[tc]' && &l:textwidth > 0 + \ && neocomplcache#util#wcswidth(a:cur_text) >= &l:textwidth) + return 1 + endif + + if !neocomplcache.skip_next_complete + return 0 + endif + + " Check delimiter pattern. + let is_delimiter = 0 + let filetype = neocomplcache#get_context_filetype() + + for delimiter in ['/', '\.'] + + \ get(g:neocomplcache_delimiter_patterns, filetype, []) + if a:cur_text =~ delimiter . '$' + let is_delimiter = 1 + break + endif + endfor + + if is_delimiter && neocomplcache.skip_next_complete == 2 + let neocomplcache.skip_next_complete = 0 + return 0 + endif + + let neocomplcache.skip_next_complete = 0 + let neocomplcache.cur_text = '' + let neocomplcache.old_cur_text = '' + + return 1 +endfunction"}}} +function! s:close_preview_window() "{{{ + if g:neocomplcache_enable_auto_close_preview && + \ bufname('%') !=# '[Command Line]' && + \ winnr('$') != 1 && !&l:previewwindow + " Close preview window. + pclose! + endif +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/helper.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/helper.vim new file mode 100644 index 0000000..c24ecc8 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/helper.vim @@ -0,0 +1,438 @@ +"============================================================================= +" FILE: helper.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 20 Aug 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#helper#get_cur_text() "{{{ + let cur_text = + \ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ? + \ getline('.') : + \ matchstr(getline('.'), + \ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.')) + + if cur_text =~ '^.\{-}\ze\S\+$' + let complete_str = matchstr(cur_text, '\S\+$') + let cur_text = matchstr(cur_text, '^.\{-}\ze\S\+$') + else + let complete_str = '' + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + if neocomplcache.event ==# 'InsertCharPre' + let complete_str .= v:char + endif + + let filetype = neocomplcache#get_context_filetype() + let wildcard = get(g:neocomplcache_wildcard_characters, filetype, + \ get(g:neocomplcache_wildcard_characters, '_', '*')) + if g:neocomplcache_enable_wildcard && + \ wildcard !=# '*' && len(wildcard) == 1 + " Substitute wildcard character. + while 1 + let index = stridx(complete_str, wildcard) + if index <= 0 + break + endif + + let complete_str = complete_str[: index-1] + \ . '*' . complete_str[index+1: ] + endwhile + endif + + let neocomplcache.cur_text = cur_text . complete_str + + " Save cur_text. + return neocomplcache.cur_text +endfunction"}}} + +function! neocomplcache#helper#keyword_escape(complete_str) "{{{ + " Fuzzy completion. + let keyword_len = len(a:complete_str) + let keyword_escape = s:keyword_escape(a:complete_str) + if g:neocomplcache_enable_fuzzy_completion + \ && (g:neocomplcache_fuzzy_completion_start_length + \ <= keyword_len && keyword_len < 20) + let pattern = keyword_len >= 8 ? + \ '\0\\w*' : '\\%(\0\\w*\\|\U\0\E\\l*\\)' + + let start = g:neocomplcache_fuzzy_completion_start_length + if start <= 1 + let keyword_escape = + \ substitute(keyword_escape, '\w', pattern, 'g') + elseif keyword_len < 8 + let keyword_escape = keyword_escape[: start - 2] + \ . substitute(keyword_escape[start-1 :], '\w', pattern, 'g') + else + let keyword_escape = keyword_escape[: 3] . + \ substitute(keyword_escape[4:12], '\w', + \ pattern, 'g') . keyword_escape[13:] + endif + else + " Underbar completion. "{{{ + if g:neocomplcache_enable_underbar_completion + \ && keyword_escape =~ '[^_]_\|^_' + let keyword_escape = substitute(keyword_escape, + \ '\%(^\|[^_]\)\zs_', '[^_]*_', 'g') + endif + if g:neocomplcache_enable_underbar_completion + \ && '-' =~ '\k' && keyword_escape =~ '[^-]-' + let keyword_escape = substitute(keyword_escape, + \ '[^-]\zs-', '[^-]*-', 'g') + endif + "}}} + " Camel case completion. "{{{ + if g:neocomplcache_enable_camel_case_completion + \ && keyword_escape =~ '\u\?\U*' + let keyword_escape = + \ substitute(keyword_escape, + \ '\u\?\zs\U*', + \ '\\%(\0\\l*\\|\U\0\E\\u*_\\?\\)', 'g') + endif + "}}} + endif + + call neocomplcache#print_debug(keyword_escape) + return keyword_escape +endfunction"}}} + +function! neocomplcache#helper#is_omni_complete(cur_text) "{{{ + " Check eskk complete length. + if neocomplcache#is_eskk_enabled() + \ && exists('g:eskk#start_completion_length') + if !neocomplcache#is_eskk_convertion(a:cur_text) + \ || !neocomplcache#is_multibyte_input(a:cur_text) + return 0 + endif + + let complete_pos = call(&l:omnifunc, [1, '']) + let complete_str = a:cur_text[complete_pos :] + return neocomplcache#util#mb_strlen(complete_str) >= + \ g:eskk#start_completion_length + endif + + let filetype = neocomplcache#get_context_filetype() + let omnifunc = get(g:neocomplcache_omni_functions, + \ filetype, &l:omnifunc) + + if neocomplcache#check_invalid_omnifunc(omnifunc) + return 0 + endif + + let syn_name = neocomplcache#helper#get_syn_name(1) + if syn_name ==# 'Comment' || syn_name ==# 'String' + " Skip omni_complete in string literal. + return 0 + endif + + if has_key(g:neocomplcache_force_omni_patterns, omnifunc) + let pattern = g:neocomplcache_force_omni_patterns[omnifunc] + elseif filetype != '' && + \ get(g:neocomplcache_force_omni_patterns, filetype, '') != '' + let pattern = g:neocomplcache_force_omni_patterns[filetype] + else + return 0 + endif + + if a:cur_text !~# '\%(' . pattern . '\m\)$' + return 0 + endif + + " Set omnifunc. + let &omnifunc = omnifunc + + return 1 +endfunction"}}} + +function! neocomplcache#helper#is_enabled_source(source_name) "{{{ + if neocomplcache#is_disabled_source(a:source_name) + return 0 + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + if !has_key(neocomplcache, 'sources') + call neocomplcache#helper#get_sources_list() + endif + + return index(keys(neocomplcache.sources), a:source_name) >= 0 +endfunction"}}} + +function! neocomplcache#helper#get_source_filetypes(filetype) "{{{ + let filetype = (a:filetype == '') ? 'nothing' : a:filetype + + let filetype_dict = {} + + let filetypes = [filetype] + if filetype =~ '\.' + if exists('g:neocomplcache_ignore_composite_filetype_lists') + \ && has_key(g:neocomplcache_ignore_composite_filetype_lists, filetype) + let filetypes = [g:neocomplcache_ignore_composite_filetype_lists[filetype]] + else + " Set composite filetype. + let filetypes += split(filetype, '\.') + endif + endif + + if exists('g:neocomplcache_same_filetype_lists') + for ft in copy(filetypes) + let filetypes += split(get(g:neocomplcache_same_filetype_lists, ft, + \ get(g:neocomplcache_same_filetype_lists, '_', '')), ',') + endfor + endif + + return neocomplcache#util#uniq(filetypes) +endfunction"}}} + +function! neocomplcache#helper#get_completion_length(plugin_name) "{{{ + " Todo. +endfunction"}}} + +function! neocomplcache#helper#complete_check() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + if g:neocomplcache_enable_debug + echomsg split(reltimestr(reltime(neocomplcache.start_time)))[0] + endif + let ret = (!neocomplcache#is_prefetch() && complete_check()) + \ || (neocomplcache#is_auto_complete() + \ && g:neocomplcache_skip_auto_completion_time != '' + \ && split(reltimestr(reltime(neocomplcache.start_time)))[0] > + \ g:neocomplcache_skip_auto_completion_time) + if ret + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.skipped = 1 + + redraw + echo 'Skipped.' + endif + + return ret +endfunction"}}} + +function! neocomplcache#helper#get_syn_name(is_trans) "{{{ + return len(getline('.')) < 200 ? + \ synIDattr(synIDtrans(synID(line('.'), mode() ==# 'i' ? + \ col('.')-1 : col('.'), a:is_trans)), 'name') : '' +endfunction"}}} + +function! neocomplcache#helper#match_word(cur_text, ...) "{{{ + let pattern = a:0 >= 1 ? a:1 : neocomplcache#get_keyword_pattern_end() + + " Check wildcard. + let complete_pos = s:match_wildcard( + \ a:cur_text, pattern, match(a:cur_text, pattern)) + + let complete_str = (complete_pos >=0) ? + \ a:cur_text[complete_pos :] : '' + + return [complete_pos, complete_str] +endfunction"}}} + +function! neocomplcache#helper#filetype_complete(arglead, cmdline, cursorpos) "{{{ + " Dup check. + let ret = {} + for item in map( + \ split(globpath(&runtimepath, 'syntax/*.vim'), '\n') + + \ split(globpath(&runtimepath, 'indent/*.vim'), '\n') + + \ split(globpath(&runtimepath, 'ftplugin/*.vim'), '\n') + \ , 'fnamemodify(v:val, ":t:r")') + if !has_key(ret, item) && item =~ '^'.a:arglead + let ret[item] = 1 + endif + endfor + + return sort(keys(ret)) +endfunction"}}} + +function! neocomplcache#helper#unite_patterns(pattern_var, filetype) "{{{ + let keyword_patterns = [] + let dup_check = {} + + " Composite filetype. + for ft in split(a:filetype, '\.') + if has_key(a:pattern_var, ft) && !has_key(dup_check, ft) + let dup_check[ft] = 1 + call add(keyword_patterns, a:pattern_var[ft]) + endif + + " Same filetype. + if exists('g:neocomplcache_same_filetype_lists') + \ && has_key(g:neocomplcache_same_filetype_lists, ft) + for ft in split(g:neocomplcache_same_filetype_lists[ft], ',') + if has_key(a:pattern_var, ft) && !has_key(dup_check, ft) + let dup_check[ft] = 1 + call add(keyword_patterns, a:pattern_var[ft]) + endif + endfor + endif + endfor + + if empty(keyword_patterns) + let default = get(a:pattern_var, '_', get(a:pattern_var, 'default', '')) + if default != '' + call add(keyword_patterns, default) + endif + endif + + return join(keyword_patterns, '\m\|') +endfunction"}}} + +function! neocomplcache#helper#ftdictionary2list(dictionary, filetype) "{{{ + let list = [] + for filetype in neocomplcache#get_source_filetypes(a:filetype) + if has_key(a:dictionary, filetype) + call add(list, a:dictionary[filetype]) + endif + endfor + + return list +endfunction"}}} + +function! neocomplcache#helper#get_sources_list(...) "{{{ + let filetype = neocomplcache#get_context_filetype() + + let source_names = exists('b:neocomplcache_sources_list') ? + \ b:neocomplcache_sources_list : + \ get(a:000, 0, + \ get(g:neocomplcache_sources_list, filetype, + \ get(g:neocomplcache_sources_list, '_', ['_']))) + let disabled_sources = get( + \ g:neocomplcache_disabled_sources_list, filetype, + \ get(g:neocomplcache_disabled_sources_list, '_', [])) + call neocomplcache#init#_sources(source_names) + + let all_sources = neocomplcache#available_sources() + let sources = {} + for source_name in source_names + if source_name ==# '_' + " All sources. + let sources = all_sources + break + endif + + if !has_key(all_sources, source_name) + call neocomplcache#print_warning(printf( + \ 'Invalid source name "%s" is given.', source_name)) + continue + endif + + let sources[source_name] = all_sources[source_name] + endfor + + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.sources = filter(sources, " + \ index(disabled_sources, v:val.name) < 0 && + \ (empty(v:val.filetypes) || + \ get(v:val.filetypes, neocomplcache.context_filetype, 0))") + + return neocomplcache.sources +endfunction"}}} + +function! neocomplcache#helper#clear_result() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let neocomplcache.complete_str = '' + let neocomplcache.candidates = [] + let neocomplcache.complete_results = [] + let neocomplcache.complete_pos = -1 +endfunction"}}} + +function! neocomplcache#helper#call_hook(sources, hook_name, context) "{{{ + for source in neocomplcache#util#convert2list(a:sources) + try + if !has_key(source.hooks, a:hook_name) + if a:hook_name ==# 'on_init' && has_key(source, 'initialize') + call source.initialize() + elseif a:hook_name ==# 'on_final' && has_key(source, 'finalize') + call source.finalize() + endif + else + call call(source.hooks[a:hook_name], + \ [extend(source.neocomplcache__context, a:context)], + \ source.hooks) + endif + catch + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + call neocomplcache#print_error( + \ '[unite.vim] Error occurred in calling hook "' . a:hook_name . '"!') + call neocomplcache#print_error( + \ '[unite.vim] Source name is ' . source.name) + endtry + endfor +endfunction"}}} + +function! neocomplcache#helper#call_filters(filters, source, context) "{{{ + let context = extend(a:source.neocomplcache__context, a:context) + let _ = [] + for filter in neocomplcache#init#_filters( + \ neocomplcache#util#convert2list(a:filters)) + try + let context.candidates = call(filter.filter, [context], filter) + catch + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + call neocomplcache#print_error( + \ '[unite.vim] Error occurred in calling filter ' + \ . filter.name . '!') + call neocomplcache#print_error( + \ '[unite.vim] Source name is ' . a:source.name) + endtry + endfor + + return context.candidates +endfunction"}}} + +function! s:match_wildcard(cur_text, pattern, complete_pos) "{{{ + let complete_pos = a:complete_pos + while complete_pos > 1 && a:cur_text[complete_pos - 1] == '*' + let left_text = a:cur_text[: complete_pos - 2] + if left_text == '' || left_text !~ a:pattern + break + endif + + let complete_pos = match(left_text, a:pattern) + endwhile + + return complete_pos +endfunction"}}} + +function! s:keyword_escape(complete_str) "{{{ + let keyword_escape = escape(a:complete_str, '~" \.^$[]') + if g:neocomplcache_enable_wildcard + let keyword_escape = substitute( + \ substitute(keyword_escape, '.\zs\*', '.*', 'g'), + \ '\%(^\|\*\)\zs\*', '\\*', 'g') + else + let keyword_escape = escape(keyword_escape, '*') + endif + + return keyword_escape +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/init.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/init.vim new file mode 100644 index 0000000..c7a110e --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/init.vim @@ -0,0 +1,870 @@ +"============================================================================= +" FILE: init.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 25 Oct 2013. +" 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:save_cpo = &cpo +set cpo&vim + +if !exists('s:is_enabled') + let s:is_enabled = 0 +endif + +function! neocomplcache#init#lazy() "{{{ + if !exists('s:lazy_progress') + let s:lazy_progress = 0 + endif + + if s:lazy_progress == 0 + call neocomplcache#init#_others() + let s:is_enabled = 0 + elseif s:lazy_progress == 1 + call neocomplcache#init#_sources(get(g:neocomplcache_sources_list, + \ neocomplcache#get_context_filetype(), ['_'])) + else + call neocomplcache#init#_autocmds() + let s:is_enabled = 1 + endif + + let s:lazy_progress += 1 +endfunction"}}} + +function! neocomplcache#init#enable() "{{{ + if neocomplcache#is_enabled() + return + endif + + call neocomplcache#init#_autocmds() + call neocomplcache#init#_others() + + call neocomplcache#init#_sources(get(g:neocomplcache_sources_list, + \ neocomplcache#get_context_filetype(), ['_'])) + let s:is_enabled = 1 +endfunction"}}} + +function! neocomplcache#init#disable() "{{{ + if !neocomplcache#is_enabled() + call neocomplcache#print_warning( + \ 'neocomplcache is disabled! This command is ignored.') + return + endif + + let s:is_enabled = 0 + + augroup neocomplcache + autocmd! + augroup END + + delcommand NeoComplCacheDisable + + call neocomplcache#helper#call_hook(filter(values( + \ neocomplcache#variables#get_sources()), 'v:val.loaded'), + \ 'on_final', {}) +endfunction"}}} + +function! neocomplcache#init#is_enabled() "{{{ + return s:is_enabled +endfunction"}}} + +function! neocomplcache#init#_autocmds() "{{{ + augroup neocomplcache + autocmd! + autocmd InsertEnter * + \ call neocomplcache#handler#_on_insert_enter() + autocmd InsertLeave * + \ call neocomplcache#handler#_on_insert_leave() + autocmd CursorMovedI * + \ call neocomplcache#handler#_on_moved_i() + autocmd BufWritePost * + \ call neocomplcache#handler#_on_write_post() + augroup END + + if g:neocomplcache_enable_insert_char_pre + \ && (v:version > 703 || v:version == 703 && has('patch418')) + autocmd neocomplcache InsertCharPre * + \ call neocomplcache#handler#_do_auto_complete('InsertCharPre') + elseif g:neocomplcache_enable_cursor_hold_i + augroup neocomplcache + autocmd CursorHoldI * + \ call neocomplcache#handler#_do_auto_complete('CursorHoldI') + autocmd InsertEnter * + \ call neocomplcache#handler#_change_update_time() + autocmd InsertLeave * + \ call neocomplcache#handler#_restore_update_time() + augroup END + else + autocmd neocomplcache CursorMovedI * + \ call neocomplcache#handler#_do_auto_complete('CursorMovedI') + endif + + if (v:version > 703 || v:version == 703 && has('patch598')) + autocmd neocomplcache CompleteDone * + \ call neocomplcache#handler#_on_complete_done() + endif +endfunction"}}} + +function! neocomplcache#init#_others() "{{{ + call neocomplcache#init#_variables() + + call neocomplcache#context_filetype#initialize() + + call neocomplcache#commands#_initialize() + + " Save options. + let s:completefunc_save = &completefunc + let s:completeopt_save = &completeopt + + " Set completefunc. + let completefunc_save = &l:completefunc + let &completefunc = 'neocomplcache#complete#manual_complete' + if completefunc_save != '' + let &l:completefunc = completefunc_save + endif + + " For auto complete keymappings. + call neocomplcache#mappings#define_default_mappings() + + " Detect set paste. + if &paste + redir => output + 99verbose set paste + redir END + call neocomplcache#print_error(output) + call neocomplcache#print_error( + \ 'Detected set paste! Disabled neocomplcache.') + endif + + command! -nargs=0 -bar NeoComplCacheDisable + \ call neocomplcache#init#disable() +endfunction"}}} + +function! neocomplcache#init#_variables() "{{{ + " Initialize keyword patterns. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_keyword_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'_', + \'\k\+') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_keyword_patterns', + \'filename', + \ neocomplcache#util#is_windows() ? + \'\%(\a\+:/\)\?\%([/[:alnum:]()$+_~.\x80-\xff-]\|[^[:print:]]\|\\.\)\+' : + \'\%([/\[\][:alnum:]()$+_~.-]\|[^[:print:]]\|\\.\)\+') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'lisp,scheme,clojure,int-gosh,int-clisp,int-clj', + \'[[:alpha:]+*/@$_=.!?-][[:alnum:]+*/@$_:=.!?-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'ruby,int-irb', + \'^=\%(b\%[egin]\|e\%[nd]\)\|\%(@@\|[$@]\)\h\w*\|\h\w*\%(::\w*\)*[!?]\?') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'php,int-php', + \'\)\?'. + \'\|\$\h\w*\|\h\w*\%(\%(\\\|::\)\w*\)*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'perl,int-perlsh', + \'<\h\w*>\?\|[$@%&*]\h\w*\|\h\w*\%(::\w*\)*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'perl6,int-perl6', + \'<\h\w*>\?\|[$@%&][!.*?]\?\h[[:alnum:]_-]*'. + \'\|\h[[:alnum:]_-]*\%(::[[:alnum:]_-]*\)*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'pir', + \'[$@%.=]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'pasm', + \'[=]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'vim,help', + \'-\h[[:alnum:]-]*=\?\|\c\[:\%(\h\w*:\]\)\?\|&\h[[:alnum:]_:]*\|'. + \'\%(\h\w*\)\?\|([^)]*)\?'. + \'\|<\h[[:alnum:]_-]*>\?\|\h[[:alnum:]_:#]*!\?\|$\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'tex', + \'\\\a{\a\{1,2}}\|\\[[:alpha:]@][[:alnum:]@]*'. + \'\%({\%([[:alnum:]:_]\+\*\?}\?\)\?\)\?\|\a[[:alnum:]:_]*\*\?') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'sh,zsh,int-zsh,int-bash,int-sh', + \'[[:alpha:]_.-][[:alnum:]_.-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'vimshell', + \'\$\$\?\w*\|[[:alpha:]_.\\/~-][[:alnum:]_.\\/~-]*\|\d\+\%(\.\d\+\)\+') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'ps1,int-powershell', + \'\[\h\%([[:alnum:]_.]*\]::\)\?\|[$%@.]\?[[:alpha:]_.:-][[:alnum:]_.:-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'c', + \'^\s*#\s*\h\w*\|\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'cpp', + \'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'objc', + \'^\s*#\s*\h\w*\|\h\w*\|@\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'objcpp', + \'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*\|@\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'objj', + \'\h\w*\|@\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'d', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'python,int-python,int-ipython', + \'[@]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'cs', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'java', + \'[@]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'javascript,actionscript,int-js,int-kjs,int-rhino', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'coffee,int-coffee', + \'[@]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'awk', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'haskell,int-ghci', + \'\%(\u\w*\.\)\+[[:alnum:]_'']*\|[[:alpha:]_''][[:alnum:]_'']*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'ml,ocaml,int-ocaml,int-sml,int-smlsharp', + \'[''`#.]\?\h[[:alnum:]_'']*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'erlang,int-erl', + \'^\s*-\h\w*\|\%(\h\w*:\)*\h\w*\|\h[[:alnum:]_@]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'html,xhtml,xml,markdown,eruby', + \'\)\?\|&\h\%(\w*;\)\?'. + \'\|\h[[:alnum:]_-]*="\%([^"]*"\?\)\?\|\h[[:alnum:]_:-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'css,stylus,scss,less', + \'[@#.]\?[[:alpha:]_:-][[:alnum:]_:-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'tags', + \'^[^!][^/[:blank:]]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'pic', + \'^\s*#\h\w*\|\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'arm', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'asmh8300', + \'[[:alpha:]_.][[:alnum:]_.]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'masm', + \'\.\h\w*\|[[:alpha:]_@?$][[:alnum:]_@?$]*\|\h\w*:\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'nasm', + \'^\s*\[\h\w*\|[%.]\?\h\w*\|\%(\.\.@\?\|%[%$!]\)\%(\h\w*\)\?\|\h\w*:\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'asm', + \'[%$.]\?\h\w*\%(\$\h\w*\)\?') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'gas', + \'[$.]\?\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'gdb,int-gdb', + \'$\h\w*\|[[:alnum:]:._-]\+') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'make', + \'[[:alpha:]_.-][[:alnum:]_.-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'scala,int-scala', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'int-termtter', + \'\h[[:alnum:]_/-]*\|\$\a\+\|#\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'int-earthquake', + \'[:#$]\h\w*\|\h[[:alnum:]_/-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'dosbatch,int-cmdproxy', + \'\$\w+\|[[:alpha:]_./-][[:alnum:]_.-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'vb', + \'\h\w*\|#\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'lua', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \ 'zimbu', + \'\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'konoha', + \'[*$@%]\h\w*\|\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'cobol', + \'\a[[:alnum:]-]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'coq', + \'\h[[:alnum:]_'']*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'tcl', + \'[.-]\h\w*\|\h\w*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_keyword_patterns', + \'nyaos,int-nyaos', + \'\h\w*') + "}}} + + " Initialize next keyword patterns. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_next_keyword_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'perl', + \'\h\w*>') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'perl6', + \'\h\w*>') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'vim,help', + \'\w*()\?\|\w*:\]\|[[:alnum:]_-]*[)>=]') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'python', + \'\w*()\?') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'tex', + \'[[:alnum:]:_]\+[*[{}]') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_next_keyword_patterns', 'html,xhtml,xml,mkd', + \'[^"]*"\|[[:alnum:]_:-]*>') + "}}} + + " Initialize same file type lists. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_same_filetype_lists', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'c', 'cpp') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'cpp', 'c') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'erb', 'ruby,html,xhtml') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'html,xml', 'xhtml') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'html,xhtml', 'css,stylus,less') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'css', 'scss') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'scss', 'css') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'stylus', 'css') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'less', 'css') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'xhtml', 'html,xml') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'help', 'vim') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'tex', 'bib,plaintex') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'plaintex', 'bib,tex') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'lingr-say', 'lingr-messages,lingr-members') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'J6uil_say', 'J6uil') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'vimconsole', 'vim') + + " Interactive filetypes. + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-irb', 'ruby') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-ghci,int-hugs', 'haskell') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-python,int-ipython', 'python') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-gosh', 'scheme') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-clisp', 'lisp') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-erl', 'erlang') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-zsh', 'zsh') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-bash', 'bash') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-sh', 'sh') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-cmdproxy', 'dosbatch') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-powershell', 'powershell') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-perlsh', 'perl') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-perl6', 'perl6') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-ocaml', 'ocaml') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-clj', 'clojure') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-sml,int-smlsharp', 'sml') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-js,int-kjs,int-rhino', 'javascript') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-coffee', 'coffee') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-gdb', 'gdb') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-scala', 'scala') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-nyaos', 'nyaos') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists', + \ 'int-php', 'php') + "}}} + + " Initialize delimiter patterns. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_delimiter_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'vim,help', ['#']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'erlang,lisp,int-clisp', [':']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'lisp,int-clisp', ['/', ':']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'clojure,int-clj', ['/', '\.']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'perl,cpp', ['::']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'php', ['\', '::']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'java,d,javascript,actionscript,'. + \ 'ruby,eruby,haskell,int-ghci,coffee,zimbu,konoha', + \ ['\.']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'lua', ['\.', ':']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_delimiter_patterns', + \ 'perl6', ['\.', '::']) + "}}} + + " Initialize ctags arguments. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_ctags_arguments_list', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_ctags_arguments_list', + \ '_', '') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_ctags_arguments_list', 'vim', + \ '--extra=fq --fields=afmiKlnsStz ' . + \ "--regex-vim='/function!? ([a-z#:_0-9A-Z]+)/\\1/function/'") + if neocomplcache#util#is_mac() + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_ctags_arguments_list', 'c', + \ '--c-kinds=+p --fields=+iaS --extra=+q + \ -I__DARWIN_ALIAS,__DARWIN_ALIAS_C,__DARWIN_ALIAS_I,__DARWIN_INODE64 + \ -I__DARWIN_1050,__DARWIN_1050ALIAS,__DARWIN_1050ALIAS_C,__DARWIN_1050ALIAS_I,__DARWIN_1050INODE64 + \ -I__DARWIN_EXTSN,__DARWIN_EXTSN_C + \ -I__DARWIN_LDBL_COMPAT,__DARWIN_LDBL_COMPAT2') + else + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_ctags_arguments_list', 'c', + \ '-R --sort=1 --c-kinds=+p --fields=+iaS --extra=+q ' . + \ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'. + \ '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+') + endif + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_ctags_arguments_list', 'cpp', + \ '--language-force=C++ -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q '. + \ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'. + \ '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+') + "}}} + + " Initialize text mode filetypes. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_text_mode_filetypes', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_text_mode_filetypes', + \ 'hybrid,text,help,tex,gitcommit,gitrebase,vcs-commit,markdown,'. + \ 'textile,creole,org,rdoc,mediawiki,rst,asciidoc,pod', 1) + "}}} + + " Initialize tags filter patterns. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_tags_filter_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_tags_filter_patterns', 'c,cpp', + \'v:val.word !~ ''^[~_]''') + "}}} + + " Initialize force omni completion pattern. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_force_omni_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_force_omni_patterns', 'objc', + \'\h\w\+\|[^.[:digit:] *\t]\%(\.\|->\)') + "}}} + + " Initialize ignore composite filetypes + call neocomplcache#util#set_default( + \ 'g:neocomplcache_ignore_composite_filetype_lists', {}) + + " Must g:neocomplcache_auto_completion_start_length > 1. + if g:neocomplcache_auto_completion_start_length < 1 + let g:neocomplcache_auto_completion_start_length = 1 + endif + " Must g:neocomplcache_min_keyword_length > 1. + if g:neocomplcache_min_keyword_length < 1 + let g:neocomplcache_min_keyword_length = 1 + endif + + " Initialize omni function list. "{{{ + if !exists('g:neocomplcache_omni_functions') + let g:neocomplcache_omni_functions = {} + endif + "}}} + + " Set custom. + call s:set_default_custom() +endfunction"}}} + +function! neocomplcache#init#_current_neocomplcache() "{{{ + let b:neocomplcache = { + \ 'context' : { + \ 'input' : '', + \ 'complete_pos' : -1, + \ 'complete_str' : '', + \ 'candidates' : [], + \ }, + \ 'lock' : 0, + \ 'skip_next_complete' : 0, + \ 'filetype' : '', + \ 'context_filetype' : '', + \ 'context_filetype_range' : + \ [[1, 1], [line('$'), len(getline('$'))+1]], + \ 'completion_length' : -1, + \ 'update_time_save' : &updatetime, + \ 'foldinfo' : [], + \ 'lock_sources' : {}, + \ 'skipped' : 0, + \ 'event' : '', + \ 'cur_text' : '', + \ 'old_cur_text' : '', + \ 'complete_str' : '', + \ 'complete_pos' : -1, + \ 'candidates' : [], + \ 'complete_results' : [], + \ 'complete_sources' : [], + \ 'manual_sources' : [], + \ 'start_time' : reltime(), + \} +endfunction"}}} + +function! neocomplcache#init#_sources(names) "{{{ + if !exists('s:loaded_source_files') + " Initialize. + let s:loaded_source_files = {} + let s:loaded_all_sources = 0 + let s:runtimepath_save = '' + endif + + " Initialize sources table. + if s:loaded_all_sources && &runtimepath ==# s:runtimepath_save + return + endif + + let runtimepath_save = neocomplcache#util#split_rtp(s:runtimepath_save) + let runtimepath = neocomplcache#util#join_rtp( + \ filter(neocomplcache#util#split_rtp(), + \ 'index(runtimepath_save, v:val) < 0')) + let sources = neocomplcache#variables#get_sources() + + for name in filter(copy(a:names), '!has_key(sources, v:val)') + " Search autoload. + for source_name in map(split(globpath(runtimepath, + \ 'autoload/neocomplcache/sources/*.vim'), '\n'), + \ "fnamemodify(v:val, ':t:r')") + if has_key(s:loaded_source_files, source_name) + continue + endif + + let s:loaded_source_files[source_name] = 1 + + let source = neocomplcache#sources#{source_name}#define() + if empty(source) + " Ignore. + continue + endif + + call neocomplcache#define_source(source) + endfor + + if name == '_' + let s:loaded_all_sources = 1 + let s:runtimepath_save = &runtimepath + endif + endfor +endfunction"}}} + +function! neocomplcache#init#_source(source) "{{{ + let default = { + \ 'max_candidates' : 0, + \ 'filetypes' : {}, + \ 'hooks' : {}, + \ 'matchers' : ['matcher_old'], + \ 'sorters' : ['sorter_rank'], + \ 'converters' : [ + \ 'converter_remove_next_keyword', + \ 'converter_delimiter', + \ 'converter_case', + \ 'converter_abbr', + \ ], + \ 'neocomplcache__context' : copy(neocomplcache#get_context()), + \ } + + let source = extend(copy(default), a:source) + + " Overwritten by user custom. + let custom = neocomplcache#variables#get_custom().sources + let source = extend(source, get(custom, source.name, + \ get(custom, '_', {}))) + + let source.loaded = 0 + " Source kind convertion. + if source.kind ==# 'plugin' || + \ (!has_key(source, 'gather_candidates') && + \ !has_key(source, 'get_complete_words')) + let source.kind = 'keyword' + elseif source.kind ==# 'ftplugin' || source.kind ==# 'complfunc' + " For compatibility. + let source.kind = 'manual' + else + let source.kind = 'manual' + endif + + if !has_key(source, 'rank') + " Set default rank. + let source.rank = (source.kind ==# 'keyword') ? 5 : + \ empty(source.filetypes) ? 10 : 100 + endif + + if !has_key(source, 'min_pattern_length') + " Set min_pattern_length. + let source.min_pattern_length = (source.kind ==# 'keyword') ? + \ g:neocomplcache_auto_completion_start_length : 0 + endif + + let source.neocomplcache__context.source_name = source.name + + " Note: This routine is for compatibility of old sources implementation. + " Initialize sources. + if empty(source.filetypes) && has_key(source, 'initialize') + try + call source.initialize() + catch + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + call neocomplcache#print_error( + \ 'Error occurred in source''s initialize()!') + call neocomplcache#print_error( + \ 'Source name is ' . source.name) + endtry + + let source.loaded = 1 + endif + + return source +endfunction"}}} + +function! neocomplcache#init#_filters(names) "{{{ + let _ = [] + let filters = neocomplcache#variables#get_filters() + + for name in a:names + if !has_key(filters, name) + " Search autoload. + for filter_name in map(split(globpath(&runtimepath, + \ 'autoload/neocomplcache/filters/'. + \ substitute(name, + \'^\%(matcher\|sorter\|converter\)_[^/_-]\+\zs[/_-].*$', '', '') + \ .'*.vim'), '\n'), "fnamemodify(v:val, ':t:r')") + let filter = neocomplcache#filters#{filter_name}#define() + if empty(filter) + " Ignore. + continue + endif + + call neocomplcache#define_filter(filter) + endfor + + if !has_key(filters, name) + " Not found. + call neocomplcache#print_error( + \ printf('filter name : %s is not found.', string(name))) + continue + endif + endif + + if has_key(filters, name) + call add(_, filters[name]) + endif + endfor + + return _ +endfunction"}}} + +function! neocomplcache#init#_filter(filter) "{{{ + let default = { + \ } + + let filter = extend(default, a:filter) + if !has_key(filter, 'kind') + let filter.kind = + \ (filter.name =~# '^matcher_') ? 'matcher' : + \ (filter.name =~# '^sorter_') ? 'sorter' : 'converter' + endif + + return filter +endfunction"}}} + +function! s:set_default_custom() "{{{ + let custom = neocomplcache#variables#get_custom().sources + + " Initialize completion length. + for [source_name, length] in items( + \ g:neocomplcache_source_completion_length) + if !has_key(custom, source_name) + let custom[source_name] = {} + endif + let custom[source_name].min_pattern_length = length + endfor + + " Initialize rank. + for [source_name, rank] in items( + \ g:neocomplcache_source_rank) + if !has_key(custom, source_name) + let custom[source_name] = {} + endif + let custom[source_name].rank = rank + endfor +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/mappings.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/mappings.vim new file mode 100644 index 0000000..4e06b1b --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/mappings.vim @@ -0,0 +1,188 @@ +"============================================================================= +" FILE: mappings.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 19 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#mappings#define_default_mappings() "{{{ + inoremap (neocomplcache_start_unite_complete) + \ unite#sources#neocomplcache#start_complete() + inoremap (neocomplcache_start_unite_quick_match) + \ unite#sources#neocomplcache#start_quick_match() + inoremap (neocomplcache_start_auto_complete) + \ =neocomplcache#mappings#popup_post() + inoremap (neocomplcache_start_auto_complete_no_select) + \ + " \ + inoremap (neocomplcache_start_omni_complete) + \ +endfunction"}}} + +function! neocomplcache#mappings#smart_close_popup() "{{{ + return g:neocomplcache_enable_auto_select ? + \ neocomplcache#mappings#cancel_popup() : + \ neocomplcache#mappings#close_popup() +endfunction +"}}} +function! neocomplcache#mappings#close_popup() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.complete_str = '' + let neocomplcache.skip_next_complete = 2 + let neocomplcache.candidates = [] + + return pumvisible() ? "\" : '' +endfunction +"}}} +function! neocomplcache#mappings#cancel_popup() "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let neocomplcache.skip_next_complete = 1 + call neocomplcache#helper#clear_result() + + return pumvisible() ? "\" : '' +endfunction +"}}} + +function! neocomplcache#mappings#popup_post() "{{{ + return !pumvisible() ? "" : + \ g:neocomplcache_enable_auto_select ? "\\" : + \ "\" +endfunction"}}} + +function! neocomplcache#mappings#undo_completion() "{{{ + if !exists(':NeoComplCacheDisable') + return '' + endif + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + " Get cursor word. + let [complete_pos, complete_str] = + \ neocomplcache#match_word(neocomplcache#get_cur_text(1)) + let old_keyword_str = neocomplcache.complete_str + let neocomplcache.complete_str = complete_str + + return (!pumvisible() ? '' : + \ complete_str ==# old_keyword_str ? "\" : "\") + \. repeat("\", len(complete_str)) . old_keyword_str +endfunction"}}} + +function! neocomplcache#mappings#complete_common_string() "{{{ + if !exists(':NeoComplCacheDisable') + return '' + endif + + " Save options. + let ignorecase_save = &ignorecase + + " Get cursor word. + let [complete_pos, complete_str] = + \ neocomplcache#match_word(neocomplcache#get_cur_text(1)) + + if neocomplcache#is_text_mode() + let &ignorecase = 1 + elseif g:neocomplcache_enable_smart_case && complete_str =~ '\u' + let &ignorecase = 0 + else + let &ignorecase = g:neocomplcache_enable_ignore_case + endif + + let is_fuzzy = g:neocomplcache_enable_fuzzy_completion + + try + let g:neocomplcache_enable_fuzzy_completion = 0 + let neocomplcache = neocomplcache#get_current_neocomplcache() + let candidates = neocomplcache#keyword_filter( + \ copy(neocomplcache.candidates), complete_str) + finally + let g:neocomplcache_enable_fuzzy_completion = is_fuzzy + endtry + + if empty(candidates) + let &ignorecase = ignorecase_save + + return '' + endif + + let common_str = candidates[0].word + for keyword in candidates[1:] + while !neocomplcache#head_match(keyword.word, common_str) + let common_str = common_str[: -2] + endwhile + endfor + if &ignorecase + let common_str = tolower(common_str) + endif + + let &ignorecase = ignorecase_save + + if common_str == '' + return '' + endif + + return (pumvisible() ? "\" : '') + \ . repeat("\", len(complete_str)) . common_str +endfunction"}}} + +" Manual complete wrapper. +function! neocomplcache#mappings#start_manual_complete(...) "{{{ + if !neocomplcache#is_enabled() + return '' + endif + + " Set context filetype. + call neocomplcache#context_filetype#set() + + let neocomplcache = neocomplcache#get_current_neocomplcache() + + let sources = get(a:000, 0, + \ keys(neocomplcache#available_sources())) + let neocomplcache.manual_sources = neocomplcache#helper#get_sources_list( + \ neocomplcache#util#convert2list(sources)) + + " Set function. + let &l:completefunc = 'neocomplcache#complete#sources_manual_complete' + + " Start complete. + return "\\\" +endfunction"}}} + +function! neocomplcache#mappings#start_manual_complete_list(complete_pos, complete_str, candidates) "{{{ + let neocomplcache = neocomplcache#get_current_neocomplcache() + let [neocomplcache.complete_pos, + \ neocomplcache.complete_str, neocomplcache.candidates] = + \ [a:complete_pos, a:complete_str, a:candidates] + + " Set function. + let &l:completefunc = 'neocomplcache#complete#auto_complete' + + " Start complete. + return "\\\" +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/buffer_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/buffer_complete.vim new file mode 100644 index 0000000..5b19cd7 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/buffer_complete.vim @@ -0,0 +1,436 @@ +"============================================================================= +" FILE: buffer_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" Important variables. +if !exists('s:buffer_sources') + let s:buffer_sources = {} + let s:async_dictionary_list = {} +endif + +let s:source = { + \ 'name' : 'buffer_complete', + \ 'kind' : 'manual', + \ 'mark' : '[B]', + \ 'rank' : 5, + \ 'min_pattern_length' : + \ g:neocomplcache_auto_completion_start_length, + \ 'hooks' : {}, + \} + +function! s:source.hooks.on_init(context) "{{{ + let s:buffer_sources = {} + + augroup neocomplcache "{{{ + " Caching events + autocmd BufEnter,BufRead,BufWinEnter * + \ call s:check_source() + autocmd CursorHold,CursorHoldI * + \ call s:check_cache() + autocmd BufWritePost * + \ call s:check_recache() + autocmd InsertEnter,InsertLeave * + \ call neocomplcache#sources#buffer_complete#caching_current_line() + augroup END"}}} + + " Create cache directory. + if !isdirectory(neocomplcache#get_temporary_directory() . '/buffer_cache') + \ && !neocomplcache#util#is_sudo() + call mkdir(neocomplcache#get_temporary_directory() . '/buffer_cache', 'p') + endif + + " Initialize script variables. "{{{ + let s:buffer_sources = {} + let s:cache_line_count = 70 + let s:rank_cache_count = 1 + let s:disable_caching_list = {} + let s:async_dictionary_list = {} + "}}} + + call s:check_source() +endfunction +"}}} + +function! s:source.hooks.on_final(context) "{{{ + delcommand NeoComplCacheCachingBuffer + delcommand NeoComplCachePrintSource + delcommand NeoComplCacheOutputKeyword + delcommand NeoComplCacheDisableCaching + delcommand NeoComplCacheEnableCaching + + let s:buffer_sources = {} +endfunction"}}} + +function! s:source.gather_candidates(context) "{{{ + call s:check_source() + + let keyword_list = [] + for [key, source] in s:get_sources_list() + call neocomplcache#cache#check_cache_list('buffer_cache', + \ source.path, s:async_dictionary_list, source.keyword_cache, 1) + + let keyword_list += neocomplcache#dictionary_filter( + \ source.keyword_cache, a:context.complete_str) + if key == bufnr('%') + let source.accessed_time = localtime() + endif + endfor + + return keyword_list +endfunction"}}} + +function! neocomplcache#sources#buffer_complete#define() "{{{ + return s:source +endfunction"}}} + +function! neocomplcache#sources#buffer_complete#get_frequencies() "{{{ + " Current line caching. + return get(get(s:buffer_sources, bufnr('%'), {}), 'frequencies', {}) +endfunction"}}} +function! neocomplcache#sources#buffer_complete#caching_current_line() "{{{ + " Current line caching. + return s:caching_current_buffer( + \ max([1, line('.') - 10]), min([line('.') + 10, line('$')])) +endfunction"}}} +function! neocomplcache#sources#buffer_complete#caching_current_block() "{{{ + " Current line caching. + return s:caching_current_buffer( + \ max([1, line('.') - 500]), min([line('.') + 500, line('$')])) +endfunction"}}} +function! s:caching_current_buffer(start, end) "{{{ + " Current line caching. + + if !s:exists_current_source() + call s:word_caching(bufnr('%')) + endif + + let source = s:buffer_sources[bufnr('%')] + let keyword_pattern = source.keyword_pattern + let keyword_pattern2 = '^\%('.keyword_pattern.'\m\)' + let keywords = source.keyword_cache + + let completion_length = 2 + let line = join(getline(a:start, a:end)) + let match = match(line, keyword_pattern) + while match >= 0 "{{{ + let match_str = matchstr(line, keyword_pattern2, match) + + " Ignore too short keyword. + if len(match_str) >= g:neocomplcache_min_keyword_length "{{{ + " Check dup. + let key = tolower(match_str[: completion_length-1]) + if !has_key(keywords, key) + let keywords[key] = {} + endif + if !has_key(keywords[key], match_str) + " Append list. + let keywords[key][match_str] = match_str + let source.frequencies[match_str] = 30 + endif + endif"}}} + + " Next match. + let match = match(line, keyword_pattern, match + len(match_str)) + endwhile"}}} +endfunction"}}} + +function! s:get_sources_list() "{{{ + let sources_list = [] + + let filetypes_dict = {} + for filetype in neocomplcache#get_source_filetypes( + \ neocomplcache#get_context_filetype()) + let filetypes_dict[filetype] = 1 + endfor + + for [key, source] in items(s:buffer_sources) + if has_key(filetypes_dict, source.filetype) + \ || has_key(filetypes_dict, '_') + \ || bufnr('%') == key + \ || (source.name ==# '[Command Line]' && bufnr('#') == key) + call add(sources_list, [key, source]) + endif + endfor + + return sources_list +endfunction"}}} + +function! s:initialize_source(srcname) "{{{ + let path = fnamemodify(bufname(a:srcname), ':p') + let filename = fnamemodify(path, ':t') + if filename == '' + let filename = '[No Name]' + let path .= '/[No Name]' + endif + + let ft = getbufvar(a:srcname, '&filetype') + if ft == '' + let ft = 'nothing' + endif + + let buflines = getbufline(a:srcname, 1, '$') + let keyword_pattern = neocomplcache#get_keyword_pattern(ft) + + let s:buffer_sources[a:srcname] = { + \ 'keyword_cache' : {}, + \ 'frequencies' : {}, + \ 'name' : filename, 'filetype' : ft, + \ 'keyword_pattern' : keyword_pattern, + \ 'end_line' : len(buflines), + \ 'accessed_time' : 0, + \ 'cached_time' : 0, + \ 'path' : path, 'loaded_cache' : 0, + \ 'cache_name' : neocomplcache#cache#encode_name( + \ 'buffer_cache', path), + \} +endfunction"}}} + +function! s:word_caching(srcname) "{{{ + " Initialize source. + call s:initialize_source(a:srcname) + + let source = s:buffer_sources[a:srcname] + + if !filereadable(source.path) + \ || getbufvar(a:srcname, '&buftype') =~ 'nofile' + return + endif + + let source.cache_name = + \ neocomplcache#cache#async_load_from_file( + \ 'buffer_cache', source.path, + \ source.keyword_pattern, 'B') + let source.cached_time = localtime() + let source.end_line = len(getbufline(a:srcname, 1, '$')) + let s:async_dictionary_list[source.path] = [{ + \ 'filename' : source.path, + \ 'cachename' : source.cache_name, + \ }] +endfunction"}}} + +function! s:check_changed_buffer(bufnumber) "{{{ + let source = s:buffer_sources[a:bufnumber] + + let ft = getbufvar(a:bufnumber, '&filetype') + if ft == '' + let ft = 'nothing' + endif + + let filename = fnamemodify(bufname(a:bufnumber), ':t') + if filename == '' + let filename = '[No Name]' + endif + + return s:buffer_sources[a:bufnumber].name != filename + \ || s:buffer_sources[a:bufnumber].filetype != ft +endfunction"}}} + +function! s:check_source() "{{{ + if !s:exists_current_source() + call neocomplcache#sources#buffer_complete#caching_current_block() + return + endif + + for bufnumber in range(1, bufnr('$')) + " Check new buffer. + let bufname = fnamemodify(bufname(bufnumber), ':p') + if (!has_key(s:buffer_sources, bufnumber) + \ || s:check_changed_buffer(bufnumber)) + \ && !has_key(s:disable_caching_list, bufnumber) + \ && (!neocomplcache#is_locked(bufnumber) || + \ g:neocomplcache_disable_auto_complete) + \ && !getwinvar(bufwinnr(bufnumber), '&previewwindow') + \ && getfsize(bufname) < + \ g:neocomplcache_caching_limit_file_size + " Caching. + call s:word_caching(bufnumber) + endif + + if has_key(s:buffer_sources, bufnumber) + let source = s:buffer_sources[bufnumber] + call neocomplcache#cache#check_cache_list('buffer_cache', + \ source.path, s:async_dictionary_list, source.keyword_cache, 1) + endif + endfor +endfunction"}}} +function! s:check_cache() "{{{ + let release_accessd_time = + \ localtime() - g:neocomplcache_release_cache_time + + for [key, source] in items(s:buffer_sources) + " Check deleted buffer and access time. + if !bufloaded(str2nr(key)) + \ || (source.accessed_time > 0 && + \ source.accessed_time < release_accessd_time) + " Remove item. + call remove(s:buffer_sources, key) + endif + endfor +endfunction"}}} +function! s:check_recache() "{{{ + if !s:exists_current_source() + return + endif + + let release_accessd_time = + \ localtime() - g:neocomplcache_release_cache_time + + let source = s:buffer_sources[bufnr('%')] + + " Check buffer access time. + if (source.cached_time > 0 && source.cached_time < release_accessd_time) + \ || (neocomplcache#util#has_vimproc() && line('$') != source.end_line) + " Buffer recache. + if g:neocomplcache_enable_debug + echomsg 'Caching buffer: ' . bufname('%') + endif + + call neocomplcache#sources#buffer_complete#caching_current_block() + endif +endfunction"}}} + +function! s:exists_current_source() "{{{ + return has_key(s:buffer_sources, bufnr('%')) +endfunction"}}} + +" Command functions. "{{{ +function! neocomplcache#sources#buffer_complete#caching_buffer(name) "{{{ + if a:name == '' + let number = bufnr('%') + else + let number = bufnr(a:name) + + if number < 0 + let bufnr = bufnr('%') + + " No swap warning. + let save_shm = &shortmess + set shortmess+=A + + " Open new buffer. + execute 'silent! edit' fnameescape(a:name) + + let &shortmess = save_shm + + if bufnr('%') != bufnr + setlocal nobuflisted + execute 'buffer' bufnr + endif + endif + + let number = bufnr(a:name) + endif + + " Word recaching. + call s:word_caching(number) + call s:caching_current_buffer(1, line('$')) +endfunction"}}} +function! neocomplcache#sources#buffer_complete#print_source(name) "{{{ + if a:name == '' + let number = bufnr('%') + else + let number = bufnr(a:name) + + if number < 0 + call neocomplcache#print_error('Invalid buffer name.') + return + endif + endif + + if !has_key(s:buffer_sources, number) + return + endif + + silent put=printf('Print neocomplcache %d source.', number) + for key in keys(s:buffer_sources[number]) + silent put =printf('%s => %s', key, string(s:buffer_sources[number][key])) + endfor +endfunction"}}} +function! neocomplcache#sources#buffer_complete#output_keyword(name) "{{{ + if a:name == '' + let number = bufnr('%') + else + let number = bufnr(a:name) + + if number < 0 + call neocomplcache#print_error('Invalid buffer name.') + return + endif + endif + + if !has_key(s:buffer_sources, number) + return + endif + + " Output buffer. + for keyword in neocomplcache#unpack_dictionary( + \ s:buffer_sources[number].keyword_cache) + silent put=string(keyword) + endfor +endfunction "}}} +function! neocomplcache#sources#buffer_complete#disable_caching(name) "{{{ + if a:name == '' + let number = bufnr('%') + else + let number = bufnr(a:name) + + if number < 0 + call neocomplcache#print_error('Invalid buffer name.') + return + endif + endif + + let s:disable_caching_list[number] = 1 + + if has_key(s:buffer_sources, number) + " Delete source. + call remove(s:buffer_sources, number) + endif +endfunction"}}} +function! neocomplcache#sources#buffer_complete#enable_caching(name) "{{{ + if a:name == '' + let number = bufnr('%') + else + let number = bufnr(a:name) + + if number < 0 + call neocomplcache#print_error('Invalid buffer name.') + return + endif + endif + + if has_key(s:disable_caching_list, number) + call remove(s:disable_caching_list, number) + endif +endfunction"}}} +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/dictionary_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/dictionary_complete.vim new file mode 100644 index 0000000..bbc6782 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/dictionary_complete.vim @@ -0,0 +1,173 @@ +"============================================================================= +" FILE: dictionary_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" Important variables. +if !exists('s:dictionary_list') + let s:dictionary_list = {} + let s:async_dictionary_list = {} +endif + +function! neocomplcache#sources#dictionary_complete#define() "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'dictionary_complete', + \ 'kind' : 'keyword', + \ 'mark' : '[D]', + \ 'rank' : 4, + \} + +function! s:source.initialize() "{{{ + " 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 + "}}} + + " Initialize dictionary completion pattern. "{{{ + if !exists('g:neocomplcache_dictionary_patterns') + let g:neocomplcache_dictionary_patterns = {} + endif + "}}} + + " Set caching event. + autocmd neocomplcache FileType * call s:caching() + + " Create cache directory. + if !isdirectory(neocomplcache#get_temporary_directory() . '/dictionary_cache') + \ && !neocomplcache#util#is_sudo() + call mkdir(neocomplcache#get_temporary_directory() . '/dictionary_cache') + endif + + " Initialize check. + call s:caching() +endfunction"}}} + +function! s:source.finalize() "{{{ + delcommand NeoComplCacheCachingDictionary +endfunction"}}} + +function! s:source.get_keyword_list(complete_str) "{{{ + let list = [] + + let filetype = neocomplcache#is_text_mode() ? + \ 'text' : neocomplcache#get_context_filetype() + if !has_key(s:dictionary_list, filetype) + " Caching. + call s:caching() + endif + + for ft in neocomplcache#get_source_filetypes(filetype) + call neocomplcache#cache#check_cache('dictionary_cache', ft, + \ s:async_dictionary_list, s:dictionary_list, 1) + + for dict in neocomplcache#get_sources_list(s:dictionary_list, ft) + let list += neocomplcache#dictionary_filter(dict, a:complete_str) + endfor + endfor + + return list +endfunction"}}} + +function! s:caching() "{{{ + if !bufloaded(bufnr('%')) + return + endif + + let key = neocomplcache#is_text_mode() ? + \ 'text' : neocomplcache#get_context_filetype() + for filetype in neocomplcache#get_source_filetypes(key) + if !has_key(s:dictionary_list, filetype) + \ && !has_key(s:async_dictionary_list, filetype) + call neocomplcache#sources#dictionary_complete#recaching(filetype) + endif + endfor +endfunction"}}} + +function! s:caching_dictionary(filetype) + let filetype = a:filetype + if filetype == '' + let filetype = neocomplcache#get_context_filetype(1) + endif + + if has_key(s:async_dictionary_list, filetype) + \ && filereadable(s:async_dictionary_list[filetype].cache_name) + " Delete old cache. + call delete(s:async_dictionary_list[filetype].cache_name) + endif + + call neocomplcache#sources#dictionary_complete#recaching(filetype) +endfunction +function! neocomplcache#sources#dictionary_complete#recaching(filetype) "{{{ + if !exists('g:neocomplcache_dictionary_filetype_lists') + call neocomplcache#initialize() + endif + + let filetype = a:filetype + if filetype == '' + let filetype = neocomplcache#get_context_filetype(1) + endif + + " Caching. + let dictionaries = get( + \ g:neocomplcache_dictionary_filetype_lists, filetype, '') + + if dictionaries == '' + if filetype != &filetype && + \ &l:dictionary != '' && &l:dictionary !=# &g:dictionary + let dictionaries .= &l:dictionary + endif + endif + + let s:async_dictionary_list[filetype] = [] + + let pattern = get(g:neocomplcache_dictionary_patterns, filetype, + \ neocomplcache#get_keyword_pattern(filetype)) + for dictionary in split(dictionaries, ',') + let dictionary = neocomplcache#util#substitute_path_separator( + \ fnamemodify(dictionary, ':p')) + if filereadable(dictionary) + call neocomplcache#print_debug('Caching dictionary: ' . dictionary) + call add(s:async_dictionary_list[filetype], { + \ 'filename' : dictionary, + \ 'cachename' : neocomplcache#cache#async_load_from_file( + \ 'dictionary_cache', dictionary, pattern, 'D') + \ }) + endif + endfor +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_complete.vim new file mode 100644 index 0000000..98a265d --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_complete.vim @@ -0,0 +1,202 @@ +"============================================================================= +" FILE: filename_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 20 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +let s:source = { + \ 'name' : 'filename_complete', + \ 'kind' : 'manual', + \ 'mark' : '[F]', + \ 'rank' : 3, + \ 'min_pattern_length' : + \ g:neocomplcache_auto_completion_start_length, + \} + +function! s:source.initialize() "{{{ +endfunction"}}} +function! s:source.finalize() "{{{ +endfunction"}}} + +function! s:source.get_keyword_pos(cur_text) "{{{ + let filetype = neocomplcache#get_context_filetype() + if filetype ==# 'vimshell' || filetype ==# 'unite' || filetype ==# 'int-ssh' + return -1 + endif + + " Filename pattern. + let pattern = neocomplcache#get_keyword_pattern_end('filename') + let [complete_pos, complete_str] = + \ neocomplcache#match_word(a:cur_text, pattern) + if complete_str =~ '//' || + \ (neocomplcache#is_auto_complete() && + \ (complete_str !~ '/' || + \ complete_str =~# + \ '\\[^ ;*?[]"={}'']\|\.\.\+$\|/c\%[ygdrive/]$')) + " Not filename pattern. + return -1 + endif + + if neocomplcache#is_sources_complete() && complete_pos < 0 + let complete_pos = len(a:cur_text) + endif + + return complete_pos +endfunction"}}} + +function! s:source.get_complete_words(complete_pos, complete_str) "{{{ + return s:get_glob_files(a:complete_str, '') +endfunction"}}} + +let s:cached_files = {} + +function! s:get_glob_files(complete_str, path) "{{{ + let path = ',,' . substitute(a:path, '\.\%(,\|$\)\|,,', '', 'g') + + let complete_str = neocomplcache#util#substitute_path_separator( + \ substitute(a:complete_str, '\\\(.\)', '\1', 'g')) + + let glob = (complete_str !~ '\*$')? + \ complete_str . '*' : complete_str + + if a:path == '' && complete_str !~ '/' + if !has_key(s:cached_files, getcwd()) + call s:caching_current_files() + endif + + let files = copy(s:cached_files[getcwd()]) + else + let ftype = getftype(glob) + if ftype != '' && ftype !=# 'dir' + " Note: If glob() device files, Vim may freeze! + return [] + endif + + if a:path == '' + let files = neocomplcache#util#glob(glob) + else + try + let globs = globpath(path, glob) + catch + return [] + endtry + let files = split(substitute(globs, '\\', '/', 'g'), '\n') + endif + endif + + let files = neocomplcache#keyword_filter(map( + \ files, '{ + \ "word" : fnamemodify(v:val, ":t"), + \ "orig" : v:val, + \ }'), + \ fnamemodify(complete_str, ':t')) + + if neocomplcache#is_auto_complete() + \ && len(files) > g:neocomplcache_max_list + let files = files[: g:neocomplcache_max_list - 1] + endif + + let files = map(files, '{ + \ "word" : substitute(v:val.orig, "//", "/", "g"), + \ }') + + if a:complete_str =~ '^\$\h\w*' + let env = matchstr(a:complete_str, '^\$\h\w*') + let env_ev = eval(env) + if neocomplcache#is_windows() + let env_ev = substitute(env_ev, '\\', '/', 'g') + endif + let len_env = len(env_ev) + else + let len_env = 0 + endif + + let home_pattern = '^'. + \ neocomplcache#util#substitute_path_separator( + \ expand('~')).'/' + let exts = escape(substitute($PATHEXT, ';', '\\|', 'g'), '.') + + let dir_list = [] + let file_list = [] + for dict in files + call add(isdirectory(dict.word) ? + \ dir_list : file_list, dict) + + let dict.orig = dict.word + + if len_env != 0 && dict.word[: len_env-1] == env_ev + let dict.word = env . dict.word[len_env :] + endif + + let abbr = dict.word + if isdirectory(dict.word) && dict.word !~ '/$' + let abbr .= '/' + if g:neocomplcache_enable_auto_delimiter + let dict.word .= '/' + endif + elseif neocomplcache#is_windows() + if '.'.fnamemodify(dict.word, ':e') =~ exts + let abbr .= '*' + endif + elseif executable(dict.word) + let abbr .= '*' + endif + let dict.abbr = abbr + + if a:complete_str =~ '^\~/' + let dict.word = substitute(dict.word, home_pattern, '\~/', '') + let dict.abbr = substitute(dict.abbr, home_pattern, '\~/', '') + endif + + " Escape word. + let dict.word = escape(dict.word, ' ;*?[]"={}''') + endfor + + return dir_list + file_list +endfunction"}}} +function! s:caching_current_files() "{{{ + let s:cached_files[getcwd()] = neocomplcache#util#glob('*') + if !exists('vimproc#readdir') + let s:cached_files[getcwd()] += neocomplcache#util#glob('.*') + endif +endfunction"}}} + +function! neocomplcache#sources#filename_complete#define() "{{{ + return s:source +endfunction"}}} + +function! neocomplcache#sources#filename_complete#get_complete_words(complete_str, path) "{{{ + if !neocomplcache#is_enabled() + return [] + endif + + return s:get_glob_files(a:complete_str, a:path) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_include.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_include.vim new file mode 100644 index 0000000..1835c8b --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/filename_include.vim @@ -0,0 +1,238 @@ +"============================================================================= +" FILE: filename_include.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 29 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" 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 +"}}} + +let s:source = { + \ 'name' : 'filename_include', + \ 'kind' : 'manual', + \ 'mark' : '[FI]', + \ 'rank' : 10, + \ 'min_pattern_length' : + \ g:neocomplcache_auto_completion_start_length, + \} + +function! s:source.initialize() "{{{ + " Initialize. + + " Initialize filename include expr. "{{{ + let g:neocomplcache_filename_include_exprs = + \ get(g:, 'neocomplcache_filename_include_exprs', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exprs', + \ 'perl', + \ 'fnamemodify(substitute(v:fname, "/", "::", "g"), ":r")') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exprs', + \ 'ruby,python,java,d', + \ 'fnamemodify(substitute(v:fname, "/", ".", "g"), ":r")') + "}}} + + " Initialize filename include extensions. "{{{ + let g:neocomplcache_filename_include_exts = + \ get(g:, 'neocomplcache_filename_include_exts', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exts', + \ 'c', ['h']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exts', + \ 'cpp', ['', 'h', 'hpp', 'hxx']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exts', + \ 'perl', ['pm']) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_filename_include_exts', + \ 'java', ['java']) + "}}} +endfunction"}}} +function! s:source.finalize() "{{{ +endfunction"}}} + +function! s:source.get_keyword_pos(cur_text) "{{{ + let filetype = neocomplcache#get_context_filetype() + + " Not Filename pattern. + if exists('g:neocomplcache_include_patterns') + let pattern = get(g:neocomplcache_include_patterns, filetype, + \ &l:include) + else + let pattern = '' + endif + if neocomplcache#is_auto_complete() + \ && (pattern == '' || a:cur_text !~ pattern) + \ && a:cur_text =~ '\*$\|\.\.\+$\|/c\%[ygdrive/]$' + " Skip filename completion. + return -1 + endif + + " Check include pattern. + let pattern = get(g:neocomplcache_include_patterns, filetype, + \ &l:include) + if pattern == '' || a:cur_text !~ pattern + return -1 + endif + + let match_end = matchend(a:cur_text, pattern) + let complete_str = matchstr(a:cur_text[match_end :], '\f\+') + + let expr = get(g:neocomplcache_include_exprs, filetype, + \ &l:includeexpr) + if expr != '' + let cur_text = + \ substitute(eval(substitute(expr, + \ 'v:fname', string(complete_str), 'g')), + \ '\.\w*$', '', '') + endif + + let complete_pos = len(a:cur_text) - len(complete_str) + if neocomplcache#is_sources_complete() && complete_pos < 0 + let complete_pos = len(a:cur_text) + endif + + return complete_pos +endfunction"}}} + +function! s:source.get_complete_words(complete_pos, complete_str) "{{{ + return s:get_include_files(a:complete_str) +endfunction"}}} + +function! s:get_include_files(complete_str) "{{{ + let filetype = neocomplcache#get_context_filetype() + + let path = neocomplcache#util#substitute_path_separator( + \ get(g:neocomplcache_include_paths, filetype, + \ &l:path)) + let pattern = get(g:neocomplcache_include_patterns, filetype, + \ &l:include) + let expr = get(g:neocomplcache_include_exprs, filetype, + \ &l:includeexpr) + let reverse_expr = get(g:neocomplcache_filename_include_exprs, filetype, + \ '') + let exts = get(g:neocomplcache_filename_include_exts, filetype, + \ []) + + let line = neocomplcache#get_cur_text() + if line =~ '^\s*\' && &filetype =~# 'ruby' + " For require_relative. + let path = '.' + endif + + let match_end = matchend(line, pattern) + let complete_str = matchstr(line[match_end :], '\f\+') + if expr != '' + let complete_str = + \ substitute(eval(substitute(expr, + \ 'v:fname', string(complete_str), 'g')), '\.\w*$', '', '') + endif + + " Path search. + let glob = (complete_str !~ '\*$')? + \ complete_str . '*' : complete_str + let cwd = getcwd() + let bufdirectory = neocomplcache#util#substitute_path_separator( + \ fnamemodify(expand('%'), ':p:h')) + let dir_list = [] + let file_list = s:get_default_include_files(filetype) + for subpath in split(path, '[,;]') + let dir = (subpath == '.') ? bufdirectory : subpath + if !isdirectory(dir) + continue + endif + + execute 'lcd' fnameescape(dir) + + for word in split( + \ neocomplcache#util#substitute_path_separator( + \ glob(glob)), '\n') + let dict = { 'word' : word } + + call add(isdirectory(word) ? dir_list : file_list, dict) + + let abbr = dict.word + if isdirectory(word) + let abbr .= '/' + if g:neocomplcache_enable_auto_delimiter + let dict.word .= '/' + endif + elseif !empty(exts) && + \ index(exts, fnamemodify(dict.word, ':e')) < 0 + " Skip. + continue + endif + let dict.abbr = abbr + + if reverse_expr != '' + " Convert filename. + let dict.word = eval(substitute(reverse_expr, + \ 'v:fname', string(dict.word), 'g')) + let dict.abbr = eval(substitute(reverse_expr, + \ 'v:fname', string(dict.abbr), 'g')) + else + " Escape word. + let dict.word = escape(dict.word, ' ;*?[]"={}''') + endif + endfor + endfor + execute 'lcd' fnameescape(cwd) + + return neocomplcache#keyword_filter(dir_list, a:complete_str) + \ + neocomplcache#keyword_filter(file_list, a:complete_str) +endfunction"}}} + +function! s:get_default_include_files(filetype) "{{{ + let files = [] + + if a:filetype ==# 'python' || a:filetype ==# 'python3' + let files = ['sys'] + endif + + return map(files, "{ 'word' : v:val }") +endfunction"}}} + +function! neocomplcache#sources#filename_include#define() "{{{ + return s:source +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/include_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/include_complete.vim new file mode 100644 index 0000000..d847d8e --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/include_complete.vim @@ -0,0 +1,497 @@ +"============================================================================= +" FILE: include_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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:save_cpo = &cpo +set cpo&vim + +let s:source = { + \ 'name' : 'include_complete', + \ 'kind' : 'keyword', + \ 'rank' : 8, + \} + +function! s:source.initialize() "{{{ + call s:initialize_variables() + + if neocomplcache#has_vimproc() + augroup neocomplcache + " Caching events + autocmd BufWritePost * call s:check_buffer('', 0) + autocmd CursorHold * call s:check_cache() + augroup END + endif + + call neocomplcache#util#set_default( + \ 'g:neocomplcache_include_max_processes', 20) + + " Create cache directory. + if !isdirectory(neocomplcache#get_temporary_directory() . '/include_cache') + \ && !neocomplcache#util#is_sudo() + call mkdir(neocomplcache#get_temporary_directory() + \ . '/include_cache', 'p') + endif + + if neocomplcache#exists_echodoc() + call echodoc#register('include_complete', s:doc_dict) + endif +endfunction"}}} + +function! s:source.finalize() "{{{ + delcommand NeoComplCacheCachingInclude + + if neocomplcache#exists_echodoc() + call echodoc#unregister('include_complete') + endif +endfunction"}}} + +function! s:source.get_keyword_list(complete_str) "{{{ + if neocomplcache#within_comment() + return [] + endif + + if !has_key(s:include_info, bufnr('%')) + " Auto caching. + call s:check_buffer('', 0) + endif + + let keyword_list = [] + + " Check caching. + for include in s:include_info[bufnr('%')].include_files + call neocomplcache#cache#check_cache( + \ 'include_cache', include, s:async_include_cache, s:include_cache) + if has_key(s:include_cache, include) + let s:cache_accessed_time[include] = localtime() + let keyword_list += neocomplcache#dictionary_filter( + \ s:include_cache[include], a:complete_str) + endif + endfor + + return neocomplcache#keyword_filter( + \ neocomplcache#dup_filter(keyword_list), a:complete_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 copy(s:include_info[a:bufnumber].include_files) + else + return s:get_buffer_include_files(a:bufnumber) + endif +endfunction"}}} + +function! neocomplcache#sources#include_complete#get_include_tags(bufnumber) "{{{ + return filter(map( + \ neocomplcache#sources#include_complete#get_include_files(a:bufnumber), + \ "neocomplcache#cache#encode_name('tags_output', v:val)"), + \ 'filereadable(v:val)') +endfunction"}}} + +" For Debug. +function! neocomplcache#sources#include_complete#get_current_include_files() "{{{ + return s:get_buffer_include_files(bufnr('%')) +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 + + let completion_length = 2 + + " Collect words. + let words = [] + let i = 0 + while i >= 0 + let word = matchstr(a:cur_text, '\k\+', i) + if len(word) >= completion_length + call add(words, word) + endif + + let i = matchend(a:cur_text, '\k\+', i) + endwhile + + for word in reverse(words) + let key = tolower(word[: completion_length-1]) + + for include in filter(copy(s:include_info[bufnr('%')].include_files), + \ 'has_key(s:include_cache, v:val) && has_key(s:include_cache[v:val], key)') + for matched in filter(values(s:include_cache[include][key]), + \ 'v:val.word ==# word && has_key(v:val, "kind") && v:val.kind != ""') + let ret = [] + + let match = match(matched.abbr, neocomplcache#escape_match(word)) + if match > 0 + call add(ret, { 'text' : matched.abbr[ : match-1] }) + endif + + call add(ret, { 'text' : word, 'highlight' : 'Identifier' }) + call add(ret, { 'text' : matched.abbr[match+len(word) :] }) + + if match > 0 || len(ret[-1].text) > 0 + return ret + endif + endfor + endfor + endfor + + return [] +endfunction"}}} +"}}} + +function! s:check_buffer(bufnumber, is_force) "{{{ + if !neocomplcache#is_enabled_source('include_complete') + return + endif + + let bufnumber = (a:bufnumber == '') ? bufnr('%') : a:bufnumber + let filename = fnamemodify(bufname(bufnumber), ':p') + + if !has_key(s:include_info, bufnumber) + " Initialize. + let s:include_info[bufnumber] = { + \ 'include_files' : [], 'lines' : [], + \ 'async_files' : {}, + \ } + endif + + if !executable(g:neocomplcache_ctags_program) + \ || (!a:is_force && !neocomplcache#has_vimproc()) + return + endif + + let include_info = s:include_info[bufnumber] + + if a:is_force || include_info.lines !=# getbufline(bufnumber, 1, 100) + let include_info.lines = getbufline(bufnumber, 1, 100) + + " Check include files contained bufname. + let include_files = s:get_buffer_include_files(bufnumber) + + " Check include files from function. + let filetype = getbufvar(a:bufnumber, '&filetype') + let function = get(g:neocomplcache_include_functions, filetype, '') + if function != '' && getbufvar(bufnumber, '&buftype') !~ 'nofile' + let path = get(g:neocomplcache_include_paths, filetype, + \ getbufvar(a:bufnumber, '&path')) + let include_files += call(function, + \ [getbufline(bufnumber, 1, (a:is_force ? '$' : 1000)), path]) + endif + + if getbufvar(bufnumber, '&buftype') !~ 'nofile' + \ && filereadable(filename) + call add(include_files, filename) + endif + let include_info.include_files = neocomplcache#util#uniq(include_files) + endif + + if g:neocomplcache_include_max_processes <= 0 + return + endif + + let filetype = getbufvar(bufnumber, '&filetype') + if filetype == '' + let filetype = 'nothing' + endif + + for filename in include_info.include_files + if (a:is_force || !has_key(include_info.async_files, filename)) + \ && !has_key(s:include_cache, filename) + if !a:is_force && has_key(s:async_include_cache, filename) + \ && len(s:async_include_cache[filename]) + \ >= g:neocomplcache_include_max_processes + break + endif + + " Caching. + let s:async_include_cache[filename] + \ = [ s:initialize_include(filename, filetype) ] + let include_info.async_files[filename] = 1 + endif + endfor +endfunction"}}} +function! s:get_buffer_include_files(bufnumber) "{{{ + let filetype = getbufvar(a:bufnumber, '&filetype') + if filetype == '' + return [] + endif + + if (filetype ==# 'python' || filetype ==# 'python3') + \ && (executable('python') || executable('python3')) + " Initialize python path pattern. + + let path = '' + if executable('python3') + let path .= ',' . neocomplcache#system('python3 -', + \ 'import sys;sys.stdout.write(",".join(sys.path))') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_paths', 'python3', path) + endif + if executable('python') + let path .= ',' . neocomplcache#system('python -', + \ 'import sys;sys.stdout.write(",".join(sys.path))') + endif + let path = join(neocomplcache#util#uniq(filter( + \ split(path, ',', 1), "v:val != ''")), ',') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_paths', 'python', path) + elseif filetype ==# 'cpp' && isdirectory('/usr/include/c++') + " Add cpp path. + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_paths', 'cpp', + \ getbufvar(a:bufnumber, '&path') . + \ ','.join(split(glob('/usr/include/c++/*'), '\n'), ',')) + endif + + let pattern = get(g:neocomplcache_include_patterns, filetype, + \ getbufvar(a:bufnumber, '&include')) + if pattern == '' + return [] + endif + let path = get(g:neocomplcache_include_paths, filetype, + \ getbufvar(a:bufnumber, '&path')) + let expr = get(g:neocomplcache_include_exprs, filetype, + \ getbufvar(a:bufnumber, '&includeexpr')) + if has_key(g:neocomplcache_include_suffixes, filetype) + let suffixes = &l:suffixesadd + endif + + " Change current directory. + let cwd_save = getcwd() + let buffer_dir = fnamemodify(bufname(a:bufnumber), ':p:h') + if isdirectory(buffer_dir) + execute 'lcd' fnameescape(buffer_dir) + endif + + let include_files = s:get_include_files(0, + \ getbufline(a:bufnumber, 1, 100), filetype, pattern, path, expr) + + if isdirectory(buffer_dir) + execute 'lcd' fnameescape(cwd_save) + endif + + " Restore option. + if has_key(g:neocomplcache_include_suffixes, filetype) + let &l:suffixesadd = suffixes + endif + + return include_files +endfunction"}}} +function! s:get_include_files(nestlevel, lines, filetype, pattern, path, expr) "{{{ + let include_files = [] + for line in a:lines "{{{ + if line =~ a:pattern + let match_end = matchend(line, a:pattern) + if a:expr != '' + let eval = substitute(a:expr, 'v:fname', + \ string(matchstr(line[match_end :], '\f\+')), 'g') + let filename = fnamemodify(findfile(eval(eval), a:path), ':p') + else + let filename = fnamemodify(findfile( + \ matchstr(line[match_end :], '\f\+'), a:path), ':p') + endif + + if filereadable(filename) + call add(include_files, filename) + + if (a:filetype == 'c' || a:filetype == 'cpp') && a:nestlevel < 1 + let include_files += s:get_include_files( + \ a:nestlevel + 1, readfile(filename)[:100], + \ a:filetype, a:pattern, a:path, a:expr) + endif + elseif isdirectory(filename) && a:filetype ==# 'java' + " For Java import with *. + " Ex: import lejos.nxt.* + let include_files += + \ neocomplcache#util#glob(filename . '/*.java') + endif + endif + endfor"}}} + + return include_files +endfunction"}}} + +function! s:check_cache() "{{{ + if neocomplcache#is_disabled_source('include_complete') + return + endif + + let release_accessd_time = localtime() - g:neocomplcache_release_cache_time + + for key in keys(s:include_cache) + if has_key(s:cache_accessed_time, key) + \ && s:cache_accessed_time[key] < release_accessd_time + call remove(s:include_cache, key) + endif + endfor +endfunction"}}} + +function! s:initialize_include(filename, filetype) "{{{ + " Initialize include list from tags. + return { + \ 'filename' : a:filename, + \ 'cachename' : neocomplcache#cache#async_load_from_tags( + \ 'include_cache', a:filename, a:filetype, 'I', 1) + \ } +endfunction"}}} +function! neocomplcache#sources#include_complete#caching_include(bufname) "{{{ + let bufnumber = (a:bufname == '') ? bufnr('%') : bufnr(a:bufname) + if has_key(s:async_include_cache, bufnumber) + \ && filereadable(s:async_include_cache[bufnumber].cache_name) + " Delete old cache. + call delete(s:async_include_cache[bufnumber].cache_name) + endif + + " Initialize. + if has_key(s:include_info, bufnumber) + call remove(s:include_info, bufnumber) + endif + + call s:check_buffer(bufnumber, 1) +endfunction"}}} + +" Analyze include files functions. +function! neocomplcache#sources#include_complete#analyze_vim_include_files(lines, path) "{{{ + let include_files = [] + let dup_check = {} + for line in a:lines + if line =~ '\<\h\w*#' && line !~ '\' + let filename = 'autoload/' . substitute(matchstr(line, '\<\%(\h\w*#\)*\h\w*\ze#'), + \ '#', '/', 'g') . '.vim' + if filename == '' || has_key(dup_check, filename) + continue + endif + let dup_check[filename] = 1 + + let filename = fnamemodify(findfile(filename, &runtimepath), ':p') + if filereadable(filename) + call add(include_files, filename) + endif + endif + endfor + + return include_files +endfunction"}}} +function! neocomplcache#sources#include_complete#analyze_ruby_include_files(lines, path) "{{{ + let include_files = [] + let dup_check = {} + for line in a:lines + if line =~ '\' + let args = split(line, ',') + if len(args) < 2 + continue + endif + let filename = substitute(matchstr(args[1], '["'']\zs\f\+\ze["'']'), + \ '\.', '/', 'g') . '.rb' + if filename == '' || has_key(dup_check, filename) + continue + endif + let dup_check[filename] = 1 + + let filename = fnamemodify(findfile(filename, a:path), ':p') + if filereadable(filename) + call add(include_files, filename) + endif + endif + endfor + + return include_files +endfunction"}}} + +function! s:initialize_variables() "{{{ + let s:include_info = {} + let s:include_cache = {} + let s:cache_accessed_time = {} + let s:async_include_cache = {} + let s:cached_pattern = {} + + " Initialize include pattern. "{{{ + let g:neocomplcache_include_patterns = + \ get(g:, 'neocomplcache_include_patterns', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_patterns', + \ 'java,haskell', '^\s*\') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_patterns', + \ 'c,cpp', '^\s*#\s*include') + "}}} + " Initialize expr pattern. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_include_exprs', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_exprs', + \ 'haskell,cs', + \ "substitute(v:fname, '\\.', '/', 'g')") + "}}} + " Initialize path pattern. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_include_paths', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_paths', 'c,cpp', + \ &path) + "}}} + " Initialize include suffixes. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_include_suffixes', {}) + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_suffixes', + \ 'haskell', '.hs') + "}}} + " Initialize include functions. "{{{ + call neocomplcache#util#set_default( + \ 'g:neocomplcache_include_functions', {}) + " call neocomplcache#util#set_default_dictionary( + " \ 'g:neocomplcache_include_functions', 'vim', + " \ 'neocomplcache#sources#include_complete#analyze_vim_include_files') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_include_functions', 'ruby', + \ 'neocomplcache#sources#include_complete#analyze_ruby_include_files') + "}}} +endfunction"}}} + +if !exists('s:include_info') + call s:initialize_variables() +endif + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/member_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/member_complete.vim new file mode 100644 index 0000000..8292b71 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/member_complete.vim @@ -0,0 +1,247 @@ +"============================================================================= +" FILE: member_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 01 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" Important variables. +if !exists('s:member_sources') + let s:member_sources = {} +endif + +let s:source = { + \ 'name' : 'member_complete', + \ 'kind' : 'manual', + \ 'mark' : '[M]', + \ 'rank' : 5, + \ 'min_pattern_length' : 0, + \} + +function! s:source.initialize() "{{{ + augroup neocomplcache "{{{ + " Caching events + autocmd CursorHold * call s:caching_current_buffer(line('.')-10, line('.')+10) + autocmd InsertEnter,InsertLeave * + \ call neocomplcache#sources#member_complete#caching_current_line() + augroup END"}}} + + " Initialize member prefix patterns. "{{{ + if !exists('g:neocomplcache_member_prefix_patterns') + let g:neocomplcache_member_prefix_patterns = {} + endif + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_member_prefix_patterns', + \ 'c,cpp,objc,objcpp', '\.\|->') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_member_prefix_patterns', + \ 'perl,php', '->') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_member_prefix_patterns', + \ 'cs,java,javascript,d,vim,ruby,python,perl6,scala,vb', '\.') + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_member_prefix_patterns', + \ 'lua', '\.\|:') + "}}} + + " Initialize member patterns. "{{{ + if !exists('g:neocomplcache_member_patterns') + let g:neocomplcache_member_patterns = {} + endif + call neocomplcache#util#set_default_dictionary( + \ 'g:neocomplcache_member_patterns', + \'default', '\h\w*\%(()\|\[\h\w*\]\)\?') + "}}} + + " Initialize script variables. "{{{ + let s:member_sources = {} + "}}} +endfunction +"}}} + +function! s:source.get_keyword_pos(cur_text) "{{{ + " Check member prefix pattern. + let filetype = neocomplcache#get_context_filetype() + if !has_key(g:neocomplcache_member_prefix_patterns, filetype) + \ || g:neocomplcache_member_prefix_patterns[filetype] == '' + return -1 + endif + + let member = s:get_member_pattern(filetype) + let prefix = g:neocomplcache_member_prefix_patterns[filetype] + let complete_pos = matchend(a:cur_text, + \ '\%(' . member . '\%(' . prefix . '\m\)\)\+\ze\w*$') + return complete_pos +endfunction"}}} + +function! s:source.get_complete_words(complete_pos, complete_str) "{{{ + " Check member prefix pattern. + let filetype = neocomplcache#get_context_filetype() + if !has_key(g:neocomplcache_member_prefix_patterns, filetype) + \ || g:neocomplcache_member_prefix_patterns[filetype] == '' + return [] + endif + + let cur_text = neocomplcache#get_cur_text() + let var_name = matchstr(cur_text, + \ '\%(' . s:get_member_pattern(filetype) . '\%(' . + \ g:neocomplcache_member_prefix_patterns[filetype] . '\m\)\)\+\ze\w*$') + if var_name == '' + return [] + endif + + return neocomplcache#keyword_filter( + \ copy(s:get_member_list(cur_text, var_name)), a:complete_str) +endfunction"}}} + +function! neocomplcache#sources#member_complete#define() "{{{ + return s:source +endfunction"}}} + +function! neocomplcache#sources#member_complete#caching_current_line() "{{{ + " Current line caching. + return s:caching_current_buffer(line('.')-1, line('.')+1) +endfunction"}}} +function! neocomplcache#sources#member_complete#caching_current_buffer() "{{{ + " Current line caching. + return s:caching_current_buffer(1, line('$')) +endfunction"}}} +function! s:caching_current_buffer(start, end) "{{{ + " Current line caching. + + if !has_key(s:member_sources, bufnr('%')) + call s:initialize_source(bufnr('%')) + endif + + let filetype = neocomplcache#get_context_filetype(1) + if !has_key(g:neocomplcache_member_prefix_patterns, filetype) + \ || g:neocomplcache_member_prefix_patterns[filetype] == '' + return + endif + + let source = s:member_sources[bufnr('%')] + let keyword_pattern = + \ '\%(' . s:get_member_pattern(filetype) . '\%(' + \ . g:neocomplcache_member_prefix_patterns[filetype] + \ . '\m\)\)\+' . s:get_member_pattern(filetype) + let keyword_pattern2 = '^'.keyword_pattern + let member_pattern = s:get_member_pattern(filetype) . '$' + + " Cache member pattern. + let [line_num, max_lines] = [a:start, a:end] + for line in getline(a:start, a:end) + let match = match(line, keyword_pattern) + + while match >= 0 "{{{ + let match_str = matchstr(line, keyword_pattern2, match) + + " Next match. + let match = matchend(line, keyword_pattern, match + len(match_str)) + + while match_str != '' + let member_name = matchstr(match_str, member_pattern) + if member_name == '' + break + endif + let var_name = match_str[ : -len(member_name)-1] + + if !has_key(source.member_cache, var_name) + let source.member_cache[var_name] = {} + endif + if !has_key(source.member_cache[var_name], member_name) + let source.member_cache[var_name][member_name] = member_name + endif + + let match_str = matchstr(var_name, keyword_pattern2) + endwhile + endwhile"}}} + endfor +endfunction"}}} + +function! s:get_member_list(cur_text, var_name) "{{{ + let keyword_list = [] + for [key, source] in filter(s:get_sources_list(), + \ 'has_key(v:val[1].member_cache, a:var_name)') + let keyword_list += + \ values(source.member_cache[a:var_name]) + endfor + + return keyword_list +endfunction"}}} + +function! s:get_sources_list() "{{{ + let sources_list = [] + + let filetypes_dict = {} + for filetype in neocomplcache#get_source_filetypes( + \ neocomplcache#get_context_filetype()) + let filetypes_dict[filetype] = 1 + endfor + + for [key, source] in items(s:member_sources) + if has_key(filetypes_dict, source.filetype) + \ || has_key(filetypes_dict, '_') + \ || bufnr('%') == key + \ || (bufname('%') ==# '[Command Line]' && bufnr('#') == key) + call add(sources_list, [key, source]) + endif + endfor + + return sources_list +endfunction"}}} + +function! s:initialize_source(srcname) "{{{ + let path = fnamemodify(bufname(a:srcname), ':p') + let filename = fnamemodify(path, ':t') + if filename == '' + let filename = '[No Name]' + let path .= '/[No Name]' + endif + + " Set cache line count. + let buflines = getbufline(a:srcname, 1, '$') + let end_line = len(buflines) + + let ft = getbufvar(a:srcname, '&filetype') + if ft == '' + let ft = 'nothing' + endif + + let s:member_sources[a:srcname] = { + \ 'member_cache' : {}, 'filetype' : ft, + \ 'keyword_pattern' : neocomplcache#get_keyword_pattern(ft), + \} +endfunction"}}} + +function! s:get_member_pattern(filetype) "{{{ + return has_key(g:neocomplcache_member_patterns, a:filetype) ? + \ g:neocomplcache_member_patterns[a:filetype] : + \ g:neocomplcache_member_patterns['default'] +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/omni_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/omni_complete.vim new file mode 100644 index 0000000..fe864bd --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/omni_complete.vim @@ -0,0 +1,303 @@ +"============================================================================= +" FILE: omni_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 29 May 2013. +" 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:save_cpo = &cpo +set cpo&vim + +let s:source = { + \ 'name' : 'omni_complete', + \ 'kind' : 'manual', + \ 'compare_func' : 'neocomplcache#compare_nothing', + \ 'mark' : '[O]', + \ 'rank' : 50, + \} + +let s:List = vital#of('neocomplcache').import('Data.List') + +function! s:source.initialize() "{{{ + " Initialize omni completion pattern. "{{{ + if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} + endif + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'html,xhtml,xml,markdown', + \'<[^>]*') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'css,scss,sass', + \'^\s\+\w\+\|\w\+[):;]\?\s\+\w*\|[@!]') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'javascript', + \'[^. \t]\.\%(\h\w*\)\?') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'actionscript', + \'[^. \t][.:]\h\w*') + "call neocomplcache#util#set_default_dictionary( + "\'g:neocomplcache_omni_patterns', + "\'php', + "\'[^. \t]->\h\w*\|\h\w*::') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'java', + \'\%(\h\w*\|)\)\.') + "call neocomplcache#util#set_default_dictionary( + "\'g:neocomplcache_omni_patterns', + "\'perl', + "\'\h\w*->\h\w*\|\h\w*::') + "call neocomplcache#util#set_default_dictionary( + "\'g:neocomplcache_omni_patterns', + "\'c', + "\'[^.[:digit:] *\t]\%(\.\|->\)' + "call neocomplcache#util#set_default_dictionary( + "\'g:neocomplcache_omni_patterns', + "\'cpp', + "\'[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'objc', + \'[^.[:digit:] *\t]\%(\.\|->\)') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'objj', + \'[\[ \.]\w\+$\|:\w*$') + + " External language interface check. + if has('ruby') + " call neocomplcache#util#set_default_dictionary( + "\'g:neocomplcache_omni_patterns', 'ruby', + "\'[^. *\t]\.\h\w*\|\h\w*::') + endif + if has('python/dyn') || has('python3/dyn') + \ || has('python') || has('python3') + call neocomplcache#util#set_default_dictionary( + \'g:neocomplcache_omni_patterns', + \'python', '[^. \t]\.\w*') + endif + "}}} +endfunction"}}} +function! s:source.finalize() "{{{ +endfunction"}}} + +function! s:source.get_keyword_pos(cur_text) "{{{ + let syn_name = neocomplcache#helper#get_syn_name(1) + if syn_name ==# 'Comment' || syn_name ==# 'String' + " Skip omni_complete in string literal. + return -1 + endif + + let filetype = neocomplcache#get_context_filetype() + let s:complete_results = s:set_complete_results_pos( + \ s:get_omni_funcs(filetype), a:cur_text) + + return s:get_complete_pos(s:complete_results) +endfunction"}}} + +function! s:source.get_complete_words(complete_pos, complete_str) "{{{ + return s:get_candidates( + \ s:set_complete_results_words(s:complete_results), + \ a:complete_pos, a:complete_str) +endfunction"}}} + +function! neocomplcache#sources#omni_complete#define() "{{{ + return s:source +endfunction"}}} + +function! s:get_omni_funcs(filetype) "{{{ + let funcs = [] + for ft in insert(split(a:filetype, '\.'), '_') + if has_key(g:neocomplcache_omni_functions, ft) + let omnifuncs = + \ (type(g:neocomplcache_omni_functions[ft]) == type([])) ? + \ g:neocomplcache_omni_functions[ft] : + \ [g:neocomplcache_omni_functions[ft]] + else + let omnifuncs = [&l:omnifunc] + endif + + for omnifunc in omnifuncs + if neocomplcache#check_invalid_omnifunc(omnifunc) + " omnifunc is irregal. + continue + endif + + if get(g:neocomplcache_omni_patterns, omnifunc, '') != '' + let pattern = g:neocomplcache_omni_patterns[omnifunc] + elseif get(g:neocomplcache_omni_patterns, ft, '') != '' + let pattern = g:neocomplcache_omni_patterns[ft] + else + let pattern = '' + endif + + if pattern == '' + continue + endif + + call add(funcs, [omnifunc, pattern]) + endfor + endfor + + return s:List.uniq(funcs) +endfunction"}}} +function! s:get_omni_list(list) "{{{ + let omni_list = [] + + " Convert string list. + for val in deepcopy(a:list) + let dict = (type(val) == type('') ? + \ { 'word' : val } : val) + let dict.menu = '[O]' . get(dict, 'menu', '') + call add(omni_list, dict) + + unlet val + endfor + + return omni_list +endfunction"}}} + +function! s:set_complete_results_pos(funcs, cur_text) "{{{ + " Try omnifunc completion. "{{{ + let complete_results = {} + for [omnifunc, pattern] in a:funcs + if neocomplcache#is_auto_complete() + \ && a:cur_text !~ '\%(' . pattern . '\m\)$' + continue + endif + + " Save pos. + let pos = getpos('.') + + try + let complete_pos = call(omnifunc, [1, '']) + catch + call neocomplcache#print_error( + \ 'Error occurred calling omnifunction: ' . omnifunc) + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + let complete_pos = -1 + finally + if getpos('.') != pos + call setpos('.', pos) + endif + endtry + + if complete_pos < 0 + continue + endif + + let complete_str = a:cur_text[complete_pos :] + + let complete_results[omnifunc] = { + \ 'candidates' : [], + \ 'complete_pos' : complete_pos, + \ 'complete_str' : complete_str, + \ 'omnifunc' : omnifunc, + \} + endfor + "}}} + + return complete_results +endfunction"}}} +function! s:set_complete_results_words(complete_results) "{{{ + " Try source completion. + for [omnifunc, result] in items(a:complete_results) + if neocomplcache#complete_check() + return a:complete_results + endif + + let pos = getpos('.') + + " Note: For rubycomplete problem. + let complete_str = + \ (omnifunc == 'rubycomplete#Complete') ? + \ '' : result.complete_str + + try + let list = call(omnifunc, [0, complete_str]) + catch + call neocomplcache#print_error( + \ 'Error occurred calling omnifunction: ' . omnifunc) + call neocomplcache#print_error(v:throwpoint) + call neocomplcache#print_error(v:exception) + let list = [] + finally + if getpos('.') != pos + call setpos('.', pos) + endif + endtry + + if type(list) != type([]) + " Error. + return a:complete_results + endif + + let list = s:get_omni_list(list) + + let result.candidates = list + endfor + + return a:complete_results +endfunction"}}} +function! s:get_complete_pos(complete_results) "{{{ + if empty(a:complete_results) + return -1 + endif + + let complete_pos = col('.') + for result in values(a:complete_results) + if complete_pos > result.complete_pos + let complete_pos = result.complete_pos + endif + endfor + + return complete_pos +endfunction"}}} +function! s:get_candidates(complete_results, complete_pos, complete_str) "{{{ + " Append prefix. + let candidates = [] + let len_words = 0 + for [source_name, result] in items(a:complete_results) + if result.complete_pos > a:complete_pos + let prefix = a:complete_str[: result.complete_pos + \ - a:complete_pos - 1] + + for keyword in result.candidates + let keyword.word = prefix . keyword.word + endfor + endif + + let candidates += result.candidates + endfor + + return candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/syntax_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/syntax_complete.vim new file mode 100644 index 0000000..d03c233 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/syntax_complete.vim @@ -0,0 +1,323 @@ +"============================================================================= +" FILE: syntax_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" Important variables. +if !exists('s:syntax_list') + let s:syntax_list = {} +endif + +let s:source = { + \ 'name' : 'syntax_complete', + \ 'kind' : 'keyword', + \ 'mark' : '[S]', + \ 'rank' : 4, + \} + +function! s:source.initialize() "{{{ + " Set caching event. + autocmd neocomplcache Syntax * call s:caching() + + " Create cache directory. + if !isdirectory(neocomplcache#get_temporary_directory() . '/syntax_cache') + \ && !neocomplcache#util#is_sudo() + call mkdir(neocomplcache#get_temporary_directory() . '/syntax_cache') + endif + + " Initialize check. + call s:caching() +endfunction"}}} + +function! s:source.finalize() "{{{ + delcommand NeoComplCacheCachingSyntax +endfunction"}}} + +function! s:source.get_keyword_list(complete_str) "{{{ + let list = [] + + let filetype = neocomplcache#get_context_filetype() + if !has_key(s:syntax_list, filetype) + call s:caching() + endif + + for syntax in neocomplcache#get_sources_list( + \ s:syntax_list, filetype) + let list += neocomplcache#dictionary_filter(syntax, a:complete_str) + endfor + + return list +endfunction"}}} + +function! neocomplcache#sources#syntax_complete#define() "{{{ + return s:source +endfunction"}}} + +function! s:caching() "{{{ + if &filetype == '' || &filetype ==# 'vim' + return + endif + + for filetype in neocomplcache#get_source_filetypes(&filetype) + if !has_key(s:syntax_list, filetype) + " Check old cache. + let cache_name = neocomplcache#cache#encode_name('syntax_cache', &filetype) + let syntax_files = split( + \ globpath(&runtimepath, 'syntax/'.&filetype.'.vim'), '\n') + if getftime(cache_name) < 0 || (!empty(syntax_files) + \ && getftime(cache_name) <= getftime(syntax_files[0])) + if filetype ==# &filetype + " Caching from syn list. + let s:syntax_list[filetype] = s:caching_from_syn(filetype) + endif + else + let s:syntax_list[filetype] = neocomplcache#cache#index_load_from_cache( + \ 'syntax_cache', filetype, 1) + endif + endif + endfor +endfunction"}}} + +function! neocomplcache#sources#syntax_complete#recaching(filetype) "{{{ + if a:filetype == '' + let filetype = &filetype + else + let filetype = a:filetype + endif + + " Caching. + let s:syntax_list[filetype] = s:caching_from_syn(filetype) +endfunction"}}} + +function! s:caching_from_syn(filetype) "{{{ + call neocomplcache#print_caching( + \ 'Caching syntax "' . a:filetype . '"... please wait.') + + " Get current syntax list. + redir => syntax_list + silent! syntax list + redir END + + if syntax_list =~ '^E\d\+' || syntax_list =~ '^No Syntax items' + return [] + endif + + let group_name = '' + let keyword_pattern = neocomplcache#get_keyword_pattern(a:filetype) + + let dup_check = {} + + let filetype_pattern = tolower(a:filetype) + + let keyword_lists = {} + for line in split(syntax_list, '\n') + if line =~ '^\h\w\+' + " Change syntax group name. + let group_name = matchstr(line, '^\S\+') + let line = substitute(line, '^\S\+\s*xxx', '', '') + endif + + if line =~ 'Syntax items' || line =~ '^\s*links to' || + \ line =~ '^\s*nextgroup=' || + \ strridx(tolower(group_name), filetype_pattern) != 0 + " Next line. + continue + endif + + let line = substitute(line, 'contained\|skipwhite\|skipnl\|oneline', '', 'g') + let line = substitute(line, '^\s*nextgroup=.*\ze\s', '', '') + + if line =~ '^\s*match' + let line = s:substitute_candidate(matchstr(line, '/\zs[^/]\+\ze/')) + elseif line =~ '^\s*start=' + let line = + \s:substitute_candidate(matchstr(line, 'start=/\zs[^/]\+\ze/')) . ' ' . + \s:substitute_candidate(matchstr(line, 'end=/zs[^/]\+\ze/')) + endif + + " Add keywords. + let match_num = 0 + let completion_length = 2 + let match_str = matchstr(line, keyword_pattern, match_num) + while match_str != '' + " Ignore too short keyword. + if len(match_str) >= g:neocomplcache_min_syntax_length + \ && !has_key(dup_check, match_str) + \&& match_str =~ '^[[:print:]]\+$' + let key = tolower(match_str[: completion_length-1]) + if !has_key(keyword_lists, key) + let keyword_lists[key] = [] + endif + call add(keyword_lists[key], match_str) + + let dup_check[match_str] = 1 + endif + + let match_num += len(match_str) + + let match_str = matchstr(line, keyword_pattern, match_num) + endwhile + endfor + + " Save syntax cache. + let unpack_lists = neocomplcache#unpack_dictionary(keyword_lists) + if !empty(unpack_lists) + call neocomplcache#cache#save_cache('syntax_cache', &filetype, unpack_lists) + endif + + call neocomplcache#print_caching('') + + return keyword_lists +endfunction"}}} + +function! s:substitute_candidate(candidate) "{{{ + let candidate = a:candidate + + " Collection. + let candidate = substitute(candidate, + \'\\\@{}]\|[$^]\|\\z\?\a\)', ' ', 'g') + + if candidate =~ '\\%\?(' + let candidate = join(s:split_pattern(candidate)) + endif + + " \ + let candidate = substitute(candidate, '\\\\', '\\', 'g') + " * + let candidate = substitute(candidate, '\\\*', '*', 'g') + return candidate +endfunction"}}} + +function! s:split_pattern(keyword_pattern) "{{{ + let original_pattern = a:keyword_pattern + let result_patterns = [] + let analyzing_patterns = [ '' ] + + let i = 0 + let max = len(original_pattern) + while i < max + if match(original_pattern, '^\\%\?(', i) >= 0 + " Grouping. + let end = s:match_pair(original_pattern, '\\%\?(', '\\)', i) + if end < 0 + "call neocomplcache#print_error('Unmatched (.') + return [ a:keyword_pattern ] + endif + + let save_pattern = analyzing_patterns + let analyzing_patterns = [] + for keyword in split(original_pattern[matchend(original_pattern, '^\\%\?(', i) : end], '\\|') + for prefix in save_pattern + call add(analyzing_patterns, prefix . keyword) + endfor + endfor + + let i = end + 1 + elseif match(original_pattern, '^\\|', i) >= 0 + " Select. + let result_patterns += analyzing_patterns + let analyzing_patterns = [ '' ] + let original_pattern = original_pattern[i+2 :] + let max = len(original_pattern) + + let i = 0 + elseif original_pattern[i] == '\' && i+1 < max + let save_pattern = analyzing_patterns + let analyzing_patterns = [] + for prefix in save_pattern + call add(analyzing_patterns, prefix . original_pattern[i] . original_pattern[i+1]) + endfor + + " Escape. + let i += 2 + else + let save_pattern = analyzing_patterns + let analyzing_patterns = [] + for prefix in save_pattern + call add(analyzing_patterns, prefix . original_pattern[i]) + endfor + + let i += 1 + endif + endwhile + + let result_patterns += analyzing_patterns + return result_patterns +endfunction"}}} + +function! s:match_pair(string, start_pattern, end_pattern, start_cnt) "{{{ + let end = -1 + let start_pattern = '\%(' . a:start_pattern . '\)' + let end_pattern = '\%(' . a:end_pattern . '\)' + + let i = a:start_cnt + let max = len(a:string) + let nest_level = 0 + while i < max + let start = match(a:string, start_pattern, i) + let end = match(a:string, end_pattern, i) + + if start >= 0 && (end < 0 || start < end) + let i = matchend(a:string, start_pattern, i) + let nest_level += 1 + elseif end >= 0 && (start < 0 || end < start) + let nest_level -= 1 + + if nest_level == 0 + return end + endif + + let i = matchend(a:string, end_pattern, i) + else + break + endif + endwhile + + if nest_level != 0 + return -1 + else + return end + endif +endfunction"}}} + +" Global options definition. "{{{ +if !exists('g:neocomplcache_min_syntax_length') + let g:neocomplcache_min_syntax_length = 4 +endif +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/tags_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/tags_complete.vim new file mode 100644 index 0000000..6b6b8b5 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/tags_complete.vim @@ -0,0 +1,114 @@ +"============================================================================= +" FILE: tags_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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:save_cpo = &cpo +set cpo&vim + +" Important variables. +if !exists('s:tags_list') + let s:tags_list = {} + let s:async_tags_list = {} +endif + +let s:source = { + \ 'name' : 'tags_complete', + \ 'kind' : 'keyword', + \} + +function! s:source.initialize() "{{{ + let g:neocomplcache_tags_caching_limit_file_size = + \ get(g:, 'neocomplcache_tags_caching_limit_file_size', 500000) + + " Create cache directory. + if !isdirectory(neocomplcache#get_temporary_directory() . '/tags_cache') + \ && !neocomplcache#util#is_sudo() + call mkdir(neocomplcache#get_temporary_directory() . '/tags_cache', 'p') + endif +endfunction"}}} + +function! s:source.finalize() "{{{ + delcommand NeoComplCacheCachingTags +endfunction"}}} + +function! neocomplcache#sources#tags_complete#define() "{{{ + return s:source +endfunction"}}} + +function! s:source.get_keyword_list(complete_str) "{{{ + if !has_key(s:async_tags_list, bufnr('%')) + \ && !has_key(s:tags_list, bufnr('%')) + call neocomplcache#sources#tags_complete#caching_tags(0) + endif + + if neocomplcache#within_comment() + return [] + endif + + call neocomplcache#cache#check_cache( + \ 'tags_cache', bufnr('%'), s:async_tags_list, s:tags_list) + + if !has_key(s:tags_list, bufnr('%')) + return [] + endif + let keyword_list = neocomplcache#dictionary_filter( + \ s:tags_list[bufnr('%')], a:complete_str) + + return neocomplcache#keyword_filter(keyword_list, a:complete_str) +endfunction"}}} + +function! s:initialize_tags(filename) "{{{ + " Initialize tags list. + let ft = &filetype + if ft == '' + let ft = 'nothing' + endif + + return { + \ 'filename' : a:filename, + \ 'cachename' : neocomplcache#cache#async_load_from_tags( + \ 'tags_cache', a:filename, ft, 'T', 0) + \ } +endfunction"}}} +function! neocomplcache#sources#tags_complete#caching_tags(force) "{{{ + let bufnumber = bufnr('%') + + let s:async_tags_list[bufnumber] = [] + for tags in map(filter(tagfiles(), 'getfsize(v:val) > 0'), + \ "neocomplcache#util#substitute_path_separator( + \ fnamemodify(v:val, ':p'))") + if tags !~? '/doc/tags\%(-\w\+\)\?$' && + \ (a:force || getfsize(tags) + \ < g:neocomplcache_tags_caching_limit_file_size) + call add(s:async_tags_list[bufnumber], + \ s:initialize_tags(tags)) + endif + endfor +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete.vim new file mode 100644 index 0000000..252b5fe --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete.vim @@ -0,0 +1,198 @@ +"============================================================================= +" FILE: vim_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Jun 2013. +" 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:save_cpo = &cpo +set cpo&vim + +let s:source = { + \ 'name' : 'vim_complete', + \ 'kind' : 'manual', + \ 'filetypes' : { 'vim' : 1, 'vimconsole' : 1, }, + \ 'mark' : '[vim]', + \ 'rank' : 300, + \} + +function! s:source.initialize() "{{{ + " Initialize. + + " Initialize complete function list. "{{{ + if !exists('g:neocomplcache_vim_completefuncs') + let g:neocomplcache_vim_completefuncs = {} + endif + "}}} + + " Call caching event. + autocmd neocomplcache FileType * + \ call neocomplcache#sources#vim_complete#helper#on_filetype() + + " Initialize check. + call neocomplcache#sources#vim_complete#helper#on_filetype() + + " Add command. + command! -nargs=? -complete=buffer NeoComplCacheCachingVim + \ call neocomplcache#sources#vim_complete#helper#recaching() +endfunction"}}} + +function! s:source.finalize() "{{{ + delcommand NeoComplCacheCachingVim + + if neocomplcache#exists_echodoc() + call echodoc#unregister('vim_complete') + endif +endfunction"}}} + +function! s:source.get_keyword_pos(cur_text) "{{{ + let cur_text = neocomplcache#sources#vim_complete#get_cur_text() + + if cur_text =~ '^\s*"' + " Comment. + return -1 + endif + + let pattern = '\.\%(\h\w*\)\?$\|' . + \ neocomplcache#get_keyword_pattern_end('vim') + if cur_text != '' && cur_text !~ + \ '^[[:digit:],[:space:][:tab:]$''<>]*\h\w*$' + let command_completion = + \ neocomplcache#sources#vim_complete#helper#get_completion_name( + \ neocomplcache#sources#vim_complete#get_command(cur_text)) + if command_completion =~ '\%(dir\|file\|shellcmd\)' + let pattern = neocomplcache#get_keyword_pattern_end('filename') + endif + endif + + let [complete_pos, complete_str] = + \ neocomplcache#match_word(a:cur_text, pattern) + if complete_pos < 0 + " Use args pattern. + let [complete_pos, complete_str] = + \ neocomplcache#match_word(a:cur_text, '\S\+$') + endif + + if a:cur_text !~ '\.\%(\h\w*\)\?$' && neocomplcache#is_auto_complete() + \ && bufname('%') !=# '[Command Line]' + \ && neocomplcache#util#mb_strlen(complete_str) + \ < g:neocomplcache_auto_completion_start_length + return -1 + endif + + return complete_pos +endfunction"}}} + +function! s:source.get_complete_words(complete_pos, complete_str) "{{{ + let cur_text = neocomplcache#sources#vim_complete#get_cur_text() + if neocomplcache#is_auto_complete() && cur_text !~ '\h\w*\.\%(\h\w*\)\?$' + \ && len(a:complete_str) < g:neocomplcache_auto_completion_start_length + \ && bufname('%') !=# '[Command Line]' + return [] + endif + + if cur_text =~ '\h\w*\.\%(\h\w*\)\?$' + " Dictionary. + let complete_str = matchstr(cur_text, '.\%(\h\w*\)\?$') + let list = neocomplcache#sources#vim_complete#helper#var_dictionary( + \ cur_text, complete_str) + return neocomplcache#keyword_filter(list, complete_str) + elseif a:complete_str =~# '^&\%([gl]:\)\?' + " Options. + let prefix = matchstr(a:complete_str, '&\%([gl]:\)\?') + let list = deepcopy( + \ neocomplcache#sources#vim_complete#helper#option( + \ cur_text, a:complete_str)) + for keyword in list + let keyword.word = + \ prefix . keyword.word + let keyword.abbr = prefix . + \ get(keyword, 'abbr', keyword.word) + endfor + elseif a:complete_str =~? '^\c' + " SID functions. + let prefix = matchstr(a:complete_str, '^\c') + let complete_str = substitute(a:complete_str, '^\c', 's:', '') + let list = deepcopy( + \ neocomplcache#sources#vim_complete#helper#function( + \ cur_text, complete_str)) + for keyword in list + let keyword.word = prefix . keyword.word[2:] + let keyword.abbr = prefix . + \ get(keyword, 'abbr', keyword.word)[2:] + endfor + elseif cur_text =~# '\[:alnum:]]*$' + " Expand. + let list = neocomplcache#sources#vim_complete#helper#expand( + \ cur_text, a:complete_str) + elseif a:complete_str =~ '^\$' + " Environment. + let list = neocomplcache#sources#vim_complete#helper#environment( + \ cur_text, a:complete_str) + elseif cur_text =~ '^[[:digit:],[:space:][:tab:]$''<>]*!\s*\f\+$' + " Shell commands. + let list = neocomplcache#sources#vim_complete#helper#shellcmd( + \ cur_text, a:complete_str) + else + " Commands. + let list = neocomplcache#sources#vim_complete#helper#command( + \ cur_text, a:complete_str) + endif + + return neocomplcache#keyword_filter(copy(list), a:complete_str) +endfunction"}}} + +function! neocomplcache#sources#vim_complete#define() "{{{ + return s:source +endfunction"}}} + +function! neocomplcache#sources#vim_complete#get_cur_text() "{{{ + let cur_text = neocomplcache#get_cur_text(1) + if &filetype == 'vimshell' && exists('*vimshell#get_secondary_prompt') + \ && empty(b:vimshell.continuation) + return cur_text[len(vimshell#get_secondary_prompt()) :] + endif + + let line = line('.') + let cnt = 0 + while cur_text =~ '^\s*\\' && line > 1 && cnt < 5 + let cur_text = getline(line - 1) . + \ substitute(cur_text, '^\s*\\', '', '') + let line -= 1 + let cnt += 1 + endwhile + + return split(cur_text, '\s\+|\s\+\|', 1)[-1] +endfunction"}}} +function! neocomplcache#sources#vim_complete#get_command(cur_text) "{{{ + return matchstr(a:cur_text, '\<\%(\d\+\)\?\zs\h\w*\ze!\?\|'. + \ '\<\%([[:digit:],[:space:]$''<>]\+\)\?\zs\h\w*\ze/.*') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/autocmds.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/autocmds.dict new file mode 100644 index 0000000..7bcbd68 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/autocmds.dict @@ -0,0 +1,83 @@ +BufNewFile ; starting to edit a file that doesn't exist +BufReadPre ; starting to edit a new buffer, before reading the file +BufRead ; starting to edit a new buffer, after reading the file +BufReadPost ; starting to edit a new buffer, after reading the file +BufReadCmd ; before starting to edit a new buffer |Cmd-event| +FileReadPre ; before reading a file with a ":read" command +FileReadPost ; after reading a file with a ":read" command +FileReadCmd ; before reading a file with a ":read" command |Cmd-event| +FilterReadPre ; before reading a file from a filter command +FilterReadPost ; after reading a file from a filter command +StdinReadPre ; before reading from stdin into the buffer +StdinReadPost ; After reading from the stdin into the buffer +BufWrite ; starting to write the whole buffer to a file +BufWritePre ; starting to write the whole buffer to a file +BufWritePost ; after writing the whole buffer to a file +BufWriteCmd ; before writing the whole buffer to a file |Cmd-event| +FileWritePre ; starting to write part of a buffer to a file +FileWritePost ; after writing part of a buffer to a file +FileWriteCmd ; starting to append to a file +FileAppendPre ; after appending to a file +FileAppendPost ; before appending to a file |Cmd-event| +FileAppendCmd ; starting to write a file for a filter command or diff +FilterWritePre ; after writing a file for a filter command or diff +FilterWritePost ; just after adding a buffer to the buffer list +BufAdd ; just after adding a buffer to the buffer list +BufCreate ; just after adding a buffer to the buffer list +BufDelete ; before deleting a buffer from the buffer list +BufWipeout ; before completely deleting a buffer +BufFilePre ; before changing the name of the current buffer +BufFilePost ; after changing the name of the current buffer +BufEnter ; after entering a buffer +BufLeave ; before leaving to another buffer +BufWinEnter ; after a buffer is displayed in a window +BufWinLeave ; before a buffer is removed from a window +BufUnload ; before unloading a buffer +BufHidden ; just after a buffer has become hidden +BufNew ; just after creating a new buffer +SwapExists ; detected an existing swap file +FileType ; when the 'filetype' option has been set +Syntax ; when the 'syntax' option has been set +EncodingChanged ; after the 'encoding' option has been changed +TermChanged ; after the value of 'term' has changed +VimEnter ; after doing all the startup stuff +GUIEnter ; after starting the GUI successfully +TermResponse ; after the terminal response to |t_RV| is received +VimLeavePre ; before exiting Vim, before writing the viminfo file +VimLeave ; before exiting Vim, after writing the viminfo file +FileChangedShell ; Vim notices that a file changed since editing started +FileChangedShellPost ; After handling a file changed since editing started +FileChangedRO ; before making the first change to a read-only file +ShellCmdPost ; after executing a shell command +ShellFilterPost ; after filtering with a shell command +FuncUndefined ; a user function is used but it isn't defined +SpellFileMissing ; a spell file is used but it can't be found +SourcePre ; before sourcing a Vim script +SourceCmd ; before sourcing a Vim script |Cmd-event| +VimResized ; after the Vim window size changed +FocusGained ; Vim got input focus +FocusLost ; Vim lost input focus +CursorHold ; the user doesn't press a key for a while +CursorHoldI ; the user doesn't press a key for a while in Insert mode +CursorMoved ; the cursor was moved in Normal mode +CursorMovedI ; the cursor was moved in Insert mode +WinEnter ; after entering another window +WinLeave ; before leaving a window +TabEnter ; after entering another tab page +TabLeave ; before leaving a tab page +CmdwinEnter ; after entering the command-line window +CmdwinLeave ; before leaving the command-line window +InsertEnter ; starting Insert mode +InsertChange ; when typing while in Insert or Replace mode +InsertLeave ; when leaving Insert mode +ColorScheme ; after loading a color scheme +CompleteDone ; after Insert mode completion is done +RemoteReply ; a reply from a server Vim was received +QuickFixCmdPre ; before a quickfix command is run +QuickFixCmdPost ; after a quickfix command is run +SessionLoadPost ; after loading a session file +MenuPopup ; just before showing the popup menu +User ; to be used in combination with ":doautocmd" + ; buffer-local autocommands + ; for the file name that is being + ; for the buffer name that is being diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_args.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_args.dict new file mode 100644 index 0000000..1805a74 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_args.dict @@ -0,0 +1,44 @@ +-bang ; the command can take a ! modifier (like :q or :w) +-bar ; the command can be followed by a "|" and another command +-buffer ; the command will only be available in the current buffer +-complete=augroup ; autocmd groups +-complete=behave ; :behave suboptions +-complete=buffer ; buffer names +-complete=color ; color schemes +-complete=command ; Ex command (and arguments) +-complete=compiler ; compilers +-complete=cscope ; :cscope suboptions +-complete=custom,{func} ; custom completion, defined via {func} +-complete=customlist,{func} ; custom completion, defined via {func} +-complete=dir ; directory names +-complete=environment ; environment variable names +-complete=event ; autocommand events +-complete=expression ; Vim expression +-complete=file ; file and directory names +-complete=file_in_path ; file and directory names in 'path' +-complete=filetype ; filetype names 'filetype' +-complete=function ; function name +-complete=help ; help subjects +-complete=highlight ; highlight groups +-complete=history ; :history suboptions +-complete=locale ; locale names (as output of locale -a) +-complete=mapping ; mapping name +-complete=menu ; menus +-complete=option ; options +-complete=shellcmd ; Shell command +-complete=sign ; :sign suboptions +-complete=syntax ; syntax file names |'syntax'| +-complete=tag ; tags +-complete=tag_list ; tags, file names are shown when CTRL-D is hit +-complete=tag_listfiles ; tags, file names are shown when CTRL-D is hit +-complete=var ; user variables +-count= ; a count (default N) in the line or as an initial argument +-nargs=* ; any number of arguments are allowed (0, 1, or many) +-nargs=+ ; arguments must be supplied, but any number are allowed +-nargs=0 ; no arguments are allowed (the default) +-nargs=1 ; exactly one argument is required +-nargs=? ; 0 or 1 arguments are allowed +-range ; range allowed, default is current line +-range= ; a count (default N) which is specified in the line +-range=% ; range allowed, default is whole file (1,$) +-register ; the first argument to the command can be an optional register name diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_completions.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_completions.dict new file mode 100644 index 0000000..3e258a4 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_completions.dict @@ -0,0 +1,498 @@ +N[ext] +P[rint] +a[ppend] +ab[breviate] abbreviation +abc[lear] +abo[veleft] command +al[l] +am[enu] +an[oremenu] menu +ar[gs] file +arga[dd] file +argd[elete] file +argdo command +arge[dit] file +argg[lobal] file +argl[ocal] file +argu[ment] +as[cii] +au[tocmd] autocmd_args +aug[roup] augroup +aun[menu] menu +bN[ext] +b[uffer] buffer +ba[ll] +bad[d] file +bd[elete] buffer +be[have] +bel[owright] command +bf[irst] +bl[ast] +bm[odified] +bn[ext] +bo[tright] command +bp[revious] +br[ewind] +brea[k] +breaka[dd] function +breakd[el] +breakl[ist] +bro[wse] command +bufdo command +buffers +bun[load] buffer +bw[ipeout] buffer +cN[ext] +cNf[ile] +c[hange] +ca[bbrev] abbreviation +cabc[lear] +cad[dexpr] expression +caddb[uffer] +caddf[ile] file +cal[l] function +cat[ch] +cb[uffer] +cc +ccl[ose] +cd dir +ce[nter] +cex[pr] expression +cf[ile] file +cfir[st] +cg[etfile] file +cgetb[uffer] +cgete[xpr] expression +changes +chd[ir] dir +che[ckpath] +checkt[ime] +cl[ist] +cla[st] +clo[se] +cm[ap] mapping +cmapc[lear] +cme[nu] menu +cn[ext] +cnew[er] +cnf[ile] +cno[remap] mapping +cnorea[bbrev] abbreviation +cnoreme[nu] menu +co[py] +col[der] +colo[rscheme] colorscheme_args +com[mand] command_args +comc[lear] +comp[iler] compiler_args +con[tinue] +conf[irm] command +cope[n] +cp[revious] +cpf[ile] +cq[uit] +cr[ewind] +cs[cope] cscope_args +cst[ag] +cu[nmap] mapping +cuna[bbrev] abbreviation +cunme[nu] menu +cw[indow] +d[elete] +deb[ug] command +debugg[reedy] +del[command] command +delf[unction] function +delm[arks] +di[splay] +diffg[et] +diffo[ff] +diffp[atch] file +diffpu[t] +diffs[plit] file +diffthis +diffu[pdate] +dig[raphs] +dj[ump] +dl[ist] +do[autocmd] autocmd_args +doautoa[ll] autocmd_args +dr[op] file +ds[earch] +dsp[lit] +e[dit] file +ea[rlier] +ec[ho] expression +echoe[rr] expression +echoh[l] expression +echom[sg] expression +echon expression +el[se] +elsei[f] expression +em[enu] menu +en[dif] +endf[unction] +endfo[r] +endt[ry] +endw[hile] +ene[w] +ex file +exe[cute] execute +exi[t] file +exu[sage] +f[ile] +files +filet[ype] +fin[d] file +fina[lly] +fini[sh] +fir[st] +fix[del] +fo[ld] +foldc[lose] +foldd[oopen] command +folddoc[losed] command +foldo[pen] +for expression +fu[nction] function_args +go[to] +gr[ep] file +grepa[dd] file +gu[i] file +gv[im] file +h[elp] help +ha[rdcopy] +helpf[ind] +helpg[rep] +helpt[ags] dir +hi[ghlight] highlight +hid[e] command +his[tory] +i[nsert] +ia[bbrev] abbreviation +iabc[lear] +if expression +ij[ump] +il[ist] +im[ap] mapping +imapc[lear] +imenu menu +ino[remap] mapping +inorea[bbrev] mapping +inoreme[nu] menu +int[ro] +is[earch] +isp[lit] +iu[nmap] mapping +iuna[bbrev] abbreviation +iunme[nu] menu +j[oin] +ju[mps] +kee[pmarks] command +keep[jumps] command +keepa[lt] command +lN[ext] +lNf[ile] +l[ist] +la[st] +lad[dexpr] expr +laddb[uffer] +laddf[ile] file +lan[guage] language_args +lat[er] +lb[uffer] +lc[d] dir +lch[dir] dir +lcl[ose] +lcs[cope] cscope_args +le[ft] +lefta[bove] command +let let +lex[pr] expression +lf[ile] file +lfir[st] +lg[etfile] file +lgetb[uffer] +lgete[xpr] expression +lgr[ep] file +lgrepa[dd] file +lh[elpgrep] +ll +lla[st] +lli[st] +lm[ap] mapping +lmak[e] file +lmapc[lear] +ln[oremap] mapping +lne[xt] +lnew[er] +lnf[ile] +lo[adview] +loadk[eymap] +loc[kmarks] command +lockv[ar] var +lol[der] +lop[en] +lp[revious] +lpf[ile] +lr[ewind] +ls +lt[ag] +lu[nmap] mapping +lua +luado +luafile file +lv[imgrep] file +lvimgrepadd file +lwindow +m[ove] +ma[rk] +mak[e] file +map mapping +mapc[lear] +marks +match +menu menu +menut[ranslate] menutranslate_args +mes[sages] +mk[exrc] file +mks[ession] file +mksp[ell] file +mkv[imrc] file +mkvie[w] file +mod[e] +mz[scheme] file +mzf[ile] file +n[ext] +nb[key] +new +nm[ap] mapping +nmapc[lear] +nmenu menu +nno[remap] mapping +nnoreme[nu] menu +no[remap] mapping +noa[utocmd] command +noh[lsearch] +norea[bbrev] abbreviation +noreme[nu] menu +norm[al] +nu[mber] +nun[map] mapping +nunme[nu] menu +o[pen] +ol[dfiles] +om[ap] mapping +omapc[lear] +ome[nu] menu +on[ly] +ono[remap] mapping +onoreme[nu] menu +opt[ions] +ou[nmap] lhs +ounmenu menu +ownsyntax syntax_args +p[rint] +pc[lose] +pe[rl] +ped[it] file +perld[o] +po[p] +popu[p] +pp[op] +pre[serve] +prev[ious] +prof[ile] profile_args +profd[el] +promptf[ind] +promptr[epl] +ps[earch] +ptN[ext] +pta[g] tag +ptf[irst] +ptj[ump] +ptl[ast] +ptn[ext] +ptp[revious] +ptr[ewind] +pts[elect] tag +pu[t] +pw[d] +py3f[ile] file +py[thon] +pyf[ile] file +python3 +q[uit] +qa[ll] +quita[ll] +r[ead] +rec[over] file +red[o] +redi[r] +redr[aw] +redraws[tatus] +reg[isters] +res[ize] +ret[ab] +retu[rn] expression +rew[ind] +ri[ght] +rightb[elow] command +rub[y] +rubyd[o] +rubyf[ile] file +runtime file +rv[iminfo] file +sN[ext] +s[ubstitute] +sa[rgument] +sal[l] +san[dbox] command +sav[eas] file +sbN[ext] +sb[uffer] buffer +sba[ll] +sbf[irst] +sbl[ast] +sbm[odified] +sbn[ext] +sbp[revious] +sbr[ewind] +scrip[tnames] +scripte[ncoding] encoding +scscope cscope_args +se[t] option +setf[iletype] filetype +setg[lobal] option +setl[ocal] option +sf[ind] file +sfir[st] +sh[ell] +sig[n] sign_args +sil[ent] command +sim[alt] +sl[eep] +sla[st] +sm[agic] +sm[ap] mapping +smapc[lear] +sme[nu] menu +sn[ext] file +sni[ff] +sno[remap] mapping +snoreme[nu] menu +so[urce] file +sor[t] +sp[lit] +spe[llgood] +spelld[ump] +spelli[nfo] +spellr[epall] +spellu[ndo] +spellw[rong] +spr[evious] +sre[wind] +st[op] +sta[g] tag +star[tinsert] +startg[replace] +startr[eplace] +stj[ump] tag +stopi[nsert] +sts[elect] tag +sun[hide] +sunm[ap] mapping +sunme[nu] menu +sus[pend] +sv[iew] file +sw[apname] +sy[ntax] syntax_args +sync[bind] +t +tN[ext] +ta[g] tag +tab command +tabN[ext] +tabc[lose] +tabd[o] command +tabe[dit] file +tabf[ind] file +tabfir[st] +tabl[ast] +tabm[ove] +tabn[ext] +tabnew file +tabo[nly] +tabp[revious] +tabr[ewind] +tabs +tags +tc[l] +tcld[o] +tclf[ile] file +te[aroff] menu +tf[irst] +th[row] expression +tj[ump] tag +tl[ast] +tm[enu] menu +tn[ext] +to[pleft] command +tp[revious] +tr[ewind] +try +tselect +tu[nmenu] menu +u[ndo] +una[bbreviate] abbreviation +undoj[oin] +undol[ist] +unh[ide] +unl[et] var +unlo[ckvar] var +unm[ap] mapping +unme[nu] menu +uns[ilent] command +up[date] file +ve[rsion] +verb[ose] command +vert[ical] command +vg[lobal] +vi[sual] file +vie[w] file +vim[grep] file +vimgrepa[dd] file +viu[sage] +vm[ap] mapping +vmapc[lear] +vmenu menu +vn[oremap] mapping +vne[w] file +vnoremenu menu +vsp[lit] file +vu[nmap] mapping +vunmenu menu +wN[ext] file +w[rite] file +wa[ll] +wh[ile] expression +win[size] +winc[md] +windo command +winp[os] +wn[ext] +wp[revious] file +wq +wqa[ll] +ws[verb] +wv[iminfo] file +x[it] file +xa[ll] +xm[ap] mapping +xmapc[lear] +xmenu menu +xn[oremap] mapping +xnoremenu menu +xu[nmap] mapping +xunmenu menu +y[ank] diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_prototypes.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_prototypes.dict new file mode 100644 index 0000000..ecd86c9 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_prototypes.dict @@ -0,0 +1,498 @@ +N[ext] [count] [++opt] [+cmd] +P[rint] [count] [flags] +a[ppend] +ab[breviate] +abc[lear] +abo[veleft] {cmd} +al[l] [N] +am[enu] +an[oremenu] {menu} +ar[gs] +arga[dd] {name} .. +argd[elete] {pattern} .. +argdo {cmd} +arge[dit] [++opt] [+cmd] {name} +argg[lobal] [++opt] [+cmd] {arglist} +argl[ocal] [++opt] [+cmd] {arglist} +argu[ment] [count] [++opt] [+cmd] +as[cii] +au[tocmd] [group] {event} {pat} [nested] {cmd} +aug[roup] {name} +aun[menu] {menu} +bN[ext] [N] +b[uffer] {bufname} +ba[ll] [N] +bad[d] [+lnum] {fname} +bd[elete] {bufname} +be[have] {model} +bel[owright] {cmd} +bf[irst] +bl[ast] +bm[odified] [N] +bn[ext] [N] +bo[tright] {cmd} +bp[revious] [N] +br[ewind] +brea[k] +breaka[dd] func [lnum] {name} +breakd[el] {nr} +breakl[ist] +bro[wse] {command} +bufdo {cmd} +buffers +bun[load] {bufname} +bw[ipeout] {bufname} +cN[ext] +cNf[ile] +c[hange] +ca[bbrev] [] [lhs] [rhs] +cabc[lear] +cad[dexpr] {expr} +caddb[uffer] [bufnr] +caddf[ile] [errorfile] +cal[l] {name}([arguments]) +cat[ch] /{pattern}/ +cb[uffer] [bufnr] +cc [nr] +ccl[ose] +cd {path} +ce[nter] [width] +cex[pr] {expr} +cf[ile] [errorfile] +cfir[st] [nr] +cg[etfile] [errorfile] +cgetb[uffer] [bufnr] +cgete[xpr] {expr} +changes +chd[ir] [path] +che[ckpath] +checkt[ime] +cl[ist] [from] [, [to]] +cla[st] [nr] +clo[se] +cm[ap] {lhs} {rhs} +cmapc[lear] +cme[nu] {menu} +cn[ext] +cnew[er] [count] +cnf[ile] +cno[remap] {lhs} {rhs} +cnorea[bbrev] [] [lhs] [rhs] +cnoreme[nu] {menu} +co[py] {address} +col[der] [count] +colo[rscheme] {name} +com[mand] [-bang -complete= -nargs=...] {cmdname} {call function()} | {rep} +comc[lear] +comp[iler] {name} +con[tinue] +conf[irm] {command} +cope[n] [height] +cp[revious] +cpf[ile] +cq[uit] +cr[ewind] [nr] +cs[cope] add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show +cst[ag] +cu[nmap] {lhs} +cuna[bbrev] {lhs} +cunme[nu] {menu} +cw[indow] [height] +d[elete] [x] +deb[ug] {cmd} +debugg[reedy] +del[command] {cmd} +delf[unction] {name} +delm[arks] {marks} +di[splay] [arg] +diffg[et] [bufspec] +diffo[ff] +diffp[atch] {patchfile} +diffpu[t] [bufspec] +diffs[plit] {filename} +diffthis +diffu[pdate] +dig[raphs] {char1}{char2} {number} ... +dj[ump] [count] [/]string[/] +dl[ist] [/]string[/] +do[autocmd] [group] {event} [fname] +doautoa[ll] [group] {event} [fname] +dr[op] [++opt] [+cmd] {file} .. +ds[earch] [count] [/]string[/] +dsp[lit] [count] [/]string[/] +e[dit] [++opt] [+cmd] {file} +ea[rlier] {count} | {N}s | {N}h +ec[ho] {expr1} .. +echoe[rr] {expr1} .. +echoh[l] {expr1} .. +echom[sg] {expr1} .. +echon {expr1} .. +el[se] +elsei[f] {expr1} +em[enu] {menu} +en[dif] +endf[unction] +endfo[r] +endt[ry] +endw[hile] +ene[w] +ex [++opt] [+cmd] [file] +exe[cute] {expr1} .. +exi[t] [++opt] [file] +exu[sage] +f[ile] +files +filet[ype] +fin[d] [++opt] [+cmd] {file} +fina[lly] +fini[sh] +fir[st] [++opt] [+cmd] +fix[del] +fo[ld] +foldc[lose] +foldd[oopen] {cmd} +folddoc[losed] {cmd} +foldo[pen] +for {var} in {list} +fu[nction] {name}([arguments]) [range] [abort] [dict] +go[to] [count] +gr[ep] [arguments] +grepa[dd] [arguments] +gu[i] [++opt] [+cmd] [-f|-b] [files...] +gv[im] [++opt] [+cmd] [-f|-b] [files...] +h[elp] {subject} +ha[rdcopy] [arguments] +helpf[ind] +helpg[rep] {pattern}[@xx] +helpt[ags] [++t] {dir} +hi[ghlight] [default] {group-name} {key}={arg} .. +hid[e] {cmd} +his[tory] [{name}] [{first}][, [{last}]] +i[nsert] +ia[bbrev] [] [lhs] [rhs] +iabc[lear] +if {expr1} +ij[ump] [count] [/]pattern[/] +il[ist] [/]pattern[/] +im[ap] {lhs} {rhs} +imapc[lear] +imenu {menu} +ino[remap] {lhs} {rhs} +inorea[bbrev] [] [lhs] [rhs] +inoreme[nu] {menu} +int[ro] +is[earch] [count] [/]pattern[/] +isp[lit] [count] [/]pattern[/] +iu[nmap] {lhs} +iuna[bbrev] {lhs} +iunme[nu] {menu} +j[oin] {count} [flags] +ju[mps] +kee[pmarks] {command} +keep[jumps] {command} +keepa[lt] {cmd} +lN[ext] +lNf[ile] +l[ist] [count] [flags] +la[st] [++opt] [+cmd] +lad[dexpr] {expr} +laddb[uffer] [bufnr] +laddf[ile] [errorfile] +lan[guage] {name} | mes[sages] {name} | cty[pe] {name} | tim[e] {name} +lat[er] {count} | {N}s | {N}m | {N}h +lb[uffer] [bufnr] +lc[d] {path} +lch[dir] {path} +lcl[ose] +lcs[cope] add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show +le[ft] [indent] +lefta[bove] {cmd} +let {var-name} = {expr1} +lex[pr] {expr} +lf[ile] [errorfile] +lfir[st] [nr] +lg[etfile] [errorfile] +lgetb[uffer] [bufnr] +lgete[xpr] {expr} +lgr[ep] [arguments] +lgrepa[dd] [arguments] +lh[elpgrep] {pattern}[@xx] +ll [nr] +lla[st] [nr] +lli[st] [from] [, [to]] +lm[ap] {lhs} {rhs} +lmak[e] [arguments] +lmapc[lear] +ln[oremap] {lhs} {rhs} +lne[xt] +lnew[er] [count] +lnf[ile] +lo[adview] [nr] +loadk[eymap] +loc[kmarks] {command} +lockv[ar] [depth] {name} ... +lol[der] [count] +lop[en] [height] +lp[revious] +lpf[ile] +lr[ewind] [nr] +ls +lt[ag] [ident] +lua {chunk} | << {endmarker} +luado {body} +luafile {file} +lu[nmap] {lhs} +lv[imgrep] /{pattern}/[g][j] {file} ... | {pattern} {file} ... +lvimgrepadd /{pattern}/[g][j] {file} ... | {pattern} {file} ... +lwindow [height] +m[ove] {address} +ma[rk] {a-zA-z'} +mak[e] [arguments] +map {lhs} {rhs} +mapc[lear] +marks +match {group} /{pattern}/ +menu {menu} +menut[ranslate] clear | {english} {mylang} +mes[sages] +mk[exrc] [file] +mks[ession] [file] +mksp[ell] [-ascii] {outname} {inname} ... +mkv[imrc] [file] +mkvie[w] [file] +mod[e] [mode] +mz[scheme] {stmt} | << {endmarker} {script} {endmarker} | {file} +mzf[ile] {file} +n[ext] [++opt] [+cmd] +nb[key] key +new +nm[ap] {lhs} {rhs} +nmapc[lear] +nmenu {menu} +nno[remap] {lhs} {rhs} +nnoreme[nu] {menu} +no[remap] {lhs} {rhs} +noa[utocmd] {cmd} +noh[lsearch] +norea[bbrev] [] [lhs] [rhs] +noreme[nu] {menu} +norm[al] {commands} +nu[mber] [count] [flags] +nun[map] {lhs} +nunme[nu] {menu} +o[pen] /pattern/ +ol[dfiles] +om[ap] {lhs} {rhs} +omapc[lear] +ome[nu] {menu} +on[ly] +ono[remap] {lhs} {rhs} +onoreme[nu] {menu} +opt[ions] +ou[nmap] {lhs} +ounmenu {menu} +ownsyntax list {group-name} | list @{cluster-name} +p[rint] {count} [flags] +pc[lose] +pe[rl] {cmd} | << {endpattern} {script} {endpattern} +ped[it] [++opt] [+cmd] {file} +perld[o] {cmd} +po[p] +popu[p] {name} +pp[op] +pre[serve] +prev[ious] [count] [++opt] [+cmd] +prof[ile] start {fname} | pause | continue | func {pattern} | file {pattern} +profd[el] ... +promptf[ind] [string] +promptr[epl] [string] +ps[earch] [count] [/]pattern[/] +ptN[ext] +pta[g] [tagname] +ptf[irst] +ptj[ump] +ptl[ast] +ptn[ext] +ptp[revious] +ptr[ewind] +pts[elect] [ident] +pu[t] [x] +pw[d] +py[thon] {stmt} | << {endmarker} {script} {endmarker} +python3 {stmt} | << {endmarker} {script} {endmarker} +pyf[ile] {file} +py3f[ile] {file} +q[uit] +qa[ll] +quita[ll] +r[ead] [++opt] [name] +rec[over] [file] +red[o] +redi[r] > {file} | >> {file} | @{a-zA-Z} | => {var} | END +redr[aw] +redraws[tatus] +reg[isters] {arg} +res[ize] +ret[ab] [new_tabstop] +retu[rn] [expr] +rew[ind] [++opt] [+cmd] +ri[ght] [width] +rightb[elow] {cmd} +rub[y] {cmd} | << {endpattern} {script} {endpattern} +rubyd[o] {cmd} +rubyf[ile] {file} +runtime {file} .. +rv[iminfo] [file] +sN[ext] [++opt] [+cmd] [N] +s[ubstitute] /{pattern}/{string}/[flags] [count] +sa[rgument] [++opt] [+cmd] [N] +sal[l] +san[dbox] {cmd} +sav[eas] [++opt] {file} +sbN[ext] [N] +sb[uffer] {bufname} +sba[ll] [N] +sbf[irst] +sbl[ast] +sbm[odified] [N] +sbn[ext] [N] +sbp[revious] [N] +sbr[ewind] +scrip[tnames] +scripte[ncoding] [encoging] +scscope add {file|dir} [pre-path] [flags] | find {querytype} {name} | kill {num|partial_name} | help | reset | show +se[t] {option}={value} {option}? | {option} | {option}& +setf[iletype] {filetype} +setg[lobal] ... +setl[ocal] ... +sf[ind] [++opt] [+cmd] {file} +sfir[st] [++opt] [+cmd] +sh[ell] +sig[n] define {name} {argument}... | icon={pixmap} | linehl={group} | text={text} | texthl={group} +sil[ent] {command} +sim[alt] {key} +sl[eep] [N] [m] +sla[st] [++opt] [+cmd] +sm[agic] ... +sm[ap] {lhs} {rhs} +smapc[lear] +sme[nu] {menu} +sn[ext] [++opt] [+cmd] [file ..] +sni[ff] request [symbol] +sno[remap] {lhs} {rhs} +snoreme[nu] {menu} +so[urce] {file} +sor[t] [i][u][r][n][x][o] [/{pattern}/] +sp[lit] [++opt] [+cmd] +spe[llgood] {word} +spelld[ump] +spelli[nfo] +spellr[epall] +spellu[ndo] {word} +spellw[rong] {word} +spr[evious] [++opt] [+cmd] [N] +sre[wind] [++opt] [+cmd] +st[op] +sta[g] [tagname] +star[tinsert] +startg[replace] +startr[eplace] +stj[ump] [ident] +stopi[nsert] +sts[elect] [ident] +sun[hide] [N] +sunm[ap] {lhs} +sunme[nu] {menu} +sus[pend] +sv[iew] [++opt] [+cmd] {file} +sw[apname] +sy[ntax] list {group-name} | list @{cluster-name} +sync[bind] +t +tN[ext] +ta[g] {ident} +tab {cmd} +tabN[ext] +tabc[lose] +tabd[o] {cmd} +tabe[dit] [++opt] [+cmd] {file} +tabf[ind] [++opt] [+cmd] {file} +tabfir[st] +tabl[ast] +tabm[ove] [N] +tabn[ext] +tabnew [++opt] [+cmd] {file} +tabo[nly] +tabp[revious] +tabr[ewind] +tabs +tags +tc[l] {cmd} | {endmarker} {script} {endmarker} +tcld[o] {cmd} +tclf[ile] {file} +te[aroff] {name} +tf[irst] +th[row] {expr1} +tj[ump] [ident] +tl[ast] +tm[enu] {menu} +tn[ext] +to[pleft] {cmd} +tp[revious] +tr[ewind] +try +tselect +tu[nmenu] {menu} +u[ndo] {N} +una[bbreviate] {lhs} +undoj[oin] +undol[ist] +unh[ide] [N] +unl[et] {name} ... +unlo[ckvar] [depth] {name} ... +unm[ap] {lhs} +unme[nu] {menu} +uns[ilent] {command} +up[date] [++opt] [>>] [file] +ve[rsion] +verb[ose] {command} +vert[ical] {cmd} +vg[lobal] /{pattern}/[cmd] +vi[sual] [++opt] [+cmd] [file] +vie[w] [++opt] [+cmd] file +vim[grep] /{pattern}/[g][j] {file} ... | {pattern} {file} ... +vimgrepa[dd] /{pattern}/[g][j] {file} ... | {pattern} {file} ... +viu[sage] +vm[ap] {lhs} {rhs} +vmapc[lear] +vmenu {menu} +vn[oremap] {lhs} {rhs} +vne[w] [++opt] [+cmd] [file] +vnoremenu {menu} +vsp[lit] [++opt] [+cmd] [file] +vu[nmap] {lhs} +vunmenu {menu} +wN[ext] [++opt] [file] +w[rite] [++opt] [file] +wa[ll] +wh[ile] {expr1} +win[size] {width} {height} +winc[md] {arg} +windo {cmd} +winp[os] {X} {Y} +wn[ext] [++opt] +wp[revious] [++opt] [file] +wq [++opt] +wqa[ll] [++opt] +ws[verb] verb +wv[iminfo] [file] +x[it] [++opt] [file] +xa[ll] [++opt] +xm[ap] {lhs} {rhs} +xmapc[lear] +xmenu {menu} +xn[oremap] {lhs} {rhs} +xnoremenu {menu} +xu[nmap] {lhs} +xunmenu {menu} +y[ank] [x] {count} diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_replaces.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_replaces.dict new file mode 100644 index 0000000..6ec9154 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/command_replaces.dict @@ -0,0 +1,10 @@ + ; the starting line of the command range + ; the final line of the command range + ; any count supplied (as described for the '-range' and '-count' attributes) + ; expands to a ! if the command was executed with a ! modifier + ; the optional register, if specified + ; the command arguments, exactly as supplied + ; a single '<' (Less-Than) character + ; the value is quoted in such a way as to make it a valid value for use in an expression + ; splits the command arguments at spaces and tabs, quotes each argument individually + ; defining a user command in a script diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/commands.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/commands.dict new file mode 100644 index 0000000..565c1ea --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/commands.dict @@ -0,0 +1,492 @@ +Next ; go to previous file in the argument list +Print ; print lines +abbreviate ; enter abbreviation +abclear ; remove all abbreviations +aboveleft ; make split window appear left or above +all ; open a window for each file in the argument list +amenu ; enter new menu item for all modes +anoremenu ; enter a new menu for all modes that will not be remapped +append ; append text +argadd ; add items to the argument list +argdelete ; delete items from the argument list +argdo ; do a command on all items in the argument list +argedit ; add item to the argument list and edit it +argglobal ; define the global argument list +arglocal ; define a local argument list +args ; print the argument list +argument ; go to specific file in the argument list +ascii ; print ascii value of character under the cursor +augroup ; select the autocommand group to use +aunmenu ; remove menu for all modes +autocmd ; enter or show autocommands +bNext ; go to previous buffer in the buffer list +badd ; add buffer to the buffer list +ball ; open a window for each buffer in the buffer list +bdelete ; remove a buffer from the buffer list +behave ; set mouse and selection behavior +belowright ; make split window appear right or below +bfirst ; go to first buffer in the buffer list +blast ; go to last buffer in the buffer list +bmodified ; go to next buffer in the buffer list that has been modified +bnext ; go to next buffer in the buffer list +botright ; make split window appear at bottom or far right +bprevious ; go to previous buffer in the buffer list +break ; break out of while loop +breakadd ; add a debugger breakpoint +breakdel ; delete a debugger breakpoint +breaklist ; list debugger breakpoints +brewind ; go to first buffer in the buffer list +browse ; use file selection dialog +bufdo ; execute command in each listed buffer +buffer ; go to specific buffer in the buffer list +buffers ; list all files in the buffer list +bunload ; unload a specific buffer +bwipeout ; really delete a buffer +cNext ; go to previous error +cNfile ; go to last error in previous file +cabbrev ; like "abbreviate" but for Command-line mode +cabclear ; clear all abbreviations for Command-line mode +caddbuffer ; add errors from buffer +caddexpr ; add errors from expr +caddfile ; add error message to current quickfix list +call ; call a function +catch ; part of a try command +cbuffer ; parse error messages and jump to first error +cclose ; close quickfix window +center ; format lines at the center +cexpr ; read errors from expr and jump to first +cfile ; read file with error messages and jump to first +cfirst ; go to the specified error, default first one +cgetbuffer ; get errors from buffer +cgetexpr ; get errors from expr +cgetfile ; read file with error messages +change ; replace a line or series of lines +changes ; print the change list +chdir ; change directory +checkpath ; list included files +checktime ; check timestamp of loaded buffers +clast ; go to the specified error, default last one +clist ; list all errors +close ; close current window +cmap ; like "map" but for Command-line mode +cmapclear ; clear all mappings for Command-line mode +cmenu ; add menu for Command-line mode +cnewer ; go to newer error list +cnext ; go to next error +cnfile ; go to first error in next file +cnoreabbrev ; like "noreabbrev" but for Command-line mode +cnoremap ; like "noremap" but for Command-line mode +cnoremenu ; like "noremenu" but for Command-line mode +colder ; go to older error list +colorscheme ; load a specific color scheme +comclear ; clear all user-defined commands +command ; create user-defined command +compiler ; do settings for a specific compiler +confirm ; prompt user when confirmation required +continue ; go back to while +copen ; open quickfix window +copy ; copy lines +cpfile ; go to last error in previous file +cprevious ; go to previous error +cquit ; quit Vim with an error code +crewind ; go to the specified error, default first one +cscope ; execute cscope command +cstag ; use cscope to jump to a tag +cunabbrev ; like "unabbrev" but for Command-line mode +cunmap ; like "unmap" but for Command-line mode +cunmenu ; remove menu for Command-line mode +cwindow ; open or close quickfix window +debug ; run a command in debugging mode +debuggreedy ; read debug mode commands from normal input +delcommand ; delete user-defined command +delete ; delete lines +delfunction ; delete a user function +delmarks ; delete marks +diffget ; remove differences in current buffer +diffoff ; switch off diff mode +diffpatch ; apply a patch and show differences +diffput ; remove differences in other buffer +diffsplit ; show differences with another file +diffthis ; make current window a diff window +diffupdate ; update 'diff' buffers +digraphs ; show or enter digraphs +display ; display registers +djump ; jump to #define +dlist ; list #defines +doautoall ; apply autocommands for all loaded buffers +doautocmd ; apply autocommands to current buffer +drop ; jump to window editing file or edit file in current window +dsearch ; list one #define +dsplit ; split window and jump to #define +earlier ; go to older change, undo +echo ; echoes the result of expressions +echoerr ; like echo, show like an error and use history +echohl ; set highlighting for echo commands +echomsg ; same as echo, put message in history +echon ; same as echo, but without +edit ; edit a file +else ; part of an if command +elseif ; part of an if command +emenu ; execute a menu by name +endfor ; end previous for +endfunction ; end of a user function +endif ; end previous if +endtry ; end previous try +endwhile ; end previous while +enew ; edit a new, unnamed buffer +execute ; execute result of expressions +exit ; same as "xit" +exusage ; overview of Ex commands +file ; show or set the current file name +files ; list all files in the buffer list +filetype ; switch file type detection on/off +finally ; part of a try command +find ; find file in 'path' and edit it +finish ; quit sourcing a Vim script +first ; go to the first file in the argument list +fixdel ; set key code of +fold ; create a fold +foldclose ; close folds +folddoclosed ; execute command on lines in a closed fold +folddoopen ; execute command on lines not in a closed fold +foldopen ; open folds +for ; for loop +function ; define a user function +global ; execute commands for matching lines +goto ; go to byte in the buffer +grep ; run 'grepprg' and jump to first match +grepadd ; like grep, but append to current list +gui ; start the GUI +gvim ; start the GUI +hardcopy ; send text to the printer +help ; open a help window +helpfind ; dialog to open a help window +helpgrep ; like "grep" but searches help files +helptags ; generate help tags for a directory +hide ; hide current buffer for a command +highlight ; specify highlighting methods +history ; print a history list +iabbrev ; like "abbrev" but for Insert mode +iabclear ; like "abclear" but for Insert mode +ijump ; jump to definition of identifier +ilist ; list lines where identifier matches +imap ; like "map" but for Insert mode +imapclear ; like "mapclear" but for Insert mode +imenu ; add menu for Insert mode +inoreabbrev ; like "noreabbrev" but for Insert mode +inoremap ; like "noremap" but for Insert mode +inoremenu ; like "noremenu" but for Insert mode +insert ; insert text +intro ; print the introductory message +isearch ; list one line where identifier matches +isplit ; split window and jump to definition of identifier +iunabbrev ; like "unabbrev" but for Insert mode +iunmap ; like "unmap" but for Insert mode +iunmenu ; remove menu for Insert mode +join ; join lines +jumps ; print the jump list +keepalt ; following command keeps the alternate file +keepjumps ; following command keeps jumplist and marks +keepmarks ; following command keeps marks where they are +lNext ; go to previous entry in location list +lNfile ; go to last entry in previous file +laddbuffer ; add locations from buffer +laddexpr ; add locations from expr +laddfile ; add locations to current location list +language ; set the language (locale) +last ; go to the last file in the argument list +later ; go to newer change, redo +lbuffer ; parse locations and jump to first location +lcd ; change directory locally +lchdir ; change directory locally +lclose ; close location window +lcscope ; like "cscope" but uses location list +left ; left align lines +leftabove ; make split window appear left or above +let ; assign a value to a variable or option +lexpr ; read locations from expr and jump to first +lfile ; read file with locations and jump to first +lfirst ; go to the specified location, default first one +lgetbuffer ; get locations from buffer +lgetexpr ; get locations from expr +lgetfile ; read file with locations +lgrep ; run 'grepprg' and jump to first match +lgrepadd ; like grep, but append to current list +lhelpgrep ; like "helpgrep" but uses location list +list ; print lines +llast ; go to the specified location, default last one +llist ; list all locations +lmake ; execute external command 'makeprg' and parse error messages +lmap ; like "map!" but includes Lang-Arg mode +lmapclear ; like "mapclear!" but includes Lang-Arg mode +lnewer ; go to newer location list +lnext ; go to next location +lnfile ; go to first location in next file +lnoremap ; like "noremap!" but includes Lang-Arg mode +loadkeymap ; load the following keymaps until EOF +loadview ; load view for current window from a file +lockmarks ; following command keeps marks where they are +lockvar ; lock variables +lolder ; go to older location list +lopen ; open location window +lpfile ; go to last location in previous file +lprevious ; go to previous location +lrewind ; go to the specified location, default first one +ltag ; jump to tag and add matching tags to the location list +lua ; execute Lua chunk. +luado ; execute Lua function. +luafile ; execute Lua script in file. +lunmap ; like "unmap!" but includes Lang-Arg mode +lvimgrep ; search for pattern in files +lvimgrepadd ; like vimgrep, but append to current list +lwindow ; open or close location window +make ; execute external command 'makeprg' and parse error messages +map ; show or enter a mapping +mapclear ; clear all mappings for Normal and Visual mode +mark ; set a mark +marks ; list all marks +match ; define a match to highlight +menu ; enter a new menu item +menutranslate ; add a menu translation item +messages ; view previously displayed messages +mkexrc ; write current mappings and settings to a file +mksession ; write session info to a file +mkspell ; produce .spl spell file +mkview ; write view of current window to a file +mkvimrc ; write current mappings and settings to a file +mode ; show or change the screen mode +move ; move lines +mzfile ; execute MzScheme script file +mzscheme ; execute MzScheme command +nbkey ; pass a key to Netbeans +new ; create a new empty window +next ; go to next file in the argument list +nmap ; like "map" but for Normal mode +nmapclear ; clear all mappings for Normal mode +nmenu ; add menu for Normal mode +nnoremap ; like "noremap" but for Normal mode +nnoremenu ; like "noremenu" but for Normal mode +noautocmd ; following command don't trigger autocommands +nohlsearch ; suspend 'hlsearch' highlighting +noreabbrev ; enter an abbreviation that will not be remapped +noremap ; enter a mapping that will not be remapped +noremenu ; enter a menu that will not be remapped +normal ; execute Normal mode commands +number ; print lines with line number +nunmap ; like "unmap" but for Normal mode +nunmenu ; remove menu for Normal mode +oldfiles ; list files that have marks in the viminfo file +omap ; like "map" but for Operator-pending mode +omapclear ; remove all mappings for Operator-pending mode +omenu ; add menu for Operator-pending mode +only ; close all windows except the current one +onoremap ; like "noremap" but for Operator-pending mode +onoremenu ; like "noremenu" but for Operator-pending mode +open ; start open mode (not implemented) +options ; open the options-window +ounmap ; like "unmap" but for Operator-pending mode +ounmenu ; remove menu for Operator-pending mode +ownsyntax ; define Window-local syntax +pclose ; close preview window +pedit ; edit file in the preview window +perl ; execute Perl command +perldo ; execute Perl command for each line +pop ; jump to older entry in tag stack +popup ; popup a menu by name +ppop ; "pop" in preview window +preserve ; write all text to swap file +previous ; go to previous file in argument list +print ; print lines +profdel ; stop profiling a function or script +profile ; profiling functions and scripts +promptfind ; open GUI dialog for searching +promptrepl ; open GUI dialog for search/replace +psearch ; like "ijump" but shows match in preview window +ptNext ; tNext in preview window +ptag ; show tag in preview window +ptfirst ; trewind in preview window +ptjump ; tjump and show tag in preview window +ptlast ; tlast in preview window +ptnext ; tnext in preview window +ptprevious ; tprevious in preview window +ptrewind ; trewind in preview window +ptselect ; tselect and show tag in preview window +put ; insert contents of register in the text +pwd ; print current directory +py3file ; execute Python3 script file +pyfile ; execute Python script file +python ; execute Python command +python3 ; execute Python3 command +qall ; quit Vim +quit ; quit current window (when one window quit Vim) +quitall ; quit Vim +read ; read file into the text +recover ; recover a file from a swap file +redir ; redirect messages to a file or register +redo ; redo one undone change +redraw ; force a redraw of the display +redrawstatus ; force a redraw of the status line(s) +registers ; display the contents of registers +resize ; change current window height +retab ; change tab size +return ; return from a user function +rewind ; go to the first file in the argument list +right ; right align text +rightbelow ; make split window appear right or below +ruby ; execute Ruby command +rubydo ; execute Ruby command for each line +rubyfile ; execute Ruby script file +runtime ; source vim scripts in 'runtimepath' +rviminfo ; read from viminfo file +sNext ; split window and go to previous file in argument list +sall ; open a window for each file in argument list +sandbox ; execute a command in the sandbox +sargument ; split window and go to specific file in argument list +saveas ; save file under another name. +sbNext ; split window and go to previous file in the buffer list +sball ; open a window for each file in the buffer list +sbfirst ; split window and go to first file in the buffer list +sblast ; split window and go to last file in buffer list +sbmodified ; split window and go to modified file in the buffer list +sbnext ; split window and go to next file in the buffer list +sbprevious ; split window and go to previous file in the buffer list +sbrewind ; split window and go to first file in the buffer list +sbuffer ; split window and go to specific file in the buffer list +scriptencoding ; encoding used in sourced Vim script +scriptnames ; list names of all sourced Vim scripts +scscope ; split window and execute cscope command +set ; show or set options +setfiletype ; set 'filetype', unless it was set already +setglobal ; show global values of options +setlocal ; show or set options locally +sfind ; split current window and edit file in 'path' +sfirst ; split window and go to first file in the argument list +shell ; escape to a shell +sign ; manipulate signs +silent ; run a command silently +simalt ; Win32 GUI simulate Windows ALT key +slast ; split window and go to last file in the argument list +sleep ; do nothing for a few seconds +smagic ; substitute with 'magic' +smap ; like "map" but for Select mode +smapclear ; remove all mappings for Select mode +smenu ; add menu for Select mode +snext ; split window and go to next file in the argument list +sniff ; send request to sniff +snomagic ; substitute with 'nomagic' +snoremap ; like "noremap" but for Select mode +snoremenu ; like "noremenu" but for Select mode +sort ; sort lines +source ; read Vim or Ex commands from a file +spelldump ; split window and fill with all correct words +spellgood ; add good word for spelling +spellinfo ; show info about loaded spell files +spellrepall ; replace all bad words like last z= +spellundo ; remove good or bad word +spellwrong ; add spelling mistake +split ; split current window +sprevious ; split window and go to previous file in the argument list +srewind ; split window and go to first file in the argument list +stag ; split window and jump to a tag +startgreplace ; start Virtual Replace mode +startinsert ; start Insert mode +startreplace ; start Replace mode +stjump ; do "tjump" and split window +stop ; suspend the editor or escape to a shell +stopinsert ; stop Insert mode +stselect ; do "tselect" and split window +substitute ; find and replace text +sunhide ; same as "unhide" +sunmap ; like "unmap" but for Select mode +sunmenu ; remove menu for Select mode +suspend ; same as "stop" +sview ; split window and edit file read-only +swapname ; show the name of the current swap file +syncbind ; sync scroll binding +syntax ; syntax highlighting +tNext ; jump to previous matching tag +tab ; create new tab when opening new window +tabNext ; go to previous tab page +tabclose ; close current tab page +tabdo ; execute command in each tab page +tabedit ; edit a file in a new tab page +tabfind ; find file in 'path', edit it in a new tab page +tabfirst ; got to first tab page +tablast ; got to last tab page +tabmove ; move tab page to other position +tabnew ; edit a file in a new tab page +tabnext ; go to next tab page +tabonly ; close all tab pages except the current one +tabprevious ; go to previous tab page +tabrewind ; got to first tab page +tabs ; list the tab pages and what they contain +tag ; jump to tag +tags ; show the contents of the tag stack +tcl ; execute Tcl command +tcldo ; execute Tcl command for each line +tclfile ; execute Tcl script file +tearoff ; tear-off a menu +tfirst ; jump to first matching tag +throw ; throw an exception +tjump ; like "tselect", but jump directly when there is only one match +tlast ; jump to last matching tag +tmenu ; define menu tooltip +tnext ; jump to next matching tag +topleft ; make split window appear at top or far left +tprevious ; jump to previous matching tag +trewind ; jump to first matching tag +try ; execute commands, abort on error or exception +tselect ; list matching tags and select one +tunmenu ; remove menu tooltip +unabbreviate ; remove abbreviation +undo ; undo last change(s) +undojoin ; join next change with previous undo block +undolist ; list leafs of the undo tree +unhide ; open a window for each loaded file in the buffer list +unlet ; delete variable +unlockvar ; unlock variables +unmap ; remove mapping +unmenu ; remove menu +unsilent ; run a command not silently +update ; write buffer if modified +verbose ; execute command with 'verbose' set +version ; print version number and other info +vertical ; make following command split vertically +vglobal ; execute commands for not matching lines +view ; edit a file read-only +vimgrep ; search for pattern in files +vimgrepadd ; like vimgrep, but append to current list +visual ; same as "edit", but turns off "Ex" mode +viusage ; overview of Normal mode commands +vmap ; like "map" but for Visual+Select mode +vmapclear ; remove all mappings for Visual+Select mode +vmenu ; add menu for Visual+Select mode +vnew ; create a new empty window, vertically split +vnoremap ; like "noremap" but for Visual+Select mode +vnoremenu ; like "noremenu" but for Visual+Select mode +vsplit ; split current window vertically +vunmap ; like "unmap" but for Visual+Select mode +vunmenu ; remove menu for Visual+Select mode +wNext ; write to a file and go to previous file in argument list +wall ; write all (changed) buffers +while ; execute loop for as long as condition met +wincmd ; execute a Window (CTRL-W) command +windo ; execute command in each window +winpos ; get or set window position +winsize ; get or set window size (obsolete) +wnext ; write to a file and go to next file in argument list +wprevious ; write to a file and go to previous file in argument list +wqall ; write all changed buffers and quit Vim +write ; write to a file +wsverb ; pass the verb to workshop over IPC +wviminfo ; write to viminfo file +xall ; same as "wqall" +xit ; write if buffer changed and quit window or Vim +xmap ; like "map" but for Visual mode +xmapclear ; remove all mappings for Visual mode +xmenu ; add menu for Visual mode +xnoremap ; like "noremap" but for Visual mode +xnoremenu ; like "noremenu" but for Visual mode +xunmap ; like "unmap" but for Visual mode +xunmenu ; remove menu for Visual mode +yank ; yank lines into a register diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/features.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/features.dict new file mode 100644 index 0000000..d76359e --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/features.dict @@ -0,0 +1,153 @@ +all_builtin_terms ; Compiled with all builtin terminals enabled. +amiga ; Amiga version of Vim. +arabic ; Compiled with Arabic support |Arabic|. +arp ; Compiled with ARP support (Amiga). +autocmd ; Compiled with autocommand support. |autocommand| +balloon_eval ; Compiled with |balloon-eval| support. +balloon_multiline ; GUI supports multiline balloons. +beos ; BeOS version of Vim. +browse ; Compiled with |:browse| support, and browse() will work. +builtin_terms ; Compiled with some builtin terminals. +byte_offset ; Compiled with support for 'o' in 'statusline' +cindent ; Compiled with 'cindent' support. +clientserver ; Compiled with remote invocation support |clientserver|. +clipboard ; Compiled with 'clipboard' support. +cmdline_compl ; Compiled with |cmdline-completion| support. +cmdline_hist ; Compiled with |cmdline-history| support. +cmdline_info ; Compiled with 'showcmd' and 'ruler' support. +comments ; Compiled with |'comments'| support. +compatible ; Compiled to be very Vi compatible. +cryptv ; Compiled with encryption support |encryption|. +cscope ; Compiled with |cscope| support. +debug ; Compiled with "DEBUG" defined. +dialog_con ; Compiled with console dialog support. +dialog_gui ; Compiled with GUI dialog support. +diff ; Compiled with |vimdiff| and 'diff' support. +digraphs ; Compiled with support for digraphs. +dnd ; Compiled with support for the "~ register |quote_~|. +dos16 ; 16 bits DOS version of Vim. +dos32 ; 32 bits DOS (DJGPP) version of Vim. +ebcdic ; Compiled on a machine with ebcdic character set. +emacs_tags ; Compiled with support for Emacs tags. +eval ; Compiled with expression evaluation support. Always true, of course! +ex_extra ; Compiled with extra Ex commands |+ex_extra|. +extra_search ; Compiled with support for |'incsearch'| and |'hlsearch'| +farsi ; Compiled with Farsi support |farsi|. +file_in_path ; Compiled with support for |gf| and || +filterpipe ; When 'shelltemp' is off pipes are used for shell read/write/filter commands +find_in_path ; Compiled with support for include file searches |+find_in_path|. +float ; Compiled with support for |Float|. +fname_case ; Case in file names matters (for Amiga, MS-DOS, and Windows this is not present). +folding ; Compiled with |folding| support. +footer ; Compiled with GUI footer support. |gui-footer| +fork ; Compiled to use fork()/exec() instead of system(). +gettext ; Compiled with message translation |multi-lang| +gui ; Compiled with GUI enabled. +gui_athena ; Compiled with Athena GUI. +gui_gnome ; Compiled with Gnome support (gui_gtk is also defined). +gui_gtk ; Compiled with GTK+ GUI (any version). +gui_gtk2 ; Compiled with GTK+ 2 GUI (gui_gtk is also defined). +gui_mac ; Compiled with Macintosh GUI. +gui_motif ; Compiled with Motif GUI. +gui_photon ; Compiled with Photon GUI. +gui_running ; Vim is running in the GUI, or it will start soon. +gui_win32 ; Compiled with MS Windows Win32 GUI. +gui_win32s ; idem, and Win32s system being used (Windows 3.1) +hangul_input ; Compiled with Hangul input support. |hangul| +iconv ; Can use iconv() for conversion. +insert_expand ; Compiled with support for CTRL-X expansion commands in Insert mode. +jumplist ; Compiled with |jumplist| support. +keymap ; Compiled with 'keymap' support. +langmap ; Compiled with 'langmap' support. +libcall ; Compiled with |libcall()| support. +linebreak ; Compiled with 'linebreak', 'breakat' and 'showbreak' support. +lispindent ; Compiled with support for lisp indenting. +listcmds ; Compiled with commands for the buffer list |:files| and the argument list |arglist|. +localmap ; Compiled with local mappings and abbr. |:map-local| +lua ; Compiled with Lua interface |Lua|. +mac ; Macintosh version of Vim. +macunix ; Macintosh version of Vim, using Unix files (OS-X). +menu ; Compiled with support for |:menu|. +mksession ; Compiled with support for |:mksession|. +modify_fname ; Compiled with file name modifiers. |filename-modifiers| +mouse ; Compiled with support mouse. +mouse_dec ; Compiled with support for Dec terminal mouse. +mouse_gpm ; Compiled with support for gpm (Linux console mouse) +mouse_netterm ; Compiled with support for netterm mouse. +mouse_pterm ; Compiled with support for qnx pterm mouse. +mouse_sysmouse ; Compiled with support for sysmouse (*BSD console mouse) +mouse_xterm ; Compiled with support for xterm mouse. +mouseshape ; Compiled with support for 'mouseshape'. +multi_byte ; Compiled with support for 'encoding' +multi_byte_encoding ; 'encoding' is set to a multi-byte encoding. +multi_byte_ime ; Compiled with support for IME input method. +multi_lang ; Compiled with support for multiple languages. +mzscheme ; Compiled with MzScheme interface |mzscheme|. +netbeans_enabled ; Compiled with support for |netbeans| and it's used. +netbeans_intg ; Compiled with support for |netbeans|. +ole ; Compiled with OLE automation support for Win32. +os2 ; OS/2 version of Vim. +osfiletype ; Compiled with support for osfiletypes |+osfiletype| +path_extra ; Compiled with up/downwards search in 'path' and 'tags' +perl ; Compiled with Perl interface. +persistent_undo ; Compiled with support for persistent undo history. +postscript ; Compiled with PostScript file printing. +printer ; Compiled with |:hardcopy| support. +profile ; Compiled with |:profile| support. +python ; Compiled with Python interface. +python3 ; Compiled with Python3 interface. +qnx ; QNX version of Vim. +quickfix ; Compiled with |quickfix| support. +reltime ; Compiled with |reltime()| support. +rightleft ; Compiled with 'rightleft' support. +ruby ; Compiled with Ruby interface |ruby|. +scrollbind ; Compiled with 'scrollbind' support. +showcmd ; Compiled with 'showcmd' support. +signs ; Compiled with |:sign| support. +smartindent ; Compiled with 'smartindent' support. +sniff ; Compiled with SNiFF interface support. +spell ; Compiled with spell checking support |spell|. +statusline ; Compiled with |--startuptime| support. +sun_workshop ; Compiled with support for Sun |workshop|. +syntax ; Compiled with syntax highlighting support |syntax|. +syntax_items ; There are active syntax highlighting items for the current buffer. +system ; Compiled to use system() instead of fork()/exec(). +tag_any_white ; Compiled with support for any white characters in tags files |tag-any-white|. +tag_binary ; Compiled with binary searching in tags files |tag-binary-search|. +tag_old_static ; Compiled with support for old static tags |tag-old-static|. +tcl ; Compiled with Tcl interface. +terminfo ; Compiled with terminfo instead of termcap. +termresponse ; Compiled with support for |t_RV| and |v:termresponse|. +textobjects ; Compiled with support for |text-objects|. +tgetent ; Compiled with tgetent support, able to use a termcap or terminfo file. +title ; Compiled with window title support |'title'|. +toolbar ; Compiled with support for |gui-toolbar|. +unix ; Unix version of Vim. +unnamedplus ; Usable '+' register instead of '*' register. +user_commands ; User-defined commands. +vertsplit ; Compiled with vertically split windows |:vsplit|. +vim_starting ; True while initial source'ing takes place. +viminfo ; Compiled with viminfo support. +virtualedit ; Compiled with 'virtualedit' option. +visual ; Compiled with Visual mode. +visualextra ; Compiled with extra Visual mode commands. +vms ; VMS version of Vim. +vreplace ; Compiled with |gR| and |gr| commands. +wildignore ; Compiled with 'wildignore' option. +wildmenu ; Compiled with 'wildmenu' option. +win16 ; Win16 version of Vim (MS-Windows 3.1). +win32 ; Win32 version of Vim (MS-Windows 95/98/ME/NT/2000/XP). +win32unix ; Win32 version of Vim, using Unix files (Cygwin) +win64 ; Win64 version of Vim (MS-Windows 64 bit). +win95 ; Win32 version for MS-Windows 95/98/ME. +winaltkeys ; Compiled with 'winaltkeys' option. +windows ; Compiled with support for more than one window. +writebackup ; Compiled with 'writebackup' default on. +x11 ; Compiled with X11 support. +xfontset ; Compiled with X fontset support |xfontset|. +xim ; Compiled with X input method support |xim|. +xpm_w32 ; Compiled with pixmap support for Win32. +xsmp ; Compiled with X session management support. +xsmp_interact ; Compiled with interactive X session management support. +xterm_clipboard ; Compiled with support for xterm clipboard. +xterm_save ; Compiled with support for saving and restoring the xterm screen. diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/functions.dict b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/functions.dict new file mode 100644 index 0000000..3a3d798 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/functions.dict @@ -0,0 +1,252 @@ +abs({expr}) +acos({expr}) +add({list}, {item}) +append({lnum}, {list}) +append({lnum}, {string}) +argc() +argidx() +argv() +argv({nr}) +asin({expr}) +atan({expr}) +atan2({expr1}, {expr2}) +browse({save}, {title}, {initdir}, {default}) +browsedir({title}, {initdir}) +bufexists({expr}) +buflisted({expr}) +bufloaded({expr}) +bufname({expr}) +bufnr({expr}) +bufwinnr({expr}) +byte2line({byte}) +byteidx({expr}, {nr}) +call({func}, {arglist} [, {dict}]) +ceil({expr}) +changenr() +char2nr({expr}) +cindent({lnum}) +clearmatches() +col({expr}) +complete({startcol}, {matches}) +complete_add({expr}) +complete_check() +confirm({msg} [, {choices} [, {default} [, {type}]]]) +copy({expr}) +cos({expr}) +cosh({expr}) +count({list}, {expr} [, {start} [, {ic}]]) +cscope_connection([{num} , {dbpath} [, {prepend}]]) +cursor({list}) +cursor({lnum}, {col} [, {coladd}]) +deepcopy({expr}) +delete({fname}) +did_filetype() +diff_filler({lnum}) +diff_hlID({lnum}, {col}) +empty({expr}) +escape({string}, {chars}) +eval({string}) +eventhandler() +executable({expr}) +exists({expr}) +exp({expr}) +expand({expr} [, {flag}]) +extend({expr1}, {expr2} [, {expr3}]) +feedkeys({string} [, {mode}]) +filereadable({file}) +filewritable({file}) +filter({expr}, {string}) +finddir({name}[, {path}[, {count}]]) +findfile({name}[, {path}[, {count}]]) +float2nr({expr}) +floor({expr}) +fmod({expr1}, {expr2}) +fnameescape({fname}) +fnamemodify({fname}, {mods}) +foldclosed({lnum}) +foldclosedend({lnum}) +foldlevel({lnum}) +foldtext() +foldtextresult({lnum}) +foreground() +function({name}) +garbagecollect([at_exit]) +get({dict}, {key} [, {def}]) +get({list}, {idx} [, {def}]) +getbufline({expr}, {lnum} [, {end}]) +getbufvar({expr}, {varname}) +getchar([expr]) +getcharmod() +getcmdline() +getcmdpos() +getcmdtype() +getcwd() +getfontname([{name}]) +getfperm({fname}) +getfsize({fname}) +getftime({fname}) +getftype({fname}) +getline({lnum}) +getline({lnum}, {end}) +getloclist({nr}) +getmatches() +getpid() +getpos({expr}) +getqflist() +getreg([{regname} [, 1]]) +getregtype([{regname}]) +gettabvar({tabnr}, {varname}) +gettabwinvar({tabnr}, {winnr}, {name}) +getwinposx() +getwinposy() +getwinvar({nr}, {varname}) +glob({expr} [, {flag}]) +globpath({path}, {expr} [, {flag}]) +has({feature}) +has_key({dict}, {key}) +haslocaldir() +hasmapto({what} [, {mode} [, {abbr}]]) +histadd({history},{item}) +histdel({history} [, {item}]) +histget({history} [, {index}]) +histnr({history}) +hlID({name}) +hlexists({name}) +hostname() +iconv({expr}, {from}, {to}) +indent({lnum}) +index({list}, {expr} [, {start} [, {ic}]]) +input({prompt} [, {text} [, {completion}]]) +inputdialog({p} [, {t} [, {c}]]) +inputlist({textlist}) +inputrestore() +inputsave() +inputsecret({prompt} [, {text}]) +insert({list}, {item} [, {idx}]) +isdirectory({directory}) +islocked({expr}) +items({dict}) +join({list} [, {sep}]) +keys({dict}) +len({expr}) +libcall({lib}, {func}, {arg}) +libcallnr({lib}, {func}, {arg}) +line({expr}) +line2byte({lnum}) +lispindent({lnum}) +localtime() +log({expr}) +log10({expr}) +map({expr}, {string}) +maparg({name}[, {mode} [, {abbr}]]) +mapcheck({name}[, {mode} [, {abbr}]]) +match({expr}, {pat}[, {start}[, {count}]]) +matchadd({group}, {pattern}[, {priority}[, {id}]]) +matcharg({nr}) +matchdelete({id}) +matchend({expr}, {pat}[, {start}[, {count}]]) +matchlist({expr}, {pat}[, {start}[, {count}]]) +matchstr({expr}, {pat}[, {start}[, {count}]]) +max({list}) +min({list}) +mkdir({name} [, {path} [, {prot}]]) +mode([expr]) +nextnonblank({lnum}) +nr2char({expr}) +pathshorten({expr}) +pow({x}, {y}) +prevnonblank({lnum}) +printf({fmt}, {expr1}...) +pumvisible() +range({expr} [, {max} [, {stride}]]) +readfile({fname} [, {binary} [, {max}]]) +reltime([{start} [, {end}]]) +reltimestr({time}) +remote_expr({server}, {string} [, {idvar}]) +remote_foreground({server}) +remote_peek({serverid} [, {retvar}]) +remote_read({serverid}) +remote_send({server}, {string} [, {idvar}]) +remove({dict}, {key}) +remove({list}, {idx} [, {end}]) +rename({from}, {to}) +repeat({expr}, {count}) +resolve({filename}) +reverse({list}) +round({expr}) +search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) +searchdecl({name} [, {global} [, {thisblock}]]) +searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) +searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) +searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) +server2client({clientid}, {string}) +serverlist() +setbufvar({expr}, {varname}, {val}) +setcmdpos({pos}) +setline({lnum}, {line}) +setloclist({nr}, {list}[, {action}]) +setmatches({list}) +setpos({expr}, {list}) +setqflist({list}[, {action}]) +setreg({n}, {v}[, {opt}]) +settabvar({tabnr}, {varname}, {val}) +settabwinvar({tabnr}, {winnr}, {varname}, {val}) +setwinvar({nr}, {varname}, {val}) +shellescape({string} [, {special}]) +simplify({filename}) +sin({expr}) +sinh({expr}) +sort({list} [, {func}]) +soundfold({word}) +spellbadword() +spellsuggest({word} [, {max} [, {capital}]]) +split({expr} [, {pat} [, {keepempty}]]) +sqrt({expr}) +str2float({expr}) +str2nr({expr} [, {base}]) +strchars({expr}) +strdisplaywidth({expr}[, {col}]) +strftime({format}[, {time}]) +stridx({haystack}, {needle}[, {start}]) +string({expr}) +strlen({expr}) +strpart({src}, {start}[, {len}]) +strridx({haystack}, {needle} [, {start}]) +strtrans({expr}) +strwidth({expr}) +submatch({nr}) +substitute({expr}, {pat}, {sub}, {flags}) +synID({lnum}, {col}, {trans}) +synIDattr({synID}, {what} [, {mode}]) +synIDtrans({synID}) +synconcealed({lnum}, {col}) +synstack({lnum}, {col}) +system({expr} [, {input}]) +tabpagebuflist([{arg}]) +tabpagenr([{arg}]) +tabpagewinnr({tabarg}[, {arg}]) +tagfiles() +taglist({expr}) +tan({expr}) +tanh({expr}) +tempname() +tolower({expr}) +toupper({expr}) +tr({src}, {fromstr}, {tostr}) +trunc({expr} +type({name}) +undofile({name}) +undotree() +values({dict}) +virtcol({expr}) +visualmode([expr]) +winbufnr({nr}) +wincol() +winheight({nr}) +winline() +winnr([{expr}]) +winrestcmd() +winrestview({dict}) +winsaveview() +winwidth({nr}) +writefile({list}, {fname} [, {binary}]) diff --git a/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/helper.vim b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/helper.vim new file mode 100644 index 0000000..9cd4cb3 --- /dev/null +++ b/vim/bundle/neocomplcache/autoload/neocomplcache/sources/vim_complete/helper.vim @@ -0,0 +1,964 @@ +"============================================================================= +" FILE: helper.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Apr 2013. +" 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:save_cpo = &cpo +set cpo&vim + +if !exists('s:internal_candidates_list') + let s:internal_candidates_list = {} + let s:global_candidates_list = { 'dictionary_variables' : {} } + let s:script_candidates_list = {} + let s:local_candidates_list = {} +endif + +function! neocomplcache#sources#vim_complete#helper#on_filetype() "{{{ + " Caching script candidates. + let bufnumber = 1 + + " Check buffer. + while bufnumber <= bufnr('$') + if getbufvar(bufnumber, '&filetype') == 'vim' && bufloaded(bufnumber) + \&& !has_key(s:script_candidates_list, bufnumber) + let s:script_candidates_list[bufnumber] = s:get_script_candidates(bufnumber) + endif + + let bufnumber += 1 + endwhile + + if neocomplcache#exists_echodoc() + call echodoc#register('vim_complete', s:doc_dict) + endif +endfunction"}}} + +function! neocomplcache#sources#vim_complete#helper#recaching(bufname) "{{{ + " Caching script candidates. + let bufnumber = a:bufname != '' ? bufnr(a:bufname) : bufnr('%') + + if getbufvar(bufnumber, '&filetype') == 'vim' && bufloaded(bufnumber) + let s:script_candidates_list[bufnumber] = s:get_script_candidates(bufnumber) + endif + let s:global_candidates_list = { 'dictionary_variables' : {} } +endfunction"}}} + +" For echodoc. "{{{ +let s:doc_dict = { + \ 'name' : 'vim_complete', + \ 'rank' : 10, + \ 'filetypes' : { 'vim' : 1 }, + \ } +function! s:doc_dict.search(cur_text) "{{{ + let cur_text = a:cur_text + + " Echo prototype. + let script_candidates_list = s:get_cached_script_candidates() + + let prototype_name = matchstr(cur_text, + \'\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\s*(\ze\%([^(]\|(.\{-})\)*$') + let ret = [] + if prototype_name != '' + if !has_key(s:internal_candidates_list, 'function_prototypes') + " No cache. + return [] + endif + + " Search function name. + call add(ret, { 'text' : prototype_name, 'highlight' : 'Identifier' }) + if has_key(s:internal_candidates_list.function_prototypes, prototype_name) + call add(ret, { 'text' : s:internal_candidates_list.function_prototypes[prototype_name] }) + elseif has_key(s:global_candidates_list.function_prototypes, prototype_name) + call add(ret, { 'text' : s:global_candidates_list.function_prototypes[prototype_name] }) + elseif has_key(script_candidates_list.function_prototypes, prototype_name) + call add(ret, { 'text' : script_candidates_list.function_prototypes[prototype_name] }) + else + " No prototypes. + return [] + endif + else + if !has_key(s:internal_candidates_list, 'command_prototypes') + " No cache. + return [] + endif + + " Search command name. + " Skip head digits. + let prototype_name = neocomplcache#sources#vim_complete#get_command(cur_text) + call add(ret, { 'text' : prototype_name, 'highlight' : 'Statement' }) + if has_key(s:internal_candidates_list.command_prototypes, prototype_name) + call add(ret, { 'text' : s:internal_candidates_list.command_prototypes[prototype_name] }) + elseif has_key(s:global_candidates_list.command_prototypes, prototype_name) + call add(ret, { 'text' : s:global_candidates_list.command_prototypes[prototype_name] }) + else + " No prototypes. + return [] + endif + endif + + return ret +endfunction"}}} +"}}} + +function! neocomplcache#sources#vim_complete#helper#get_command_completion(command_name, cur_text, complete_str) "{{{ + let completion_name = + \ neocomplcache#sources#vim_complete#helper#get_completion_name(a:command_name) + if completion_name == '' + " Not found. + return [] + endif + + let args = (completion_name ==# 'custom' || completion_name ==# 'customlist')? + \ [a:command_name, a:cur_text, a:complete_str] : [a:cur_text, a:complete_str] + return call('neocomplcache#sources#vim_complete#helper#'.completion_name, args) +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#get_completion_name(command_name) "{{{ + if !has_key(s:internal_candidates_list, 'command_completions') + let s:internal_candidates_list.command_completions = + \ s:caching_completion_from_dict('command_completions') + endif + if !has_key(s:global_candidates_list, 'command_completions') + let s:global_candidates_list.commands = + \ neocomplcache#pack_dictionary(s:get_cmdlist()) + endif + + if has_key(s:internal_candidates_list.command_completions, a:command_name) + \&& exists('*neocomplcache#sources#vim_complete#helper#' + \ .s:internal_candidates_list.command_completions[a:command_name]) + return s:internal_candidates_list.command_completions[a:command_name] + elseif has_key(s:global_candidates_list.command_completions, a:command_name) + \&& exists('*neocomplcache#sources#vim_complete#helper#' + \ .s:global_candidates_list.command_completions[a:command_name]) + return s:global_candidates_list.command_completions[a:command_name] + else + return '' + endif +endfunction"}}} + +function! neocomplcache#sources#vim_complete#helper#autocmd_args(cur_text, complete_str) "{{{ + let args = s:split_args(a:cur_text, a:complete_str) + if len(args) < 2 + return [] + endif + + " Caching. + if !has_key(s:global_candidates_list, 'augroups') + let s:global_candidates_list.augroups = s:get_augrouplist() + endif + if !has_key(s:internal_candidates_list, 'autocmds') + let s:internal_candidates_list.autocmds = s:caching_from_dict('autocmds', '') + endif + + let list = [] + if len(args) == 2 + let list += s:global_candidates_list.augroups + s:internal_candidates_list.autocmds + elseif len(args) == 3 + if args[1] ==# 'FileType' + " Filetype completion. + let list += neocomplcache#sources#vim_complete#helper#filetype(a:cur_text, a:complete_str) + endif + + let list += s:internal_candidates_list.autocmds + elseif len(args) == 4 + if args[2] ==# 'FileType' + " Filetype completion. + let list += neocomplcache#sources#vim_complete#helper#filetype( + \ a:cur_text, a:complete_str) + endif + + let list += neocomplcache#sources#vim_complete#helper#command( + \ args[3], a:complete_str) + let list += s:make_completion_list(['nested'], '') + else + let command = args[3] =~ '^*' ? + \ join(args[4:]) : join(args[3:]) + let list += neocomplcache#sources#vim_complete#helper#command( + \ command, a:complete_str) + let list += s:make_completion_list(['nested'], '') + endif + + return list +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#augroup(cur_text, complete_str) "{{{ + " Caching. + if !has_key(s:global_candidates_list, 'augroups') + let s:global_candidates_list.augroups = s:get_augrouplist() + endif + + return s:global_candidates_list.augroups +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#buffer(cur_text, complete_str) "{{{ + return [] +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#colorscheme_args(cur_text, complete_str) "{{{ + return s:make_completion_list(filter(map(split( + \ globpath(&runtimepath, 'colors/*.vim'), '\n'), + \ 'fnamemodify(v:val, ":t:r")'), + \ 'stridx(v:val, a:complete_str) == 0'), '') +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#command(cur_text, complete_str) "{{{ + if a:cur_text == '' || + \ a:cur_text =~ '^[[:digit:],[:space:][:tab:]$''<>]*\h\w*$' + " Commands. + + " Caching. + if !has_key(s:global_candidates_list, 'commands') + let s:global_candidates_list.commands = + \ neocomplcache#pack_dictionary(s:get_cmdlist()) + endif + if !has_key(s:internal_candidates_list, 'commands') + let s:internal_candidates_list.command_prototypes = + \ s:caching_prototype_from_dict('command_prototypes') + let commands = s:caching_from_dict('commands', 'c') + for command in commands + if has_key(s:internal_candidates_list.command_prototypes, command.word) + let command.description = command.word . + \ s:internal_candidates_list.command_prototypes[command.word] + endif + endfor + + let s:internal_candidates_list.commands = + \ neocomplcache#pack_dictionary(commands) + endif + + " echomsg string(s:internal_candidates_list.commands)[: 1000] + " echomsg string(s:global_candidates_list.commands)[: 1000] + let list = neocomplcache#dictionary_filter( + \ s:internal_candidates_list.commands, a:complete_str) + \ + neocomplcache#dictionary_filter( + \ s:global_candidates_list.commands, a:complete_str) + else + " Commands args. + let command = neocomplcache#sources#vim_complete#get_command(a:cur_text) + let completion_name = + \ neocomplcache#sources#vim_complete#helper#get_completion_name(command) + + " Prevent infinite loop. + let cur_text = completion_name ==# 'command' ? + \ a:cur_text[len(command):] : a:cur_text + + let list = neocomplcache#sources#vim_complete#helper#get_command_completion( + \ command, cur_text, a:complete_str) + + if a:cur_text =~ + \'[[(,{]\|`=[^`]*$' + " Expression. + let list += neocomplcache#sources#vim_complete#helper#expression( + \ a:cur_text, a:complete_str) + endif + endif + + return list +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#command_args(cur_text, complete_str) "{{{ + " Caching. + if !has_key(s:internal_candidates_list, 'command_args') + let s:internal_candidates_list.command_args = + \ s:caching_from_dict('command_args', '') + let s:internal_candidates_list.command_replaces = + \ s:caching_from_dict('command_replaces', '') + endif + + return s:internal_candidates_list.command_args + + \ s:internal_candidates_list.command_replaces +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#custom(command_name, cur_text, complete_str) "{{{ + if !has_key(g:neocomplcache_vim_completefuncs, a:command_name) + return [] + endif + + return s:make_completion_list(split( + \ call(g:neocomplcache_vim_completefuncs[a:command_name], + \ [a:complete_str, getline('.'), len(a:cur_text)]), '\n'), '') +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#customlist(command_name, cur_text, complete_str) "{{{ + if !has_key(g:neocomplcache_vim_completefuncs, a:command_name) + return [] + endif + + return s:make_completion_list( + \ call(g:neocomplcache_vim_completefuncs[a:command_name], + \ [a:complete_str, getline('.'), len(a:cur_text)]), '') +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#dir(cur_text, complete_str) "{{{ + return filter(neocomplcache#sources#filename_complete#get_complete_words( + \ a:complete_str, '.'), 'isdirectory(v:val.word)') +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#environment(cur_text, complete_str) "{{{ + " Caching. + if !has_key(s:global_candidates_list, 'environments') + let s:global_candidates_list.environments = s:get_envlist() + endif + + return s:global_candidates_list.environments +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#event(cur_text, complete_str) "{{{ + return [] +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#execute(cur_text, complete_str) "{{{ + if a:cur_text =~ '["''][^"'']*$' + let command = matchstr(a:cur_text, '["'']\zs[^"'']*$') + return neocomplcache#sources#vim_complete#helper#command(command, a:complete_str) + else + return neocomplcache#sources#vim_complete#helper#expression(a:cur_text, a:complete_str) + endif +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#expression(cur_text, complete_str) "{{{ + return neocomplcache#sources#vim_complete#helper#function(a:cur_text, a:complete_str) + \+ neocomplcache#sources#vim_complete#helper#var(a:cur_text, a:complete_str) +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#feature(cur_text, complete_str) "{{{ + if !has_key(s:internal_candidates_list, 'features') + let s:internal_candidates_list.features = s:caching_from_dict('features', '') + endif + return s:internal_candidates_list.features +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#file(cur_text, complete_str) "{{{ + return neocomplcache#sources#filename_complete#get_complete_words( + \ a:complete_str, '.') +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#filetype(cur_text, complete_str) "{{{ + if !has_key(s:internal_candidates_list, 'filetypes') + let s:internal_candidates_list.filetypes = + \ neocomplcache#pack_dictionary(s:make_completion_list(map( + \ split(globpath(&runtimepath, 'syntax/*.vim'), '\n') + + \ split(globpath(&runtimepath, 'indent/*.vim'), '\n') + + \ split(globpath(&runtimepath, 'ftplugin/*.vim'), '\n') + \ , "matchstr(fnamemodify(v:val, ':t:r'), '^[[:alnum:]-]*')"), '')) + endif + + return neocomplcache#dictionary_filter( + \ s:internal_candidates_list.filetypes, a:complete_str) +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#function(cur_text, complete_str) "{{{ + " Caching. + if !has_key(s:global_candidates_list, 'functions') + let s:global_candidates_list.functions = + \ neocomplcache#pack_dictionary(s:get_functionlist()) + endif + if !has_key(s:internal_candidates_list, 'functions') + let s:internal_candidates_list.function_prototypes = + \ s:caching_prototype_from_dict('functions') + + let functions = s:caching_from_dict('functions', 'f') + for function in functions + if has_key(s:internal_candidates_list.function_prototypes, function.word) + let function.description = function.word + \ . s:internal_candidates_list.function_prototypes[function.word] + endif + endfor + + let s:internal_candidates_list.functions = + \ neocomplcache#pack_dictionary(functions) + endif + + let script_candidates_list = s:get_cached_script_candidates() + if a:complete_str =~ '^s:' + let list = values(script_candidates_list.functions) + elseif a:complete_str =~ '^\a:' + let functions = deepcopy(values(script_candidates_list.functions)) + for keyword in functions + let keyword.word = '' . keyword.word[2:] + let keyword.abbr = '' . keyword.abbr[2:] + endfor + let list = functions + else + let list = neocomplcache#dictionary_filter( + \ s:internal_candidates_list.functions, a:complete_str) + \ + neocomplcache#dictionary_filter( + \ s:global_candidates_list.functions, a:complete_str) + endif + + return list +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#help(cur_text, complete_str) "{{{ + return [] +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#highlight(cur_text, complete_str) "{{{ + return [] +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#let(cur_text, complete_str) "{{{ + if a:cur_text !~ '=' + return neocomplcache#sources#vim_complete#helper#var(a:cur_text, a:complete_str) + elseif a:cur_text =~# '\' + let list += neocomplcache#sources#vim_complete#helper#expression(a:cur_text, a:complete_str) + elseif a:cur_text =~ ':\?' + let command = matchstr(a:cur_text, ':\?\zs.*$') + let list += neocomplcache#sources#vim_complete#helper#command(command, a:complete_str) + endif + + return list +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#menu(cur_text, complete_str) "{{{ + return [] +endfunction"}}} +function! neocomplcache#sources#vim_complete#helper#option(cur_text, complete_str) "{{{ + " Caching. + if !has_key(s:internal_candidates_list, 'options') + let s:internal_candidates_list.options = s:caching_from_dict('options', 'o') + + for keyword in deepcopy(s:internal_candidates_list.options) + let keyword.word = 'no' . keyword.word + let keyword.abbr = 'no' . keyword.abbr + call add(s:internal_candidates_list.options, keyword) + endfor + endif + + if a:cur_text =~ '\', '', '', '', + \ '', '', '', ''], '') +endfunction"}}} + +function! s:get_local_variables() "{{{ + " Get local variable list. + + let keyword_dict = {} + " Search function. + let line_num = line('.') - 1 + let end_line = (line('.') > 100) ? line('.') - 100 : 1 + while line_num >= end_line + let line = getline(line_num) + if line =~ '\' + break + elseif line =~ '\ 700 ? + \ s:script_candidates_list[bufnr('%')] : { + \ 'functions' : {}, 'variables' : {}, 'function_prototypes' : {}, 'dictionary_variables' : {} } +endfunction"}}} +function! s:get_script_candidates(bufnumber) "{{{ + " Get script candidate list. + + let function_dict = {} + let variable_dict = {} + let dictionary_variable_dict = {} + let function_prototypes = {} + let var_pattern = '\a:[[:alnum:]_:]*\.\h\w*\%(()\?\)\?' + + for line in getbufline(a:bufnumber, 1, '$') + if line =~ '\\?\|\h[[:alnum:]_:#\[]*\%([!\]]\+\|()\?\)\?\)' + let keyword_list = [] + for line in readfile(dict_files[0]) + call add(keyword_list, { + \ 'word' : substitute(matchstr( + \ line, keyword_pattern), '[\[\]]', '', 'g'), + \ 'kind' : a:kind, 'abbr' : line + \}) + endfor + + return keyword_list +endfunction"}}} +function! s:caching_completion_from_dict(dict_name) "{{{ + let dict_files = split(globpath(&runtimepath, + \ 'autoload/neocomplcache/sources/vim_complete/'.a:dict_name.'.dict'), '\n') + if empty(dict_files) + return {} + endif + + let keyword_dict = {} + for line in readfile(dict_files[0]) + let word = matchstr(line, '^[[:alnum:]_\[\]]\+') + let completion = matchstr(line[len(word):], '\h\w*') + if completion != '' + if word =~ '\[' + let [word_head, word_tail] = split(word, '\[') + let word_tail = ' ' . substitute(word_tail, '\]', '', '') + else + let word_head = word + let word_tail = ' ' + endif + + for i in range(len(word_tail)) + let keyword_dict[word_head . word_tail[1:i]] = completion + endfor + endif + endfor + + return keyword_dict +endfunction"}}} +function! s:caching_prototype_from_dict(dict_name) "{{{ + let dict_files = split(globpath(&runtimepath, + \ 'autoload/neocomplcache/sources/vim_complete/'.a:dict_name.'.dict'), '\n') + if empty(dict_files) + return {} + endif + if a:dict_name == 'functions' + let pattern = '^[[:alnum:]_]\+(' + else + let pattern = '^[[:alnum:]_\[\](]\+' + endif + + let keyword_dict = {} + for line in readfile(dict_files[0]) + let word = matchstr(line, pattern) + let rest = line[len(word):] + if word =~ '\[' + let [word_head, word_tail] = split(word, '\[') + let word_tail = ' ' . substitute(word_tail, '\]', '', '') + else + let word_head = word + let word_tail = ' ' + endif + + for i in range(len(word_tail)) + let keyword_dict[word_head . word_tail[1:i]] = rest + endfor + endfor + + return keyword_dict +endfunction"}}} + +function! s:get_cmdlist() "{{{ + " Get command list. + redir => redir + silent! command + redir END + + let keyword_list = [] + let completions = [ 'augroup', 'buffer', 'behave', + \ 'color', 'command', 'compiler', 'cscope', + \ 'dir', 'environment', 'event', 'expression', + \ 'file', 'file_in_path', 'filetype', 'function', + \ 'help', 'highlight', 'history', 'locale', + \ 'mapping', 'menu', 'option', 'shellcmd', 'sign', + \ 'syntax', 'tag', 'tag_listfiles', + \ 'var', 'custom', 'customlist' ] + let command_prototypes = {} + let command_completions = {} + for line in split(redir, '\n')[1:] + let word = matchstr(line, '\a\w*') + + " Analyze prototype. + let end = matchend(line, '\a\w*') + let args = matchstr(line, '[[:digit:]?+*]', end) + if args != '0' + let prototype = matchstr(line, '\a\w*', end) + let found = 0 + for comp in completions + if comp == prototype + let command_completions[word] = prototype + let found = 1 + + break + endif + endfor + + if !found + let prototype = 'arg' + endif + + if args == '*' + let prototype = '[' . prototype . '] ...' + elseif args == '?' + let prototype = '[' . prototype . ']' + elseif args == '+' + let prototype = prototype . ' ...' + endif + + let command_prototypes[word] = ' ' . repeat(' ', 16 - len(word)) . prototype + else + let command_prototypes[word] = '' + endif + let prototype = command_prototypes[word] + + call add(keyword_list, { + \ 'word' : word, 'abbr' : word . prototype, + \ 'description' : word . prototype, 'kind' : 'c' + \}) + endfor + let s:global_candidates_list.command_prototypes = command_prototypes + let s:global_candidates_list.command_completions = command_completions + + return keyword_list +endfunction"}}} +function! s:get_variablelist(dict, prefix) "{{{ + let kind_dict = ['0', '""', '()', '[]', '{}', '.'] + return values(map(copy(a:dict), "{ + \ 'word' : a:prefix.v:key, + \ 'kind' : kind_dict[type(v:val)], + \}")) +endfunction"}}} +function! s:get_functionlist() "{{{ + " Get function list. + redir => redir + silent! function + redir END + + let keyword_dict = {} + let function_prototypes = {} + for line in split(redir, '\n') + let line = line[9:] + if line =~ '^' + continue + endif + let orig_line = line + + let word = matchstr(line, '\h[[:alnum:]_:#.]*()\?') + if word != '' + let keyword_dict[word] = { + \ 'word' : word, 'abbr' : line, + \ 'description' : line, + \} + + let function_prototypes[word] = orig_line[len(word):] + endif + endfor + + let s:global_candidates_list.function_prototypes = function_prototypes + + return values(keyword_dict) +endfunction"}}} +function! s:get_augrouplist() "{{{ + " Get augroup list. + redir => redir + silent! augroup + redir END + + let keyword_list = [] + for group in split(redir . ' END', '\s\|\n') + call add(keyword_list, { 'word' : group }) + endfor + return keyword_list +endfunction"}}} +function! s:get_mappinglist() "{{{ + " Get mapping list. + redir => redir + silent! map + redir END + + let keyword_list = [] + for line in split(redir, '\n') + let map = matchstr(line, '^\a*\s*\zs\S\+') + if map !~ '^<' || map =~ '^' + continue + endif + call add(keyword_list, { 'word' : map }) + endfor + return keyword_list +endfunction"}}} +function! s:get_envlist() "{{{ + " Get environment variable list. + + let keyword_list = [] + for line in split(system('set'), '\n') + let word = '$' . toupper(matchstr(line, '^\h\w*')) + call add(keyword_list, { 'word' : word, 'kind' : 'e' }) + endfor + return keyword_list +endfunction"}}} +function! s:make_completion_list(list, kind) "{{{ + let list = [] + for item in a:list + call add(list, { 'word' : item, 'kind' : a:kind }) + endfor + + return list +endfunction"}}} +function! s:analyze_function_line(line, keyword_dict, prototype) "{{{ + " Get script function. + let line = substitute(matchstr(a:line, '\ ; the mapping will be effective in the current buffer only + ; the argument is an expression evaluated to obtain the {rhs} that is used + ; define a mapping which uses the "mapleader" variable + ; just like , except that it uses "maplocalleader" instead of "mapleader" + ; used for an internal mapping, which is not to be matched with any key sequence + +< + At the line 1 and 3, neocomplcache#get_context_filetype() is + "html" and at the line 2 it's "javascript", whilst at any + lines &filetype is "html". + + *neocomplcache#disable_default_dictionary()* +neocomplcache#disable_default_dictionary({variable-name}) + Disable default {variable-name} dictionary initialization. + Note: It must be called in .vimrc. +> + call neocomplcache#disable_default_dictionary( + \ 'g:neocomplcache_same_filetype_lists') +< +------------------------------------------------------------------------------ +KEY MAPPINGS *neocomplcache-key-mappings* + + *neocomplcache#start_manual_complete()* +neocomplcache#start_manual_complete([{sources}]) + Use this function on inoremap . The keymapping call the + completion of neocomplcache. When you rearrange the completion + of the Vim standard, you use it. + If you give {sources} argument, neocomplcache call {sources}. + {sources} is name of source or list of sources name. +> + inoremap neocomplcache#start_manual_complete() +< + *neocomplcache#manual_filename_complete()* + *neocomplcache#manual_omni_complete()* + Note: These functions are obsolete. + + *neocomplcache#close_popup()* +neocomplcache#close_popup() + Inset candidate and close popup menu for neocomplcache. +> + inoremap neocomplcache#close_popup() +< + *neocomplcache#cancel_popup()* +neocomplcache#cancel_popup() + cancel completion menu for neocomplcache. +> + inoremap neocomplcache#cancel_popup() +< + *neocomplcache#smart_close_popup()* +neocomplcache#smart_close_popup() + Inset candidate and close popup menu for neocomplcache. + Unlike|neocomplcache#close_popup()|, this function changes + behavior by|g:neocomplcache_enable_auto_select|smart. + Note: This mapping is conflicted with |SuperTab| or |endwise| + plugins. + + *neocomplcache#undo_completion()* +neocomplcache#undo_completion() + Use this function on inoremap . Undo inputted + candidate. Because there is not mechanism to cancel + candidate in Vim, it will be convenient when it inflects. +> + inoremap neocomplcache#undo_completion() +< + *neocomplcache#complete_common_string()* +neocomplcache#complete_common_string() + Use this function on inoremap . Complete common + string in candidates. It will be convenient when candidates + have long common string. +> + inoremap neocomplcache#complete_common_string() +< + *(neocomplcache_start_unite_complete)* +(neocomplcache_start_unite_complete) + Start completion with |unite|. + Note: Required unite.vim Latest ver.3.0 or above. + Note: In unite interface, uses partial match instead of head + match. + + *(neocomplcache_start_quick_match)* +(neocomplcache_start_unite_quick_match) + Start completion with |unite| and start quick match mode. + Note: Required unite.vim Latest ver.3.0 or above. + +============================================================================== +EXAMPLES *neocomplcache-examples* +> + "Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! + " Disable AutoComplPop. + let g:acp_enableAtStartup = 0 + " Use neocomplcache. + let g:neocomplcache_enable_at_startup = 1 + " Use smartcase. + let g:neocomplcache_enable_smart_case = 1 + " Set minimum syntax keyword length. + let g:neocomplcache_min_syntax_length = 3 + let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' + + " Enable heavy features. + " Use camel case completion. + "let g:neocomplcache_enable_camel_case_completion = 1 + " Use underbar completion. + "let g:neocomplcache_enable_underbar_completion = 1 + + " Define dictionary. + let g:neocomplcache_dictionary_filetype_lists = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + + " Define keyword. + if !exists('g:neocomplcache_keyword_patterns') + let g:neocomplcache_keyword_patterns = {} + endif + let g:neocomplcache_keyword_patterns['default'] = '\h\w*' + + " Plugin key-mappings. + inoremap neocomplcache#undo_completion() + inoremap neocomplcache#complete_common_string() + + " Recommended key-mappings. + " : close popup and save indent. + inoremap =my_cr_function() + function! s:my_cr_function() + return neocomplcache#smart_close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplcache#close_popup() : "\" + endfunction + " : completion. + inoremap pumvisible() ? "\" : "\" + " , : close popup and delete backword char. + inoremap neocomplcache#smart_close_popup()."\" + inoremap neocomplcache#smart_close_popup()."\" + inoremap neocomplcache#close_popup() + inoremap neocomplcache#cancel_popup() + " Close popup by . + "inoremap pumvisible() ? neocomplcache#close_popup() : "\" + + " For cursor moving in insert mode(Not recommended) + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + " Or set this. + "let g:neocomplcache_enable_cursor_hold_i = 1 + " Or set this. + "let g:neocomplcache_enable_insert_char_pre = 1 + + " AutoComplPop like behavior. + "let g:neocomplcache_enable_auto_select = 1 + + " Shell like behavior(not recommended). + "set completeopt+=longest + "let g:neocomplcache_enable_auto_select = 1 + "let g:neocomplcache_disable_auto_complete = 1 + "inoremap pumvisible() ? "\" : "\\" + + " Enable omni completion. + autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS + autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags + autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS + autocmd FileType python setlocal omnifunc=pythoncomplete#Complete + autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags + + " Enable heavy omni completion. + if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} + endif + if !exists('g:neocomplcache_force_omni_patterns') + let g:neocomplcache_force_omni_patterns = {} + endif + let g:neocomplcache_omni_patterns.php = + \ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + let g:neocomplcache_omni_patterns.c = + \ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?' + let g:neocomplcache_omni_patterns.cpp = + \ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + + " For perlomni.vim setting. + " https://github.com/c9s/perlomni.vim + let g:neocomplcache_omni_patterns.perl = + \ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' +< +============================================================================== +SOURCES *neocomplcache-sources* + +Neocomplcache reads automatically sources saved in an +autoload/neocomplcache/sources directory. + +buffer_complete.vim *buffer_complete* + This source collects keywords from buffer. + +member_complete.vim *member_complete* + This source collects use of member variables from buffer. + +tags_complete.vim *tags_complete* + This source analyzes a tag file from tagfiles() for completion. + When a huge tag file (above + |g:neocomplcache_tags_caching_limit_file_size|) is set, + neocomplcache does not make cache if you do not execute + |:NeoComplCacheCachingTags|command. Because tags_complete is + too slow if tags_complete read a big tags file. You should use + more convenient include completion now. + +syntax_complete.vim *syntax_complete* + This source analyzes a syntax file like + autoload/syntaxcomplete.vim offered by default, and to + add to candidate completion. The plugin can recognize + candidates a lot more than autoload/syntaxcomplete.vim. + +include_complete.vim *include_complete* + This source will add the file which an opening buffer + refers to to candidate. It is convenient, because you do + not need to prepare a tags file and a dictionary file. + But it is necessary for 'path' and 'include', + 'includeexpr' to be set adequately. + + Note: If you have vimproc installed, neocomplcache will cache + automatically. Otherwise it won't; please execute + |:NeoComplCacheCachingInclude| manually. + +vim_complete.vim *vim_complete* + This source analyzes context and start Omni completion of + Vim script. This plugin does not work other than editing + time of Vim script. I created it because neocomplcache + cannot call |i_CTRL-X_CTRL-V|. Local variable and a + script variable, a function and the analysis of the + command are implemented now. + +dictionary_complete.vim *dictionary_complete* + This source adds candidates from 'dictionary' or + |g:neocomplcache_dictionary_filetype_lists|. + +filename_complete.vim *filename_complete* + This source collects filename candidates. + +filename_include.vim *filename_include* + This source collects filename candidates. It is useful + when you input header file name. It recognizes include + pattern and include path like include_complete. + +omni_complete.vim *omni_complete* + This source calls 'omnifunc' automatically when cursor + text is matched with |g:neocomplcache_omni_patterns|. If + |g:neocomplcache_omni_function_list|is defined, + neocomplcache will give priority it. + Note: This source is not supported wildcard. + + +suffix of complete candidates in popup menu declaration. +(This will be good for user to know where candidate from and what it is.) + + filename_complete -> [F] {filename} + filename_include -> [FI] {filename} + dictionary_complete -> [D] {words} + member_complete -> [M] member + buffer_complete -> [B] {buffername} + syntax_complete -> [S] {syntax-keyword} + include_complete -> [I] + neosnippet -> [neosnip] + vim_complete -> [vim] type + omni_complete -> [O] + tags_complete -> [T] + other plugin sources -> [plugin-name-prefix] + other completefunc sources -> [plugin-name-prefix] + other ftplugin sources -> [plugin-name-prefix] + +------------------------------------------------------------------------------ +USER SOURCES *neocomplcache-user-sources* + +This section, introduce non default neocomplcache sources. + +neosnippet *neocomplcache-sources-neosnippet* + This source is for snippets completion. + Note: This source is not in default sources after + neocomplcache ver.7.0. + https://github.com/Shougo/neosnippet + +neco-ghc *neocomplcache-sources-neco-ghc* + https://github.com/ujihisa/neco-ghc + eagletmt originally implemented and now ujihisa is maintaining + this source. It completes a source file written in Haskell. + It requires ghc-mod . + +============================================================================== +FILTERS *neocomplcache-filters* + +To custom candidates, neocomplcache uses the filters. There are three kinds of +filters are available. "matcher" is to use filter candidates. "sorter" is to +use sort candidates. "converter" is to use candidates conversion. + +Note: "matcher" is not implemented. It will implemented in ver.8.1. + +Default sources are below. But you can create original filters(cf: +|neocomplcache-create-filter|) and set them by +|neocomplcache#custom_source()|. +> + call unite#custom_source('buffer_complete', 'converters', []) + + " Change default sorter. + call unite#custom_source('_', 'sorters', + \ ['sorter_length']) +< + *neocomplcache-filter-sorter_default* +Default sorters: ['sorter_rank']. + + *neocomplcache-filter-converter_default* +Default converters: ['converter_remove_next_keyword', + \ 'converter_delimiter', 'converter_case', 'converter_abbr']. + + *neocomplcache-filter-sorter_nothing* +sorter_nothing Nothing sorter. + + *neocomplcache-filter-sorter_rank* +sorter_rank Matched rank order sorter. The higher the matched word is + already selected or in current buffer + + *neocomplcache-filter-sorter_length* +sorter_length Candidates length order sorter. + + *neocomplcache-filter-converter_nothing* +converter_nothing + This converter is dummy. + + *neocomplcache-filter-converter_abbr* +converter_abbr + The converter which abbreviates a candidate's abbr. + + *neocomplcache-filter-converter_case* +converter_case + The converter which converts a candidate's word in text mode. + (cf: |g:neocomplcache_text_mode_filetypes|) + + *neocomplcache-filter-converter_delimiter* +converter_delimiter + The converter which abbreviates a candidate's delimiter. + (cf: |g:neocomplcache_delimiter_patterns|) + + *neocomplcache-filter-converter_remove_next_keyword* +converter_remove_next_keyword + The converter which removes matched next keyword part in a + candidate's word. + (cf: |g:neocomplcache_next_keyword_patterns|) + +============================================================================== +CREATE SOURCE *neocomplcache-create-source* + +In this clause, I comment on a method to make source of neocomplcache. The +ability of neocomplcache will spread by creating source by yourself. + +The files in autoload/neocomplcache/sources are automatically loaded and it +calls neocomplcache#sources#{source_name}#define() whose return value is the +source. Each return value can be a list so you can return an empty list to +avoid adding undesirable sources. To add your own sources dynamically, you +can use |neocomplcache#define_source()|. + +------------------------------------------------------------------------------ +SOURCE ATTRIBUTES *neocomplcache-source-attributes* + + *neocomplcache-source-attribute-name* +name String (Required) + The name of a source. It must consist of the + following characters: + - a-z + - 0-9 + - _ + - / + - - (Not head) + + *neocomplcache-source-attribute-kind* +kind String (Optional) + Source kind. + Following values are available. + "manual" : This source decides complete position + manually. + Note: "complfunc" or "ftplugin" are old + values. + "keyword" : This source decides complete position by + |g:neocomplcache_keyword_patterns|. + Note: "plugin" is old value. + + *neocomplcache-source-attribute-filetypes* +filetypes Dictionary (Optional) + Available filetype dictionary. + + For example: +> + let source = { + \ 'name' : 'test', + \ 'kind' : 'manual', + \ 'filetypes' : { 'vim' : 1, 'html' : 1 }, + \} +< + The source is available in vim and html filetypes. + + If you omit it, this source available in all + filetypes. + + + *neocomplcache-source-attribute-rank* +rank Number (Optional) + Source priority. + Note: You can set source priority by + |g:neocomplcache_source_rank|, but it is obsolete way. + + If you omit it, it is set below value. + If kind attribute is "keyword" : 5 + If filetype attribute is empty : 10 + Else : 100 + + *neocomplcache-source-attribute-min_pattern_length* +min_pattern_length + Number (Optional) + Required pattern length for completion. + + If you omit it, it is set below value. + If kind attribute is "keyword" : + |g:neocomplcache_auto_completion_start_length| + Else : 0 + + *neocomplcache-source-attribute-max_candidates* +max_candidates + Number (Optional) + The maximum number of candidates. + + This attribute is optional; if it is not given, + 0 is used as the default value. This means + maximum number is infinity. + + *neocomplcache-source-attribute-hooks* +hooks Dictionary (Optional) + You may put hook functions in this dictionary in which + the key is the position to hook and the value is the + reference to the function to be called. The following + hook functions are defined: + + *neocomplcache-source-attribute-hooks-on_init* + on_init + Called when initializing the source. + This function takes {context} as its parameters. + *neocomplcache-source-attribute-initialize* + Note initialize() attribute is obsolete interface for + initialization. + + *neocomplcache-source-attribute-hooks-on_final* + on_final + Called after executing |:NeoComplCacheDisable|. + This function takes {context} as its parameters. + *neocomplcache-source-attribute-finalize* + Note finalize() attribute is obsolete interface for + finalization. + + *neocomplcache-source-attribute-hooks-on_post_filter* + on_post_filter + Called after the filters to narrow down the + candidates. This is used to set attributes. This + filters is to avoid adversely affecting the + performance. + This function takes {context} as its parameters. + + *neocomplcache-source-attribute-get_complete_position* +get_complete_position Function (Optional) + This function takes {context} as its + parameter and returns complete position in current + line. + Here, {context} is the context information when the + source is called(|neocomplcache-notation-{context}|). + If you omit it, neocomplcache will use the position + using |g:neocomplcache_keyword_patterns|. + Note get_keyword_pos() is obsolete interface for + get complete position. + + *neocomplcache-source-attribute-gather_candidates* +gather_candidates Function (Required) + This function is called in gathering candidates. If + you enabled fuzzy completion by + |g:neocomplcache_enable_fuzzy_completion| , this + function is called whenever the input string is + changed. This function takes {context} as its + parameter and returns a list of {candidate}. + Here, {context} is the context information when the + source is called(|neocomplcache-notation-{context}|). + Note: get_complete_words() and get_keyword_list() are + obsolete interface for gather candidates. + Note: |neocomplcache-filters| feature is disabled for + compatibility in neocomplcache ver.8.0. You should use + new interface in neocomplcache ver.8.1. + +{context} *neocomplcache-notation-{context}* + A dictionary to give context information. + The followings are the primary information. + The global context information can be acquired + by |neocomplcache#get_context()|. + + input (String) + The input string of current line. + + complete_pos (Number) + The complete position of current source. + + complete_str (String) + The complete string of current source. + + source__{name} (Unknown) (Optional) + Additional source information. + Note: Recommend sources save + variables instead of s: variables. + +------------------------------------------------------------------------------ +CANDIDATE ATTRIBUTES *neocomplcache-candidate-attributes* + + *neocomplcache-candidate-attribute-name* +word String (Required) + The completion word of a candidate. It is used for + matching inputs. + + *neocomplcache-candidate-attribute-abbr* +abbr String (Optional) + The abbreviation of a candidate. It is displayed in + popup window. It is omitted by + |g:neocomplcache_max_keyword_width|. + + *neocomplcache-candidate-attribute-kind* +kind String (Optional) + The kind of a candidate. It is displayed in popup + window. + + *neocomplcache-candidate-attribute-menu* +menu String (Optional) + The menu information of a candidate. It is displayed + in popup window. + + *neocomplcache-candidate-attribute-info* +info String (Optional) + The preview information of a candidate. If + 'completeopt' contains "preview", it will be displayed + in |preview-window|. + + *neocomplcache-candidate-attribute-rank* +rank Number (Optional) + The completion priority. + + +CONTEXT *neocomplcache-context* + +============================================================================== +CREATE FILTER *neocomplcache-create-filter* + +The files in autoload/neocomplcache/filters are automatically loaded and it +calls neocomplcache#filters#{filter_name}#define() whose return value is the +filter. Each return value can be a list so you can return an empty list to +avoid adding undesirable filters. To add your own filters dynamically, you +can use |neocomplcache#define_filter()|. + +------------------------------------------------------------------------------ +FILTER ATTRIBUTES *neocomplcache-filter-attributes* + + + *neocomplcache-filter-attribute-name* +name String (Required) + The filter name. + + *neocomplcache-filter-attribute-filter* +filter Function (Required) + The filter function. This function takes {context} as + its parameter and returns a list of {candidate}. + The specification of the parameters and the returned + value is same as + |neocomplcache-source-attribute-gather_candidates|. + + *neocomplcache-filter-attribute-description* +description String (Optional) + The filter description string. + +============================================================================== +UNITE SOURCES *neocomplcache-unite-sources* + + *neocomplcache-unite-source-neocomplcache* +neocomplcache + Nominates neocomplcache completion candidates. The kind is + "completion". This source is used in + |(neocomplcache_start_unite_complete)|. +> + imap (neocomplcache_start_unite_complete) + imap (neocomplcache_start_unite_quick_match) +< +============================================================================== +FAQ *neocomplcache-faq* + +Q: My customization for neocomplcache is invalid. Why? + +A: User customization for neocomplcache must be set before initialization of +neocomplcache. For example: |neocomplcache#custom_source()| + +Q: Is there a way to control the colors used for popup menu using highlight +groups?: + +A: Like this: +> + highlight Pmenu ctermbg=8 guibg=#606060 + highlight PmenuSel ctermbg=1 guifg=#dddd00 guibg=#1f82cd + highlight PmenuSbar ctermbg=0 guibg=#d6d6d6 +< + +Q: Python (or Ruby) interface crashes Vim when I use neocomplcache or not +responding when input ".": + +A: This is not neocomplcache's issue. Please report to the maintainers of the +omnicomplete (rubycomplete or pythoncomplete) and its Vim interface. You +should disable omni_complete in python or ruby. +> + if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} + endif + let g:neocomplcache_omni_patterns.python = '' + let g:neocomplcache_omni_patterns.ruby = '' +< + +Q: I like moving cursor by cursor-keys. But neocomplcache popups menus... + +A: Please set this in your .vimrc. Note that this feature requires Vim 7.3.418 +or later. +> + let g:neocomplcache_enable_insert_char_pre = 1 +< + +Q: Where is snippets set for neocomplcache? + +A: https://github.com/Shougo/neosnippet + + +Q: How I can disable python omni complete of neocomplcache?: + +A: +> + if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} + endif + let g:neocomplcache_omni_patterns.python = '' +< + +Q: Can I enable quick match? : + +A: Quick match feature had been removed in latest neocomplcache +because quick match turned into hard to implement. +But you can use |unite.vim| instead to use quick match. +> + imap - pumvisible() ? + \ "\(neocomplcache_start_unite_quick_match)" : '-' +< + +Q: How can I change the order of candidates? : + +A: Todo. + +Q: An input problem occurred in using uim-skk or other IMEs: + +A: It may be fixed with setting |g:neocomplcache_enable_prefetch| as 1. + + +Q: include_complete does not work. + +A: include_complete depends on |vimproc|. I recommend you to install it. Also +you can check 'path' option or change |g:neocomplcache_include_paths|. + +http://github.com/Shougo/vimproc + + +Q: neocomplcache cannot create cache files in "sudo vim": + +A: Because neocomplcache (and other plugins) creates temporary files in super +user permission by sudo command. You must use sudo.vim or set "Defaults +always_set_home" in "/etc/sudoers", or must use "sudoedit" command. + + +Ubuntu has a command "sudoedit" which can work well with neocomplcache. +I'm not sure if other distros has this command... + +http://www.vim.org/scripts/script.php?script_id=729 + + +Q: Error occurred in ruby omni complete using |g:neocomplcache_omni_patterns|. +https://github.com/vim-ruby/vim-ruby/issues/95 + +A: Please set |g:neocomplcache_force_omni_patterns| instead of +|g:neocomplcache_omni_patterns|. + +Q: Does not work with clang_complete. + +A: Please try below settings. +> + if !exists('g:neocomplcache_force_omni_patterns') + let g:neocomplcache_force_omni_patterns = {} + endif + let g:neocomplcache_force_overwrite_completefunc = 1 + let g:neocomplcache_force_omni_patterns.c = + \ '[^.[:digit:] *\t]\%(\.\|->\)' + let g:neocomplcache_force_omni_patterns.cpp = + \ '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + let g:neocomplcache_force_omni_patterns.objc = + \ '[^.[:digit:] *\t]\%(\.\|->\)' + let g:neocomplcache_force_omni_patterns.objcpp = + \ '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + let g:clang_complete_auto = 0 + let g:clang_auto_select = 0 + "let g:clang_use_library = 1 +< + +Q: I want to support omni patterns for external plugins. + +A: You can add find some already found omni patterns and functions at here. + +Note: Some patterns are omitted here, (someone should check out those plugin's +source code's complete function, and find out the omni pattern). +> + " Go (plugin: gocode) + let g:neocomplcache_omni_functions.go = 'gocomplete#Complete' + " Clojure (plugin: vim-clojure) + let g:neocomplcache_omni_functions.clojure = 'vimclojure#OmniCompletion' + " SQL + let g:neocomplcache_omni_functions.sql = 'sqlcomplete#Complete' + " R (plugin: vim-R-plugin) + let g:neocomplcache_omni_patterns.r = '[[:alnum:].\\]\+' + let g:neocomplcache_omni_functions.r = 'rcomplete#CompleteR' + " XQuery (plugin: XQuery-indentomnicomplete) + let g:neocomplcache_omni_patterns.xquery = '\k\|:\|\-\|&' + let g:neocomplcache_omni_functions.xquery = 'xquerycomplete#CompleteXQuery' +< + +Q: Does not indent when I input "else" in ruby filetype. + +A: + +You must install "vim-ruby" from github to indent in neocomplcache first. +https://github.com/vim-ruby/vim-ruby + +Neocomplcache pops up a completion window automatically, but if the popup +window is already visible, Vim cannot indent text. So you must choose "close +popup window manually by or mappings" or "close popup window by + user mappings". + +Q: mapping conflicts with |SuperTab| or |endwise| plugins. + +A: Please try below settings. +> + " : close popup and save indent. + inoremap =my_cr_function() + function! s:my_cr_function() + return neocomplcache#smart_close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplcache#close_popup() : "\" + endfunction +> +Q: No completion offered from "vim" buffers in "non-vim" buffers. + +A: It is feature. neocomplcache completes from same filetype buffers in +default. But you can completes from other filetype buffers using +|g:neocomplcache_same_filetype_lists|. + +Q: I want to complete from all buffers. + +A: |g:neocomplcache_same_filetype_lists| +> + let g:neocomplcache_same_filetype_lists = {} + let g:neocomplcache_same_filetype_lists._ = '_' +< + +Q: Suggestions are case insensitive in "gitcommit" buffers, but not +"javascript". + +A: This is g:neocomplcache_text_mode_filetypes feature. +You can disable it by following code. +> + if !exists('g:neocomplcache_text_mode_filetypes') + let g:neocomplcache_tags_filter_patterns = {} + endif + let g:neocomplcache_text_mode_filetypes.gitcommit = 0 +< +Q: Conflicts completefunc with other plugins in neocomplcache. + +A: You can disable the error by |g:neocomplcache_force_overwrite_completefunc| +variable to 1. + +Q: I want to use Ruby omni_complete. + +A: Please set |g:neocomplcache_force_omni_patterns|. But this completion is +heavy, so disabled by default. +Note: But you should use |neocomplcache-rsense| instead of rubycomplete. +https://github.com/Shougo/neocomplcache-rsense +> + autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete + if !exists('g:neocomplcache_force_omni_patterns') + let g:neocomplcache_force_omni_patterns = {} + endif + let g:neocomplcache_force_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' +< +Q: I want to use jedi omni_complete. +https://github.com/davidhalter/jedi-vim + +A: Please set |g:neocomplcache_force_omni_patterns| as below. +> + autocmd FileType python setlocal omnifunc=jedi#completions + let g:jedi#auto_vim_configuration = 0 + let g:neocomplcache_force_omni_patterns.python = '[^. \t]\.\w*' +< +Q: Candidates are not found in heavy completion(neco-look, etc). + +A: It may be caused by skip completion. + + +Q: I want to disable skip completion. + +A: +> + let g:neocomplcache_skip_auto_completion_time = '' +< +Q: I want to initialize neocomplcache in .vimrc. + +A: Please call neocomplcache#initialize() in .vimrc. But this function slows +your Vim initialization. +> + call neocomplcache#initialize() +< +Q: neocomplcache conflicts when multibyte input in GVim. + +A: Because Vim multibyte IME integration is incomplete. +If you set |g:neocomplcache_lock_iminsert| is non-zero, it may be fixed. + +Q: Freeze for a while and close opened folding when I begin to insert. +https://github.com/Shougo/neocomplcache/issues/368 + +A: I think you use 'foldmethod' is "expr" or "syntax". It is too heavy to use +neocomplcache(or other auto completion). You should change 'foldmethod' +option. +Note: In current version, neocomplcache does not restore 'foldmethod'. Because +it is too heavy. + +Q: I want to use Pydiction with neocomplcache. + +A: You should set |g:neocomplcache_dictionary_filetype_lists|. +neocomplcache can load Pydiction dictionary file. + +Q: Why does neocomplcache use if_lua besides if_python? Many people may not be +able to use it because they do not have the root privilege to recompile vim. + +A: +Because of the following reasons. + 1. Python interface is not available on every Vim environment. For example, + Android, iOS, non configured Vim, or etc. + 2. Incompatibility between Python2 and Python3. I must rewrite for it. + 3. Loading Python interface is slow (10~20ms), but loading Lua interface is + absolutely fast (270ns). + 4. Python2 and Python3 are not loaded at the same time on Unix environment. + 5. Python itself is too large. + 6. Python interface is slower than Lua interface (almost twice.) + 7. Lua interface is stable (no crashes on latest Vim.) + 8. Using C module (like vimproc, YouCompleteMe) is hard to compile on Windows + environment. + 9. Using both Python and C, like YouCompleteMe, is too unstable. Your Vim may + crashes or causes mysterious errors. + 10. To build if_lua is easy. + 11. I think if_lua is the second level language in Vim (The first is Vim + script.) + +Q: I want to disable preview window. + +A: +> + set completeopt-=preview +< + +Q: I want to use "vim-lua-ftplugin". +https://github.com/xolox/vim-lua-ftplugin + +A: Please set |g:neocomplcache_omni_patterns| as below. +Note: You can not use "vim-lua-ftplugin" on 7.3.885 or below, +because if_lua has double-free problem. +> + let g:lua_check_syntax = 0 + let g:lua_complete_omni = 1 + let g:lua_complete_dynamic = 0 + + let g:neocomplcache_omni_functions.lua = + \ 'xolox#lua#omnifunc' + let g:neocomplcache_omni_patterns.lua = + \ '\w\+[.:]\|require\s*(\?["'']\w*' + " let g:neocomplcache_force_omni_patterns.lua = + " \ '\w\+[.:]\|require\s*(\?["'']\w*' +< + +Q: neocomplcache closes DiffGitCached window from vim-fugitive +https://github.com/Shougo/neocomplcache.vim/issues/424 +A: +> + let g:neocomplcache_enable_auto_close_preview = 0 +< + +Q: I want to get quiet messages in auto completion. +https://github.com/Shougo/neocomplcache.vim/issues/448 + +A: Before 7.4 patch 314 it was not possible because of vim's default +behavior. If you are using a recent version of vim you can disable the +messages through the 'shortmess' option. +> + if has("patch-7.4.314") + set shortmess+=c + endif +< +For earlier vim versions you can try to hide them by using the settings below +> + autocmd VimEnter * + \ highlight ModeMsg guifg=bg guibg=bg | highlight WarningMsg guifg=bg +< + +Q: neocomplcache will change external completeopt vaule(longest). +https://github.com/Shougo/neocomplcache.vim/issues/453 + +A: It is feature. Because "longest" completeopt conflicts with auto +completion. To use "longest" option, you must disable auto completion. +"longest" is good feature. But it is for manual completion only. + +Q: autoclose conflicts with neocomplcache. +https://github.com/Shougo/neocomplcache.vim/issues/350 + +A: It is autoclose mappings problem. I cannot fix it. You should use +auto-pairs plugin instead of it. +https://github.com/jiangmiao/auto-pairs + +============================================================================== +vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache.vim b/vim/bundle/neocomplcache/plugin/neocomplcache.vim new file mode 100644 index 0000000..f479205 --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache.vim @@ -0,0 +1,196 @@ +"============================================================================= +" FILE: neocomplcache.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 26 Sep 2013. +" 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. +" }}} +" GetLatestVimScripts: 2620 1 :AutoInstall: neocomplcache +"============================================================================= + +if exists('g:loaded_neocomplcache') + finish +endif +let g:loaded_neocomplcache = 1 + +let s:save_cpo = &cpo +set cpo&vim + +if v:version < 702 + echohl Error + echomsg 'neocomplcache does not work this version of Vim (' . v:version . ').' + echohl None + finish +endif + +command! -nargs=0 -bar NeoComplCacheEnable + \ call neocomplcache#init#enable() +command! -nargs=0 -bar NeoComplCacheDisable + \ call neocomplcache#init#disable() +command! -nargs=0 -bar NeoComplCacheLock + \ call neocomplcache#commands#_lock() +command! -nargs=0 -bar NeoComplCacheUnlock + \ call neocomplcache#commands#_unlock() +command! -nargs=0 -bar NeoComplCacheToggle + \ call neocomplcache#commands#_toggle_lock() +command! -nargs=1 -bar NeoComplCacheLockSource + \ call neocomplcache#commands#_lock_source() +command! -nargs=1 -bar NeoComplCacheUnlockSource + \ call neocomplcache#commands#_unlock_source() +if v:version >= 703 + command! -nargs=1 -bar -complete=filetype NeoComplCacheSetFileType + \ call neocomplcache#commands#_set_file_type() +else + command! -nargs=1 -bar NeoComplCacheSetFileType + \ call neocomplcache#commands#_set_file_type() +endif +command! -nargs=0 -bar NeoComplCacheClean + \ call neocomplcache#commands#_clean() + +" Warning if using obsolute mappings. "{{{ +silent! inoremap (neocomplcache_snippets_expand) + \ :echoerr print_snippets_complete_error() +silent! snoremap (neocomplcache_snippets_expand) + \ ::echoerr print_snippets_complete_error() +silent! inoremap (neocomplcache_snippets_jump) + \ :echoerr print_snippets_complete_error() +silent! snoremap (neocomplcache_snippets_jump) + \ ::echoerr print_snippets_complete_error() +silent! inoremap (neocomplcache_snippets_force_expand) + \ :echoerr print_snippets_complete_error() +silent! snoremap (neocomplcache_snippets_force_expand) + \ ::echoerr print_snippets_complete_error() +silent! inoremap (neocomplcache_snippets_force_jump) + \ :echoerr print_snippets_complete_error() +silent! snoremap (neocomplcache_snippets_force_jump) + \ ::echoerr print_snippets_complete_error() +function! s:print_snippets_complete_error() + return 'Warning: neocomplcache snippets source was splitted!' + \ .' You should install neosnippet from' + \ .' "https://github.com/Shougo/neosnippet.vim"' +endfunction"}}} + +" Global options definition. "{{{ +let g:neocomplcache_max_list = + \ get(g:, 'neocomplcache_max_list', 100) +let g:neocomplcache_max_keyword_width = + \ get(g:, 'neocomplcache_max_keyword_width', 80) +let g:neocomplcache_max_menu_width = + \ get(g:, 'neocomplcache_max_menu_width', 15) +let g:neocomplcache_auto_completion_start_length = + \ get(g:, 'neocomplcache_auto_completion_start_length', 2) +let g:neocomplcache_manual_completion_start_length = + \ get(g:, 'neocomplcache_manual_completion_start_length', 0) +let g:neocomplcache_min_keyword_length = + \ get(g:, 'neocomplcache_min_keyword_length', 4) +let g:neocomplcache_enable_ignore_case = + \ get(g:, 'neocomplcache_enable_ignore_case', &ignorecase) +let g:neocomplcache_enable_smart_case = + \ get(g:, 'neocomplcache_enable_smart_case', &infercase) +let g:neocomplcache_disable_auto_complete = + \ get(g:, 'neocomplcache_disable_auto_complete', 0) +let g:neocomplcache_enable_wildcard = + \ get(g:, 'neocomplcache_enable_wildcard', 1) +let g:neocomplcache_enable_camel_case_completion = + \ get(g:, 'neocomplcache_enable_camel_case_completion', 0) +let g:neocomplcache_enable_underbar_completion = + \ get(g:, 'neocomplcache_enable_underbar_completion', 0) +let g:neocomplcache_enable_fuzzy_completion = + \ get(g:, 'neocomplcache_enable_fuzzy_completion', 0) +let g:neocomplcache_fuzzy_completion_start_length = + \ get(g:, 'neocomplcache_fuzzy_completion_start_length', 3) +let g:neocomplcache_enable_caching_message = + \ get(g:, 'neocomplcache_enable_caching_message', 1) +let g:neocomplcache_enable_insert_char_pre = + \ get(g:, 'neocomplcache_enable_insert_char_pre', 0) +let g:neocomplcache_enable_cursor_hold_i = + \ get(g:, 'neocomplcache_enable_cursor_hold_i', 0) +let g:neocomplcache_cursor_hold_i_time = + \ get(g:, 'neocomplcache_cursor_hold_i_time', 300) +let g:neocomplcache_enable_auto_select = + \ get(g:, 'neocomplcache_enable_auto_select', 0) +let g:neocomplcache_enable_auto_delimiter = + \ get(g:, 'neocomplcache_enable_auto_delimiter', 0) +let g:neocomplcache_caching_limit_file_size = + \ get(g:, 'neocomplcache_caching_limit_file_size', 500000) +let g:neocomplcache_disable_caching_file_path_pattern = + \ get(g:, 'neocomplcache_disable_caching_file_path_pattern', '') +let g:neocomplcache_lock_buffer_name_pattern = + \ get(g:, 'neocomplcache_lock_buffer_name_pattern', '') +let g:neocomplcache_ctags_program = + \ get(g:, 'neocomplcache_ctags_program', 'ctags') +let g:neocomplcache_force_overwrite_completefunc = + \ get(g:, 'neocomplcache_force_overwrite_completefunc', 0) +let g:neocomplcache_enable_prefetch = + \ get(g:, 'neocomplcache_enable_prefetch', + \ !(v:version > 703 || v:version == 703 && has('patch519')) + \ || (has('gui_running') && has('xim')) + \ ) +let g:neocomplcache_lock_iminsert = + \ get(g:, 'neocomplcache_lock_iminsert', 0) +let g:neocomplcache_release_cache_time = + \ get(g:, 'neocomplcache_release_cache_time', 900) +let g:neocomplcache_wildcard_characters = + \ get(g:, 'neocomplcache_wildcard_characters', { + \ '_' : '*' }) +let g:neocomplcache_skip_auto_completion_time = + \ get(g:, 'neocomplcache_skip_auto_completion_time', '0.3') +let g:neocomplcache_enable_auto_close_preview = + \ get(g:, 'neocomplcache_enable_auto_close_preview', 1) + +let g:neocomplcache_sources_list = + \ get(g:, 'neocomplcache_sources_list', {}) +let g:neocomplcache_disabled_sources_list = + \ get(g:, 'neocomplcache_disabled_sources_list', {}) +if exists('g:neocomplcache_source_disable') + let g:neocomplcache_disabled_sources_list._ = + \ keys(filter(copy(g:neocomplcache_source_disable), 'v:val')) +endif + +if exists('g:neocomplcache_plugin_completion_length') + let g:neocomplcache_source_completion_length = + \ g:neocomplcache_plugin_completion_length +endif +let g:neocomplcache_source_completion_length = + \ get(g:, 'neocomplcache_source_completion_length', {}) +if exists('g:neocomplcache_plugin_rank') + let g:neocomplcache_source_rank = g:neocomplcache_plugin_rank +endif +let g:neocomplcache_source_rank = + \ get(g:, 'neocomplcache_source_rank', {}) + +let g:neocomplcache_temporary_dir = + \ get(g:, 'neocomplcache_temporary_dir', + \ ($XDG_CACHE_HOME != '' ? + \ $XDG_CACHE_HOME . '/neocomplcache' : expand('~/.cache/neocomplcache'))) +let g:neocomplcache_enable_debug = + \ get(g:, 'neocomplcache_enable_debug', 0) +if get(g:, 'neocomplcache_enable_at_startup', 0) + augroup neocomplcache + " Enable startup. + autocmd CursorHold,CursorMovedI + \ * call neocomplcache#init#lazy() + augroup END +endif"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache/buffer_complete.vim b/vim/bundle/neocomplcache/plugin/neocomplcache/buffer_complete.vim new file mode 100644 index 0000000..e6df1aa --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache/buffer_complete.vim @@ -0,0 +1,37 @@ +"============================================================================= +" FILE: buffer_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 05 Oct 2012. +"============================================================================= + +if exists('g:loaded_neocomplcache_buffer_complete') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=file -bar + \ NeoComplCacheCachingBuffer + \ call neocomplcache#sources#buffer_complete#caching_buffer() +command! -nargs=? -complete=buffer -bar + \ NeoComplCachePrintSource + \ call neocomplcache#sources#buffer_complete#print_source() +command! -nargs=? -complete=buffer -bar + \ NeoComplCacheOutputKeyword + \ call neocomplcache#sources#buffer_complete#output_keyword() +command! -nargs=? -complete=buffer -bar + \ NeoComplCacheDisableCaching + \ call neocomplcache#sources#buffer_complete#disable_caching() +command! -nargs=? -complete=buffer -bar + \ NeoComplCacheEnableCaching + \ call neocomplcache#sources#buffer_complete#enable_caching() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplcache_buffer_complete = 1 + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache/dictionary_complete.vim b/vim/bundle/neocomplcache/plugin/neocomplcache/dictionary_complete.vim new file mode 100644 index 0000000..6de4b28 --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache/dictionary_complete.vim @@ -0,0 +1,25 @@ +"============================================================================= +" FILE: dictionary_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 05 Oct 2012. +"============================================================================= + +if exists('g:loaded_neocomplcache_dictionary_complete') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=customlist,neocomplcache#filetype_complete + \ NeoComplCacheCachingDictionary + \ call neocomplcache#sources#dictionary_complete#recaching() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplcache_dictionary_complete = 1 + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache/include_complete.vim b/vim/bundle/neocomplcache/plugin/neocomplcache/include_complete.vim new file mode 100644 index 0000000..6c66818 --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache/include_complete.vim @@ -0,0 +1,24 @@ +"============================================================================= +" FILE: include_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 05 Oct 2012. +"============================================================================= + +if exists('g:loaded_neocomplcache_include_complete') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=buffer NeoComplCacheCachingInclude + \ call neocomplcache#sources#include_complete#caching_include() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplcache_include_complete = 1 + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache/syntax_complete.vim b/vim/bundle/neocomplcache/plugin/neocomplcache/syntax_complete.vim new file mode 100644 index 0000000..d4e64a9 --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache/syntax_complete.vim @@ -0,0 +1,25 @@ +"============================================================================= +" FILE: syntax_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 05 Oct 2012. +"============================================================================= + +if exists('g:loaded_neocomplcache_syntax_complete') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=customlist,neocomplcache#filetype_complete + \ NeoComplCacheCachingSyntax + \ call neocomplcache#sources#syntax_complete#recaching() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplcache_syntax_complete = 1 + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/plugin/neocomplcache/tags_complete.vim b/vim/bundle/neocomplcache/plugin/neocomplcache/tags_complete.vim new file mode 100644 index 0000000..e4946d8 --- /dev/null +++ b/vim/bundle/neocomplcache/plugin/neocomplcache/tags_complete.vim @@ -0,0 +1,25 @@ +"============================================================================= +" FILE: tags_complete.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 05 Oct 2012. +"============================================================================= + +if exists('g:loaded_neocomplcache_tags_complete') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=0 -bar + \ NeoComplCacheCachingTags + \ call neocomplcache#sources#tags_complete#caching_tags(1) +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplcache_tags_complete = 1 + +" vim: foldmethod=marker diff --git a/vim/bundle/neocomplcache/vest/test-neocomplcache.vim b/vim/bundle/neocomplcache/vest/test-neocomplcache.vim new file mode 100644 index 0000000..701555c --- /dev/null +++ b/vim/bundle/neocomplcache/vest/test-neocomplcache.vim @@ -0,0 +1,24 @@ +scriptencoding utf-8 + +" Saving 'cpoptions' {{{ +let s:save_cpo = &cpo +set cpo&vim +" }}} + +Context types + It tests compare functions. + ShouldEqual sort([{ 'word' : 'z0' }, { 'word' : 'z10' }, + \ { 'word' : 'z2'}, { 'word' : 'z3'} ], + \ 'neocomplcache#compare_human'), + \ [{ 'word' : 'z0' }, { 'word' : 'z2' }, + \ { 'word' : 'z3' }, { 'word' : 'z10' }] + End +End + +Fin + +" Restore 'cpoptions' {{{ +let &cpo = s:save_cpo +" }}} + +" vim:foldmethod=marker:fen: diff --git a/vim/bundle/nerdtree/.gitignore b/vim/bundle/nerdtree/.gitignore new file mode 100644 index 0000000..3698c0e --- /dev/null +++ b/vim/bundle/nerdtree/.gitignore @@ -0,0 +1,3 @@ +*~ +*.swp +tags diff --git a/vim/bundle/nerdtree/CHANGELOG b/vim/bundle/nerdtree/CHANGELOG new file mode 100644 index 0000000..a23884a --- /dev/null +++ b/vim/bundle/nerdtree/CHANGELOG @@ -0,0 +1,169 @@ +Next + - Reuse/reopen existing window trees where possible #244 + - Remove NERDTree.previousBuf() + - Change color of arrow (Leeiio) #630 + - Improved a tip in README.markdown (ggicci) #628 + - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 + - Fix API call to open directory tree in window (devm33) #533 + - Change default arrows on non-Windows platforms (gwilk) #546 + - Update to README - combine cd and git clone (zwhitchcox) #584 + - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 + - Escape filename when moving an open buffer (zacharyvoase) #595 + - Fixed incorrect :helptags command in README (curran) #619 + - Fixed incomplete escaping of folder arrows (adityanatraj) #548 + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 + - Replace strchars() with backward compatible workaround. + - Add support for copy command in Windows (SkylerLipthay) #231 + - Fixed typo in README.markdown - :Helptags -> :helptags + - Rename "primary" and "secondary" trees to "tab" and "window" trees. + - Move a bunch of buffer level variables into the NERDTree and UI classes. + - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) + - Remove the old style UI - Remove 'NERDTreeDirArrows' option. + - On windows default to + and ~ for expand/collapse directory symbols. + - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. + +5.0.0 + - Refactor the code significantly: + * Break the classes out into their own files. + * Make the majority of the code OO - previously large parts were + effectively a tangle of "global" methods. + - Add an API to assign flags to nodes. This allows VCS plugins like + https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to + Xuyuanp for helping design/test/build said API. + - add 'scope' argument to the key map API see :help NERDTreeAddKeyMap() + - add magic [[dir]] and [[file]] flags to NERDTreeIgnore + - add support for custom path filters. See :help NERDTreeAddPathFilter() + - add path listener API. See :help NERDTreePathListenerAPI. + - expand the fs menu functionality to list file properties (PhilRunninger, + apbarrero, JESii) + - make bookmarks work with `~` home shortcuts (hiberabyss) + - show OSX specific fsmenu options in regular vim on mac (evindor) + - make dir arrow icons configurable (PickRelated) + - optimise node sorting performance when opening large dirs (vtsang) + - make the root note render prettier by truncating it at a path slash (gcmt) + - remove NERDChristmasTree option - its always christmas now + - add "cascade" open and closing for dirs containing only another single + dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) + + Many other fixes, doc updates and contributions from: + actionshrimp + SchDen + egalpin + cperl82 - many small fixes + toiffel + WoLpH + handcraftedbits + devmanhinton + xiaodili + zhangoose + gastropoda + mixvin + alvan + lucascaton + kelaban + shanesmith + staeff + pendulm + stephenprater + franksort + agrussellknives + AndrewRadev + Twinside + +4.2.0 + - Add NERDTreeDirArrows option to make the UI use pretty arrow chars + instead of the old +~| chars to define the tree structure (sickill) + - shift the syntax highlighting out into its own syntax file (gnap) + - add some mac specific options to the filesystem menu - for macvim + only (andersonfreitas) + - Add NERDTreeMinimalUI option to remove some non functional parts of the + nerdtree ui (camthompson) + - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the + new behaviour (benjamingeiger) + - if no name is given to :Bookmark, make it default to the name of the + target file/dir (minyoung) + - use 'file' completion when doing copying, create, and move + operations (EvanDotPro) + - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly + Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) + +4.1.0 + features: + - NERDTreeFind to reveal the node for the current buffer in the tree, + see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by + Doug McInnes) into the script. + - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan + Ritter and Rémi Prévost. + - truncate the root node if wider than the tree window. Thanks to Victor + Gonzalez. + + bugfixes: + - really fix window state restoring + - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, + jfilip1024, and Chris Chambers + +4.0.0 + - add a new programmable menu system (see :help NERDTreeMenu). + - add new APIs to add menus/menu-items to the menu system as well as + custom key mappings to the NERD tree buffer (see :help NERDTreeAPI). + - removed the old API functions + - added a mapping to maximize/restore the size of nerd tree window, thanks + to Guillaume Duranceau for the patch. See :help NERDTree-A for details. + + - fix a bug where secondary nerd trees (netrw hijacked trees) and + NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey. + - fix a bug where the script ignored directories whose name ended in a dot, + thanks to Aggelos Orfanakos for the patch. + - fix a bug when using the x mapping on the tree root, thanks to Bryan + Venteicher for the patch. + - fix a bug where the cursor position/window size of the nerd tree buffer + wasnt being stored on closing the window, thanks to Richard Hart. + - fix a bug where NERDTreeMirror would mirror the wrong tree + +3.1.1 + - fix a bug where a non-listed no-name buffer was getting created every + time the tree windows was created, thanks to Derek Wyatt and owen1 + - make behave the same as the 'o' mapping + - some helptag fixes in the doc, thanks strull + - fix a bug when using :set nohidden and opening a file where the previous + buf was modified. Thanks iElectric + - other minor fixes + +3.1.0 + New features: + - add mappings to open files in a vsplit, see :help NERDTree-s and :help + NERDTree-gs + - make the statusline for the nerd tree window default to something + hopefully more useful. See :help 'NERDTreeStatusline' + Bugfixes: + - make the hijack netrw functionality work when vim is started with "vim + " (thanks to Alf Mikula for the patch). + - fix a bug where the CWD wasnt being changed for some operations even when + NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) + - add -bar to all the nerd tree :commands so they can chain with other + :commands (thanks to tpope) + - fix bugs when ignorecase was set (thanks to nach) + - fix a bug with the relative path code (thanks to nach) + - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach) + + +3.0.1 + Bugfixes: + - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden + was not set + - fix a bug where :NERDTree would fail if was relative and + didnt start with a ./ or ../ Thanks to James Kanze. + - make the q mapping work with secondary (:e style) trees, + thanks to jamessan + - fix a bunch of small bugs with secondary trees + + More insane refactoring. + +3.0.0 + - hijack netrw so that doing an :edit will put a NERD tree in + the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' + - allow sharing of trees across tabs, see :help :NERDTreeMirror + - remove "top" and "bottom" as valid settings for NERDTreeWinPos + - change the '' mapping to 'i' + - change the 'H' mapping to 'I' + - lots of refactoring diff --git a/vim/bundle/nerdtree/LICENCE b/vim/bundle/nerdtree/LICENCE new file mode 100644 index 0000000..8b1a9d8 --- /dev/null +++ b/vim/bundle/nerdtree/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/vim/bundle/nerdtree/README.markdown b/vim/bundle/nerdtree/README.markdown new file mode 100644 index 0000000..4f5133a --- /dev/null +++ b/vim/bundle/nerdtree/README.markdown @@ -0,0 +1,136 @@ +The NERD Tree +============= + +Intro +----- + +The NERD tree allows you to explore your filesystem and to open files and +directories. It presents the filesystem to you in the form of a tree which you +manipulate with the keyboard and/or mouse. It also allows you to perform +simple filesystem operations. + +The following features and functionality are provided by the NERD tree: + + * Files and directories are displayed in a hierarchical tree structure + * Different highlighting is provided for the following types of nodes: + * files + * directories + * sym-links + * windows .lnk files + * read-only files + * executable files + * Many (customisable) mappings are provided to manipulate the tree: + * Mappings to open/close/explore directory nodes + * Mappings to open files in new/existing windows/tabs + * Mappings to change the current root of the tree + * Mappings to navigate around the tree + * ... + * Directories and files can be bookmarked. + * Most NERD tree navigation can also be done with the mouse + * Filtering of tree content (can be toggled at runtime) + * custom file filters to prevent e.g. vim backup files being displayed + * optional displaying of hidden files (. files) + * files can be "turned off" so that only directories are displayed + * The position and size of the NERD tree window can be customised + * The order in which the nodes in the tree are listed can be customised. + * A model of your filesystem is created/maintained as you explore it. This + has several advantages: + * All filesystem information is cached and is only re-read on demand + * If you revisit a part of the tree that you left earlier in your + session, the directory nodes will be opened/closed as you left them + * The script remembers the cursor position and window position in the NERD + tree so you can toggle it off (or just close the tree window) and then + reopen it (with NERDTreeToggle) the NERD tree window will appear exactly + as you left it + * You can have a separate NERD tree for each tab, share trees across tabs, + or a mix of both. + * By default the script overrides the default file browser (netrw), so if + you :edit a directory a (slightly modified) NERD tree will appear in the + current window + * A programmable menu system is provided (simulates right clicking on a node) + * one default menu plugin is provided to perform basic filesystem + operations (create/delete/move/copy files/directories) + * There's an API for adding your own keymappings + +Installation +------------ + +####[pathogen.vim](https://github.com/tpope/vim-pathogen) + + git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree + +Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`. + + +####[apt-vim](https://github.com/egalpin/apt-vim) + + apt-vim install -y https://github.com/scrooloose/nerdtree.git + + + +Faq +--- + +> Is there any support for `git` flags? + +Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). + +--- + +> Can I have the nerdtree on every tab automatically? + +Nope. If this is something you want then chances are you aren't using tabs and +buffers as they were intended to be used. Read this +http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers + +If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + +--- +> How can I open a NERDTree automatically when vim starts up? + +Stick this in your vimrc: `autocmd vimenter * NERDTree` + +--- +> How can I open a NERDTree automatically when vim starts up if no files were specified? + +Stick this in your vimrc: + + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif + +Note: Now start vim with plain `vim`, not `vim .` + +--- +> How can I open NERDTree automatically when vim starts up on opening a directory? + + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif + +This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. + +--- +> How can I map a specific key or shortcut to open NERDTree? + +Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): + + map :NERDTreeToggle + +--- +> How can I close vim if the only window left open is a NERDTree? + +Stick this in your vimrc: + + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + +--- +> Can I have different highlighting for different file extensions? + +See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 + +--- +> How can I change default arrows? + +Use these variables in your vimrc. Note that below are default arrow symbols + + let g:NERDTreeDirArrowExpandable = '▸' + let g:NERDTreeDirArrowCollapsible = '▾' diff --git a/vim/bundle/nerdtree/autoload/nerdtree.vim b/vim/bundle/nerdtree/autoload/nerdtree.vim new file mode 100644 index 0000000..e0d86ef --- /dev/null +++ b/vim/bundle/nerdtree/autoload/nerdtree.vim @@ -0,0 +1,175 @@ +if exists("g:loaded_nerdtree_autoload") + finish +endif +let g:loaded_nerdtree_autoload = 1 + +function! nerdtree#version() + return '5.0.0' +endfunction + +" SECTION: General Functions {{{1 +"============================================================ + +"FUNCTION: nerdtree#checkForBrowse(dir) {{{2 +"inits a window tree in the current buffer if appropriate +function! nerdtree#checkForBrowse(dir) + if !isdirectory(a:dir) + return + endif + + if s:reuseWin(a:dir) + return + endif + + call g:NERDTreeCreator.CreateWindowTree(a:dir) +endfunction + +"FUNCTION: s:reuseWin(dir) {{{2 +"finds a NERDTree buffer with root of dir, and opens it. +function! s:reuseWin(dir) abort + let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) + + for i in range(1, bufnr("$")) + unlet! nt + let nt = getbufvar(i, "NERDTree") + if empty(nt) + continue + endif + + if nt.isWinTree() && nt.root.path.equals(path) + call nt.setPreviousBuf(bufnr("#")) + exec "buffer " . i + return 1 + endif + endfor + + return 0 +endfunction + +" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 +" completion function for the bookmark commands +function! nerdtree#completeBookmarks(A,L,P) + return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') +endfunction + +"FUNCTION: nerdtree#compareBookmarks(dir) {{{2 +function! nerdtree#compareBookmarks(first, second) + return a:first.compareTo(a:second) +endfunction + +"FUNCTION: nerdtree#compareNodes(dir) {{{2 +function! nerdtree#compareNodes(n1, n2) + return a:n1.path.compareTo(a:n2.path) +endfunction + +"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 +function! nerdtree#compareNodesBySortKey(n1, n2) + if a:n1.path.getSortKey() <# a:n2.path.getSortKey() + return -1 + elseif a:n1.path.getSortKey() ># a:n2.path.getSortKey() + return 1 + else + return 0 + endif +endfunction + +" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 +" Issue a deprecation warning for a:func. If a second arg is given, use this +" as the deprecation message +function! nerdtree#deprecated(func, ...) + let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' + + if !exists('s:deprecationWarnings') + let s:deprecationWarnings = {} + endif + if !has_key(s:deprecationWarnings, a:func) + let s:deprecationWarnings[a:func] = 1 + echomsg msg + endif +endfunction + +" FUNCTION: nerdtree#exec(cmd) {{{2 +" same as :exec cmd but eventignore=all is set for the duration +function! nerdtree#exec(cmd) + let old_ei = &ei + set ei=all + exec a:cmd + let &ei = old_ei +endfunction + +" FUNCTION: nerdtree#has_opt(options, name) {{{2 +function! nerdtree#has_opt(options, name) + return has_key(a:options, a:name) && a:options[a:name] == 1 +endfunction + +" FUNCTION: nerdtree#loadClassFiles() {{{2 +function! nerdtree#loadClassFiles() + runtime lib/nerdtree/path.vim + runtime lib/nerdtree/menu_controller.vim + runtime lib/nerdtree/menu_item.vim + runtime lib/nerdtree/key_map.vim + runtime lib/nerdtree/bookmark.vim + runtime lib/nerdtree/tree_file_node.vim + runtime lib/nerdtree/tree_dir_node.vim + runtime lib/nerdtree/opener.vim + runtime lib/nerdtree/creator.vim + runtime lib/nerdtree/flag_set.vim + runtime lib/nerdtree/nerdtree.vim + runtime lib/nerdtree/ui.vim + runtime lib/nerdtree/event.vim + runtime lib/nerdtree/notifier.vim +endfunction + +" FUNCTION: nerdtree#postSourceActions() {{{2 +function! nerdtree#postSourceActions() + call g:NERDTreeBookmark.CacheBookmarks(1) + call nerdtree#ui_glue#createDefaultBindings() + + "load all nerdtree plugins + runtime! nerdtree_plugin/**/*.vim +endfunction + +"FUNCTION: nerdtree#runningWindows(dir) {{{2 +function! nerdtree#runningWindows() + return has("win16") || has("win32") || has("win64") +endfunction + +" SECTION: View Functions {{{1 +"============================================================ + +"FUNCTION: nerdtree#echo {{{2 +"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages +" +"Args: +"msg: the message to echo +function! nerdtree#echo(msg) + redraw + echomsg "NERDTree: " . a:msg +endfunction + +"FUNCTION: nerdtree#echoError {{{2 +"Wrapper for nerdtree#echo, sets the message type to errormsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoError(msg) + echohl errormsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#echoWarning {{{2 +"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoWarning(msg) + echohl warningmsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#renderView {{{2 +function! nerdtree#renderView() + call b:NERDTree.render() +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim b/vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim new file mode 100644 index 0000000..2aa3bec --- /dev/null +++ b/vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim @@ -0,0 +1,646 @@ +if exists("g:loaded_nerdtree_ui_glue_autoload") + finish +endif +let g:loaded_nerdtree_ui_glue_autoload = 1 + +" FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1 +function! nerdtree#ui_glue#createDefaultBindings() + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) +endfunction + + +"SECTION: Interface bindings {{{1 +"============================================================ + +"FUNCTION: s:activateAll() {{{1 +"handle the user activating the updir line +function! s:activateAll() + if getline(".") ==# g:NERDTreeUI.UpDirLine() + return nerdtree#ui_glue#upDir(0) + endif +endfunction + +"FUNCTION: s:activateDirNode() {{{1 +"handle the user activating a tree node +function! s:activateDirNode(node) + call a:node.activate() +endfunction + +"FUNCTION: s:activateFileNode() {{{1 +"handle the user activating a tree node +function! s:activateFileNode(node) + call a:node.activate({'reuse': 'all', 'where': 'p'}) +endfunction + +"FUNCTION: s:activateBookmark() {{{1 +"handle the user activating a bookmark +function! s:activateBookmark(bm) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) +endfunction + +" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 +" Associate the current node with the given name +function! nerdtree#ui_glue#bookmarkNode(...) + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(0) + endif + try + call currentNode.bookmark(name) + call b:NERDTree.render() + catch /^NERDTree.IllegalBookmarkNameError/ + call nerdtree#echo("bookmark names must not contain spaces") + endtry + else + call nerdtree#echo("select a node first") + endif +endfunction + +" FUNCTION: s:chCwd(node) {{{1 +function! s:chCwd(node) + try + call a:node.path.changeToDir() + catch /^NERDTree.PathChangeError/ + call nerdtree#echoWarning("could not change cwd") + endtry +endfunction + +" FUNCTION: s:chRoot(node) {{{1 +" changes the current root to the selected one +function! s:chRoot(node) + call b:NERDTree.changeRoot(a:node) +endfunction + +" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 +" changes the current root to CWD +function! nerdtree#ui_glue#chRootCwd() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + return + endtry + if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() + return + endif + call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree)) +endfunction + +" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 +function! nerdtree#ui_glue#clearBookmarks(bookmarks) + if a:bookmarks ==# '' + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + call currentNode.clearBookmarks() + endif + else + for name in split(a:bookmarks, ' ') + let bookmark = g:NERDTreeBookmark.BookmarkFor(name) + call bookmark.delete() + endfor + endif + call b:NERDTree.root.refresh() + call b:NERDTree.render() +endfunction + +" FUNCTION: s:closeChildren(node) {{{1 +" closes all childnodes of the current node +function! s:closeChildren(node) + call a:node.closeChildren() + call b:NERDTree.render() + call a:node.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:closeCurrentDir(node) {{{1 +" closes the parent dir of the current node +function! s:closeCurrentDir(node) + let parent = a:node.parent + while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot() + let childNodes = parent.getVisibleChildren() + if len(childNodes) == 1 && childNodes[0].path.isDirectory + let parent = parent.parent + else + break + endif + endwhile + if parent ==# {} || parent.isRoot() + call nerdtree#echo("cannot close tree root") + else + call parent.close() + call b:NERDTree.render() + call parent.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: s:closeTreeWindow() {{{1 +" close the tree window +function! s:closeTreeWindow() + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 + exec "buffer " . b:NERDTree.previousBuf() + else + if winnr("$") > 1 + call g:NERDTree.Close() + else + call nerdtree#echo("Cannot close last window") + endif + endif +endfunction + +" FUNCTION: s:deleteBookmark(bm) {{{1 +" if the cursor is on a bookmark, prompt to delete +function! s:deleteBookmark(bm) + echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" + + if nr2char(getchar()) ==# 'y' + try + call a:bm.delete() + call b:NERDTree.root.refresh() + call b:NERDTree.render() + redraw + catch /^NERDTree/ + call nerdtree#echoWarning("Could not remove bookmark") + endtry + else + call nerdtree#echo("delete aborted" ) + endif + +endfunction + +" FUNCTION: s:displayHelp() {{{1 +" toggles the help display +function! s:displayHelp() + call b:NERDTree.ui.toggleHelp() + call b:NERDTree.render() + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:findAndRevealPath() {{{1 +function! s:findAndRevealPath() + try + let p = g:NERDTreePath.New(expand("%:p")) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("no file for the current buffer") + return + endtry + + if p.isUnixHiddenPath() + let showhidden=g:NERDTreeShowHidden + let g:NERDTreeShowHidden = 1 + endif + + if !g:NERDTree.ExistsForTab() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call g:NERDTreeCreator.CreateTabTree(cwd.str()) + else + call g:NERDTreeCreator.CreateTabTree(p.getParent().str()) + endif + else + if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) + if !g:NERDTree.IsOpen() + call g:NERDTreeCreator.ToggleTabTree('') + else + call g:NERDTree.CursorToTreeWin() + endif + call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden) + call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree)) + else + if !g:NERDTree.IsOpen() + call g:NERDTreeCreator.ToggleTabTree("") + endif + endif + endif + call g:NERDTree.CursorToTreeWin() + let node = b:NERDTree.root.reveal(p) + call b:NERDTree.render() + call node.putCursorHere(1,0) + + if p.isUnixHiddenFile() + let g:NERDTreeShowHidden = showhidden + endif +endfunction + +"FUNCTION: s:handleLeftClick() {{{1 +"Checks if the click should open the current node +function! s:handleLeftClick() + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + + "the dir arrows are multibyte chars, and vim's string functions only + "deal with single bytes - so split the line up with the hack below and + "take the line substring manually + let line = split(getline(line(".")), '\zs') + let startToCur = "" + for i in range(0,len(line)-1) + let startToCur .= line[i] + endfor + + if currentNode.path.isDirectory + if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$' + call currentNode.activate() + return + endif + endif + + if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 + let char = strpart(startToCur, strlen(startToCur)-1, 1) + if char !~# g:NERDTreeUI.MarkupReg() + if currentNode.path.isDirectory + call currentNode.activate() + else + call currentNode.activate({'reuse': 'all', 'where': 'p'}) + endif + return + endif + endif + endif +endfunction + +" FUNCTION: s:handleMiddleMouse() {{{1 +function! s:handleMiddleMouse() + let curNode = g:NERDTreeFileNode.GetSelected() + if curNode ==# {} + call nerdtree#echo("Put the cursor on a node first" ) + return + endif + + if curNode.path.isDirectory + call nerdtree#openExplorer(curNode) + else + call curNode.open({'where': 'h'}) + endif +endfunction + +" FUNCTION: s:jumpToChild(direction) {{{2 +" Args: +" direction: 0 if going to first child, 1 if going to last +function! s:jumpToChild(currentNode, direction) + if a:currentNode.isRoot() + return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child") + end + let dirNode = a:currentNode.parent + let childNodes = dirNode.getVisibleChildren() + + let targetNode = childNodes[0] + if a:direction + let targetNode = childNodes[len(childNodes) - 1] + endif + + if targetNode.equals(a:currentNode) + let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) + if siblingDir != {} + let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 + let targetNode = siblingDir.getChildByIndex(indx, 1) + endif + endif + + call targetNode.putCursorHere(1, 0) + + call b:NERDTree.ui.centerView() +endfunction + + +" FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! nerdtree#ui_glue#invokeKeyMap(key) + call g:NERDTreeKeyMap.Invoke(a:key) +endfunction + +" FUNCTION: s:jumpToFirstChild() {{{1 +" wrapper for the jump to child method +function! s:jumpToFirstChild(node) + call s:jumpToChild(a:node, 0) +endfunction + +" FUNCTION: s:jumpToLastChild() {{{1 +" wrapper for the jump to child method +function! s:jumpToLastChild(node) + call s:jumpToChild(a:node, 1) +endfunction + +" FUNCTION: s:jumpToParent(node) {{{1 +" moves the cursor to the parent of the current node +function! s:jumpToParent(node) + if !empty(a:node.parent) + call a:node.parent.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() + else + call nerdtree#echo("cannot jump to parent") + endif +endfunction + +" FUNCTION: s:jumpToRoot() {{{1 +" moves the cursor to the root node +function! s:jumpToRoot() + call b:NERDTree.root.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:jumpToNextSibling(node) {{{1 +function! s:jumpToNextSibling(node) + call s:jumpToSibling(a:node, 1) +endfunction + +" FUNCTION: s:jumpToPrevSibling(node) {{{1 +function! s:jumpToPrevSibling(node) + call s:jumpToSibling(a:node, 0) +endfunction + +" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2 +" moves the cursor to the sibling of the current node in the given direction +" +" Args: +" forward: 1 if the cursor should move to the next sibling, 0 if it should +" move back to the previous sibling +function! s:jumpToSibling(currentNode, forward) + let sibling = a:currentNode.findSibling(a:forward) + + if !empty(sibling) + call sibling.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() + endif +endfunction + +" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 +" put the cursor on the given bookmark and, if its a file, open it +function! nerdtree#ui_glue#openBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) + call targetNode.putCursorHere(0, 1) + redraw! + catch /^NERDTree.BookmarkedNodeNotFoundError/ + call nerdtree#echo("note - target node is not cached") + let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree) + endtry + if targetNode.path.isDirectory + call targetNode.openExplorer() + else + call targetNode.open({'where': 'p'}) + endif +endfunction + +" FUNCTION: s:openHSplit(target) {{{1 +function! s:openHSplit(target) + call a:target.activate({'where': 'h'}) +endfunction + +" FUNCTION: s:openVSplit(target) {{{1 +function! s:openVSplit(target) + call a:target.activate({'where': 'v'}) +endfunction + +" FUNCTION: s:openExplorer(node) {{{1 +function! s:openExplorer(node) + call a:node.openExplorer() +endfunction + +" FUNCTION: s:openInNewTab(target) {{{1 +function! s:openInNewTab(target) + call a:target.activate({'where': 't'}) +endfunction + +" FUNCTION: s:openInNewTabSilent(target) {{{1 +function! s:openInNewTabSilent(target) + call a:target.activate({'where': 't', 'stay': 1}) +endfunction + +" FUNCTION: s:openNodeRecursively(node) {{{1 +function! s:openNodeRecursively(node) + call nerdtree#echo("Recursively opening node. Please wait...") + call a:node.openRecursively() + call b:NERDTree.render() + redraw + call nerdtree#echo("Recursively opening node. Please wait... DONE") +endfunction + +"FUNCTION: s:previewNodeCurrent(node) {{{1 +function! s:previewNodeCurrent(node) + call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeHSplit(node) {{{1 +function! s:previewNodeHSplit(node) + call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeVSplit(node) {{{1 +function! s:previewNodeVSplit(node) + call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) +endfunction + +" FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1 +" put the cursor on the node associate with the given name +function! nerdtree#ui_glue#revealBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) + call targetNode.putCursorHere(0, 1) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echo("Bookmark isnt cached under the current root") + endtry +endfunction + +" FUNCTION: s:refreshRoot() {{{1 +" Reloads the current root. All nodes below this will be lost and the root dir +" will be reloaded. +function! s:refreshRoot() + call nerdtree#echo("Refreshing the root node. This could take a while...") + call b:NERDTree.root.refresh() + call b:NERDTree.render() + redraw + call nerdtree#echo("Refreshing the root node. This could take a while... DONE") +endfunction + +" FUNCTION: s:refreshCurrent(node) {{{1 +" refreshes the root for the current node +function! s:refreshCurrent(node) + let node = a:node + if !node.path.isDirectory + let node = node.parent + endif + + call nerdtree#echo("Refreshing node. This could take a while...") + call node.refresh() + call b:NERDTree.render() + redraw + call nerdtree#echo("Refreshing node. This could take a while... DONE") +endfunction + +" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 +function! nerdtree#ui_glue#setupCommands() + command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') + command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') + command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() + command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') + command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() + command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() + command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() + command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() +endfunction + +" Function: s:SID() {{{1 +function s:SID() + if !exists("s:sid") + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun + +" FUNCTION: s:showMenu(node) {{{1 +function! s:showMenu(node) + let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) + call mc.showMenu() +endfunction + +" FUNCTION: s:toggleIgnoreFilter() {{{1 +function! s:toggleIgnoreFilter() + call b:NERDTree.ui.toggleIgnoreFilter() +endfunction + +" FUNCTION: s:toggleShowBookmarks() {{{1 +function! s:toggleShowBookmarks() + call b:NERDTree.ui.toggleShowBookmarks() +endfunction + +" FUNCTION: s:toggleShowFiles() {{{1 +function! s:toggleShowFiles() + call b:NERDTree.ui.toggleShowFiles() +endfunction + +" FUNCTION: s:toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:toggleShowHidden() + call b:NERDTree.ui.toggleShowHidden() +endfunction + +" FUNCTION: s:toggleZoom() {{{1 +function! s:toggleZoom() + call b:NERDTree.ui.toggleZoom() +endfunction + +"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1 +"moves the tree up a level +" +"Args: +"keepState: 1 if the current root should be left open when the tree is +"re-rendered +function! nerdtree#ui_glue#upDir(keepState) + let cwd = b:NERDTree.root.path.str({'format': 'UI'}) + if cwd ==# "/" || cwd =~# '^[^/]..$' + call nerdtree#echo("already at top dir") + else + if !a:keepState + call b:NERDTree.root.close() + endif + + let oldRoot = b:NERDTree.root + + if empty(b:NERDTree.root.parent) + let path = b:NERDTree.root.path.getParent() + let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree) + call newRoot.open() + call newRoot.transplantChild(b:NERDTree.root) + let b:NERDTree.root = newRoot + else + let b:NERDTree.root = b:NERDTree.root.parent + endif + + if g:NERDTreeChDirMode ==# 2 + call b:NERDTree.root.path.changeToDir() + endif + + call b:NERDTree.render() + call oldRoot.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: s:upDirCurrentRootOpen() {{{1 +function! s:upDirCurrentRootOpen() + call nerdtree#ui_glue#upDir(1) +endfunction + +" FUNCTION: s:upDirCurrentRootClosed() {{{1 +function! s:upDirCurrentRootClosed() + call nerdtree#ui_glue#upDir(0) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/doc/NERD_tree.txt b/vim/bundle/nerdtree/doc/NERD_tree.txt new file mode 100644 index 0000000..d0af4a8 --- /dev/null +++ b/vim/bundle/nerdtree/doc/NERD_tree.txt @@ -0,0 +1,1253 @@ +*NERD_tree.txt* A tree explorer plugin that owns your momma! + + + + omg its ... ~ + + ________ ________ _ ____________ ____ __________ ____________~ + /_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~ + / / / /_/ / __/ / |/ / __/ / /_/ / / / / / / / /_/ / __/ / __/ ~ + / / / __ / /___ / /| / /___/ _, _/ /_/ / / / / _, _/ /___/ /___ ~ + /_/ /_/ /_/_____/ /_/ |_/_____/_/ |_/_____/ /_/ /_/ |_/_____/_____/ ~ + + + Reference Manual~ + + + + +============================================================================== +CONTENTS *NERDTree-contents* + + 1.Intro...................................|NERDTree| + 2.Functionality provided..................|NERDTreeFunctionality| + 2.1.Global commands...................|NERDTreeGlobalCommands| + 2.2.Bookmarks.........................|NERDTreeBookmarks| + 2.2.1.The bookmark table..........|NERDTreeBookmarkTable| + 2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands| + 2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks| + 2.3.NERD tree mappings................|NERDTreeMappings| + 2.4.The NERD tree menu................|NERDTreeMenu| + 3.Options.................................|NERDTreeOptions| + 3.1.Option summary....................|NERDTreeOptionSummary| + 3.2.Option details....................|NERDTreeOptionDetails| + 4.The NERD tree API.......................|NERDTreeAPI| + 4.1.Key map API.......................|NERDTreeKeymapAPI| + 4.2.Menu API..........................|NERDTreeMenuAPI| + 4.3.Menu API..........................|NERDTreeAddPathFilter()| + 4.4.Path Listener API.................|NERDTreePathListenerAPI| + 5.About...................................|NERDTreeAbout| + 6.License.................................|NERDTreeLicense| + +============================================================================== +1. Intro *NERDTree* + +What is this "NERD tree"?? + +The NERD tree allows you to explore your filesystem and to open files and +directories. It presents the filesystem to you in the form of a tree which you +manipulate with the keyboard and/or mouse. It also allows you to perform +simple filesystem operations. + +The following features and functionality are provided by the NERD tree: + * Files and directories are displayed in a hierarchical tree structure + * Different highlighting is provided for the following types of nodes: + * files + * directories + * sym-links + * windows .lnk files + * read-only files + * executable files + * Many (customisable) mappings are provided to manipulate the tree: + * Mappings to open/close/explore directory nodes + * Mappings to open files in new/existing windows/tabs + * Mappings to change the current root of the tree + * Mappings to navigate around the tree + * ... + * Directories and files can be bookmarked. + * Most NERD tree navigation can also be done with the mouse + * Filtering of tree content (can be toggled at runtime) + * custom file filters to prevent e.g. vim backup files being displayed + * optional displaying of hidden files (. files) + * files can be "turned off" so that only directories are displayed + * The position and size of the NERD tree window can be customised + * The order in which the nodes in the tree are listed can be customised. + * A model of your filesystem is created/maintained as you explore it. This + has several advantages: + * All filesystem information is cached and is only re-read on demand + * If you revisit a part of the tree that you left earlier in your + session, the directory nodes will be opened/closed as you left them + * The script remembers the cursor position and window position in the NERD + tree so you can toggle it off (or just close the tree window) and then + reopen it (with NERDTreeToggle) the NERD tree window will appear exactly + as you left it + * You can have a separate NERD tree for each tab, share trees across tabs, + or a mix of both. + * By default the script overrides the default file browser (netrw), so if + you :edit a directory a (slightly modified) NERD tree will appear in the + current window + * A programmable menu system is provided (simulates right clicking on a + node) + * one default menu plugin is provided to perform basic filesystem + operations (create/delete/move/copy files/directories) + * There's an API for adding your own keymappings + + +============================================================================== +2. Functionality provided *NERDTreeFunctionality* + +------------------------------------------------------------------------------ +2.1. Global Commands *NERDTreeGlobalCommands* + +:NERDTree [ | ] *:NERDTree* + Opens a fresh NERD tree. The root of the tree depends on the argument + given. There are 3 cases: If no argument is given, the current directory + will be used. If a directory is given, that will be used. If a bookmark + name is given, the corresponding directory will be used. For example: > + :NERDTree /home/marty/vim7/src + :NERDTree foo (foo is the name of a bookmark) +< +:NERDTreeFromBookmark *:NERDTreeFromBookmark* + Opens a fresh NERD tree with the root initialized to the dir for + . The only reason to use this command over :NERDTree is for + the completion (which is for bookmarks rather than directories). + +:NERDTreeToggle [ | ] *:NERDTreeToggle* + If a NERD tree already exists for this tab, it is reopened and rendered + again. If no NERD tree exists for this tab then this command acts the + same as the |:NERDTree| command. + +:NERDTreeMirror *:NERDTreeMirror* + Shares an existing NERD tree, from another tab, in the current tab. + Changes made to one tree are reflected in both as they are actually the + same buffer. + + If only one other NERD tree exists, that tree is automatically mirrored. If + more than one exists, the script will ask which tree to mirror. + +:NERDTreeClose *:NERDTreeClose* + Close the NERD tree in this tab. + +:NERDTreeFind *:NERDTreeFind* + Find the current file in the tree. + + If no tree exists and the current file is under vim's CWD, then init a + tree at the CWD and reveal the file. Otherwise init a tree in the current + file's directory. + + In any case, the current file is revealed and the cursor is placed on it. + +:NERDTreeCWD *:NERDTreeCWD* + Change tree root to current directory. If no NERD tree exists for this + tab, a new tree will be opened. + +------------------------------------------------------------------------------ +2.2. Bookmarks *NERDTreeBookmarks* + +Bookmarks in the NERD tree are a way to tag files or directories of interest. +For example, you could use bookmarks to tag all of your project directories. + +------------------------------------------------------------------------------ +2.2.1. The Bookmark Table *NERDTreeBookmarkTable* + +If the bookmark table is active (see |NERDTree-B| and +|'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double +click bookmarks or use the |NERDTree-o| mapping to activate them. See also, +|NERDTree-t| and |NERDTree-T| + +------------------------------------------------------------------------------ +2.2.2. Bookmark commands *NERDTreeBookmarkCommands* + +Note that the following commands are only available in the NERD tree buffer. + +:Bookmark [] + Bookmark the current node as . If there is already a + bookmark, it is overwritten. must not contain spaces. + If is not provided, it defaults to the file or directory name. + For directories, a trailing slash is present. + +:BookmarkToRoot + Make the directory corresponding to the new root. If a treenode + corresponding to is already cached somewhere in the tree then + the current tree will be used, otherwise a fresh tree will be opened. + Note that if points to a file then its parent will be used + instead. + +:RevealBookmark + If the node is cached under the current root then it will be revealed + (i.e. directory nodes above it will be opened) and the cursor will be + placed on it. + +:OpenBookmark + must point to a file. The file is opened as though |NERDTree-o| + was applied. If the node is cached under the current root then it will be + revealed and the cursor will be placed on it. + +:ClearBookmarks [] + Remove all the given bookmarks. If no bookmarks are given then remove all + bookmarks on the current node. + +:ClearAllBookmarks + Remove all bookmarks. + +:ReadBookmarks + Re-read the bookmarks in the |'NERDTreeBookmarksFile'|. + +See also |:NERDTree| and |:NERDTreeFromBookmark|. + +------------------------------------------------------------------------------ +2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks* + +If invalid bookmarks are detected, the script will issue an error message and +the invalid bookmarks will become unavailable for use. + +These bookmarks will still be stored in the bookmarks file (see +|'NERDTreeBookmarksFile'|), down the bottom. There will always be a blank line +after the valid bookmarks but before the invalid ones. + +Each line in the bookmarks file represents one bookmark. The proper format is: + + +After you have corrected any invalid bookmarks, either restart vim, or go +:ReadBookmarks from the NERD tree window. + +------------------------------------------------------------------------------ +2.3. NERD tree Mappings *NERDTreeMappings* + +Default Description~ help-tag~ +Key~ + +o.......Open files, directories and bookmarks....................|NERDTree-o| +go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go| +t.......Open selected node/bookmark in a new tab.................|NERDTree-t| +T.......Same as 't' but keep the focus on the current tab........|NERDTree-T| +i.......Open selected file in a split window.....................|NERDTree-i| +gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi| +s.......Open selected file in a new vsplit.......................|NERDTree-s| +gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs| +O.......Recursively open the selected directory..................|NERDTree-O| +x.......Close the current nodes parent...........................|NERDTree-x| +X.......Recursively close all children of the current node.......|NERDTree-X| +e.......Edit the current dir.....................................|NERDTree-e| + +...............same as |NERDTree-o|. +double-click.......same as the |NERDTree-o| map. +middle-click.......same as |NERDTree-i| for files, same as + |NERDTree-e| for dirs. + +D.......Delete the current bookmark .............................|NERDTree-D| + +P.......Jump to the root node....................................|NERDTree-P| +p.......Jump to current nodes parent.............................|NERDTree-p| +K.......Jump up inside directories at the current tree depth.....|NERDTree-K| +J.......Jump down inside directories at the current tree depth...|NERDTree-J| +...Jump down to the next sibling of the current directory...|NERDTree-C-J| +...Jump up to the previous sibling of the current directory.|NERDTree-C-K| + +C.......Change the tree root to the selected dir.................|NERDTree-C| +u.......Move the tree root up one directory......................|NERDTree-u| +U.......Same as 'u' except the old root node is left open........|NERDTree-U| +r.......Recursively refresh the current directory................|NERDTree-r| +R.......Recursively refresh the current root.....................|NERDTree-R| +m.......Display the NERD tree menu...............................|NERDTree-m| +cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| +CD......Change tree root to the CWD..............................|NERDTree-CD| + +I.......Toggle whether hidden files displayed....................|NERDTree-I| +f.......Toggle whether the file filters are used.................|NERDTree-f| +F.......Toggle whether files are displayed.......................|NERDTree-F| +B.......Toggle whether the bookmark table is displayed...........|NERDTree-B| + +q.......Close the NERDTree window................................|NERDTree-q| +A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A| +?.......Toggle the display of the quick help.....................|NERDTree-?| + +------------------------------------------------------------------------------ + *NERDTree-o* +Default key: o +Map option: NERDTreeMapActivateNode +Applies to: files and directories. + +If a file node is selected, it is opened in the previous window. + +If a directory is selected it is opened or closed depending on its current +state. + +If a bookmark that links to a directory is selected then that directory +becomes the new root. + +If a bookmark that links to a file is selected then that file is opened in the +previous window. + +------------------------------------------------------------------------------ + *NERDTree-go* +Default key: go +Map option: None +Applies to: files. + +If a file node is selected, it is opened in the previous window, but the +cursor does not move. + +The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see +|NERDTree-o|). + +------------------------------------------------------------------------------ + *NERDTree-t* +Default key: t +Map option: NERDTreeMapOpenInTab +Applies to: files and directories. + +Opens the selected file in a new tab. If a directory is selected, a fresh +NERD Tree for that directory is opened in a new tab. + +If a bookmark which points to a directory is selected, open a NERD tree for +that directory in a new tab. If the bookmark points to a file, open that file +in a new tab. + +------------------------------------------------------------------------------ + *NERDTree-T* +Default key: T +Map option: NERDTreeMapOpenInTabSilent +Applies to: files and directories. + +The same as |NERDTree-t| except that the focus is kept in the current tab. + +------------------------------------------------------------------------------ + *NERDTree-i* +Default key: i +Map option: NERDTreeMapOpenSplit +Applies to: files. + +Opens the selected file in a new split window and puts the cursor in the new +window. + +------------------------------------------------------------------------------ + *NERDTree-gi* +Default key: gi +Map option: None +Applies to: files. + +The same as |NERDTree-i| except that the cursor is not moved. + +The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see +|NERDTree-i|). + +------------------------------------------------------------------------------ + *NERDTree-s* +Default key: s +Map option: NERDTreeMapOpenVSplit +Applies to: files. + +Opens the selected file in a new vertically split window and puts the cursor in +the new window. + +------------------------------------------------------------------------------ + *NERDTree-gs* +Default key: gs +Map option: None +Applies to: files. + +The same as |NERDTree-s| except that the cursor is not moved. + +The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see +|NERDTree-s|). + +------------------------------------------------------------------------------ + *NERDTree-O* +Default key: O +Map option: NERDTreeMapOpenRecursively +Applies to: directories. + +Recursively opens the selected directory. + +All files and directories are cached, but if a directory would not be +displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the +hidden file filter (see |'NERDTreeShowHidden'|) then its contents are not +cached. This is handy, especially if you have .svn directories. + +------------------------------------------------------------------------------ + *NERDTree-x* +Default key: x +Map option: NERDTreeMapCloseDir +Applies to: files and directories. + +Closes the parent of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-X* +Default key: X +Map option: NERDTreeMapCloseChildren +Applies to: directories. + +Recursively closes all children of the selected directory. + +Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. + +------------------------------------------------------------------------------ + *NERDTree-e* +Default key: e +Map option: NERDTreeMapOpenExpl +Applies to: files and directories. + +|:edit|s the selected directory, or the selected file's directory. This could +result in a NERD tree or a netrw being opened, depending on +|'NERDTreeHijackNetrw'|. + +------------------------------------------------------------------------------ + *NERDTree-D* +Default key: D +Map option: NERDTreeMapDeleteBookmark +Applies to: lines in the bookmarks table + +Deletes the currently selected bookmark. + +------------------------------------------------------------------------------ + *NERDTree-P* +Default key: P +Map option: NERDTreeMapJumpRoot +Applies to: no restrictions. + +Jump to the tree root. + +------------------------------------------------------------------------------ + *NERDTree-p* +Default key: p +Map option: NERDTreeMapJumpParent +Applies to: files and directories. + +Jump to the parent node of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-K* +Default key: K +Map option: NERDTreeMapJumpFirstChild +Applies to: files and directories. + +Jump to the first child of the current nodes parent. + +If the cursor is already on the first node then do the following: + * loop back thru the siblings of the current nodes parent until we find an + open dir with children + * go to the first child of that node + +------------------------------------------------------------------------------ + *NERDTree-J* +Default key: J +Map option: NERDTreeMapJumpLastChild +Applies to: files and directories. + +Jump to the last child of the current nodes parent. + +If the cursor is already on the last node then do the following: + * loop forward thru the siblings of the current nodes parent until we find + an open dir with children + * go to the last child of that node + +------------------------------------------------------------------------------ + *NERDTree-C-J* +Default key: +Map option: NERDTreeMapJumpNextSibling +Applies to: files and directories. + +Jump to the next sibling of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-C-K* +Default key: +Map option: NERDTreeMapJumpPrevSibling +Applies to: files and directories. + +Jump to the previous sibling of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-C* +Default key: C +Map option: NERDTreeMapChangeRoot +Applies to: files and directories. + +Make the selected directory node the new tree root. If a file is selected, its +parent is used. + +------------------------------------------------------------------------------ + *NERDTree-u* +Default key: u +Map option: NERDTreeMapUpdir +Applies to: no restrictions. + +Move the tree root up a dir (like doing a "cd .."). + +------------------------------------------------------------------------------ + *NERDTree-U* +Default key: U +Map option: NERDTreeMapUpdirKeepOpen +Applies to: no restrictions. + +Like |NERDTree-u| except that the old tree root is kept open. + +------------------------------------------------------------------------------ + *NERDTree-r* +Default key: r +Map option: NERDTreeMapRefresh +Applies to: files and directories. + +If a dir is selected, recursively refresh that dir, i.e. scan the filesystem +for changes and represent them in the tree. + +If a file node is selected then the above is done on it's parent. + +------------------------------------------------------------------------------ + *NERDTree-R* +Default key: R +Map option: NERDTreeMapRefreshRoot +Applies to: no restrictions. + +Recursively refresh the tree root. + +------------------------------------------------------------------------------ + *NERDTree-m* +Default key: m +Map option: NERDTreeMapMenu +Applies to: files and directories. + +Display the NERD tree menu. See |NERDTreeMenu| for details. + +------------------------------------------------------------------------------ + *NERDTree-cd* +Default key: cd +Map option: NERDTreeMapChdir +Applies to: files and directories. + +Change vims current working directory to that of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-CD* +Default key: CD +Map option: NERDTreeMapCWD +Applies to: no restrictions. + +Change tree root to vims current working directory. + +------------------------------------------------------------------------------ + *NERDTree-I* +Default key: I +Map option: NERDTreeMapToggleHidden +Applies to: no restrictions. + +Toggles whether hidden files (i.e. "dot files") are displayed. + +------------------------------------------------------------------------------ + *NERDTree-f* +Default key: f +Map option: NERDTreeMapToggleFilters +Applies to: no restrictions. + +Toggles whether file filters are used. See |'NERDTreeIgnore'| for details. + +------------------------------------------------------------------------------ + *NERDTree-F* +Default key: F +Map option: NERDTreeMapToggleFiles +Applies to: no restrictions. + +Toggles whether file nodes are displayed. + +------------------------------------------------------------------------------ + *NERDTree-B* +Default key: B +Map option: NERDTreeMapToggleBookmarks +Applies to: no restrictions. + +Toggles whether the bookmarks table is displayed. + +------------------------------------------------------------------------------ + *NERDTree-q* +Default key: q +Map option: NERDTreeMapQuit +Applies to: no restrictions. + +Closes the NERDtree window. + +------------------------------------------------------------------------------ + *NERDTree-A* +Default key: A +Map option: NERDTreeMapToggleZoom +Applies to: no restrictions. + +Maximize (zoom) and minimize the NERDtree window. + +------------------------------------------------------------------------------ + *NERDTree-?* +Default key: ? +Map option: NERDTreeMapHelp +Applies to: no restrictions. + +Toggles whether the quickhelp is displayed. + +------------------------------------------------------------------------------ +2.3. The NERD tree menu *NERDTreeMenu* + +The NERD tree has a menu that can be programmed via the an API (see +|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most +file explorers have. + +The script comes with two default menu plugins: exec_menuitem.vim and +fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for +creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a +menu item to execute executable files. + +Related tags: |NERDTree-m| |NERDTreeApi| + +============================================================================== +3. Customisation *NERDTreeOptions* + + +------------------------------------------------------------------------------ +3.1. Customisation summary *NERDTreeOptionSummary* + +The script provides the following options that can customise the behaviour the +NERD tree. These options should be set in your vimrc. + +|'loaded_nerd_tree'| Turns off the script. + +|'NERDTreeAutoCenter'| Controls whether the NERD tree window centers + when the cursor moves within a specified + distance to the top/bottom of the window. + +|'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering. + +|'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case + sensitive or not when sorting nodes. + +|'NERDTreeSortHiddenFirst'| Tells the NERD tree whether to take the dot + at the beginning of the hidden file names + into account when sorting nodes. + +|'NERDTreeChDirMode'| Tells the NERD tree if/when it should change + vim's current working directory. + +|'NERDTreeHighlightCursorline'| Tell the NERD tree whether to highlight the + current cursor line. + +|'NERDTreeHijackNetrw'| Tell the NERD tree whether to replace the netrw + autocommands for exploring local directories. + +|'NERDTreeIgnore'| Tells the NERD tree which files to ignore. + +|'NERDTreeRespectWildIgnore'| Tells the NERD tree to respect |'wildignore'|. + +|'NERDTreeBookmarksFile'| Where the bookmarks are stored. + +|'NERDTreeBookmarksSort'| Whether the bookmarks list is sorted on + display. + +|'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse + clicks. + +|'NERDTreeQuitOnOpen'| Closes the tree window after opening a file. + +|'NERDTreeShowBookmarks'| Tells the NERD tree whether to display the + bookmarks table on startup. + +|'NERDTreeShowFiles'| Tells the NERD tree whether to display files + in the tree on startup. + +|'NERDTreeShowHidden'| Tells the NERD tree whether to display hidden + files on startup. + +|'NERDTreeShowLineNumbers'| Tells the NERD tree whether to display line + numbers in the tree window. + +|'NERDTreeSortOrder'| Tell the NERD tree how to sort the nodes in + the tree. + +|'NERDTreeStatusline'| Set a statusline for NERD tree windows. + +|'NERDTreeWinPos'| Tells the script where to put the NERD tree + window. + +|'NERDTreeWinSize'| Sets the window size when the NERD tree is + opened. + +|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and + 'Press ? for help' text. + +|'NERDTreeCascadeSingleChildDir'| + Collapses on the same line directories that + have only one child directory. + +|'NERDTreeCascadeOpenSingleChildDir'| + Cascade open while selected directory has only + one child that also is a directory. + +|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove + a buffer when a file is being deleted or renamed + via a context menu command. + +|'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the + NERDTree window. + +------------------------------------------------------------------------------ +3.2. Customisation details *NERDTreeOptionDetails* + +To enable any of the below options you should put the given line in your +~/.vimrc + + *'loaded_nerd_tree'* +If this plugin is making you feel homicidal, it may be a good idea to turn it +off with this line in your vimrc: > + let loaded_nerd_tree=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeAutoCenter'* +Values: 0 or 1. +Default: 1 + +If set to 1, the NERD tree window will center around the cursor if it moves to +within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window. + +This is ONLY done in response to tree navigation mappings, +i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p| +|NERDTree-P| + +The centering is done with a |zz| operation. + +------------------------------------------------------------------------------ + *'NERDTreeAutoCenterThreshold'* +Values: Any natural number. +Default: 3 + +This option controls the "sensitivity" of the NERD tree auto centering. See +|'NERDTreeAutoCenter'| for details. + +------------------------------------------------------------------------------ + *'NERDTreeCaseSensitiveSort'* +Values: 0 or 1. +Default: 0. + +By default the NERD tree does not sort nodes case sensitively, i.e. nodes +could appear like this: > + bar.c + Baz.c + blarg.c + boner.c + Foo.c +< +But, if you set this option to 1 then the case of the nodes will be taken into +account. The above nodes would then be sorted like this: > + Baz.c + Foo.c + bar.c + blarg.c + boner.c +< +------------------------------------------------------------------------------ + *'NERDTreeChDirMode'* + +Values: 0, 1 or 2. +Default: 0. + +Use this option to tell the script when (if at all) to change the current +working directory (CWD) for vim. + +If it is set to 0 then the CWD is never changed by the NERD tree. + +If set to 1 then the CWD is changed when the NERD tree is first loaded to the +directory it is initialized in. For example, if you start the NERD tree with > + :NERDTree /home/marty/foobar +< +then the CWD will be changed to /home/marty/foobar and will not be changed +again unless you init another NERD tree with a similar command. + +If the option is set to 2 then it behaves the same as if set to 1 except that +the CWD is changed whenever the tree root is changed. For example, if the CWD +is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new +root then the CWD will become /home/marty/foobar/baz. + +------------------------------------------------------------------------------ + *'NERDTreeHighlightCursorline'* +Values: 0 or 1. +Default: 1. + +If set to 1, the current cursor line in the NERD tree buffer will be +highlighted. This is done using the |'cursorline'| option. + +------------------------------------------------------------------------------ + *'NERDTreeHijackNetrw'* +Values: 0 or 1. +Default: 1. + +If set to 1, doing a > + :edit +< +will open up a window level NERD tree instead of a netrw in the target window. + +Window level trees behaves slightly different from a regular trees in the +following respects: + 1. 'o' will open the selected file in the same window as the tree, + replacing it. + 2. you can have one tree per window - instead of per tab. + +------------------------------------------------------------------------------ + *'NERDTreeIgnore'* +Values: a list of regular expressions. +Default: ['\~$']. + +This option is used to specify which files the NERD tree should ignore. It +must be a list of regular expressions. When the NERD tree is rendered, any +files/dirs that match any of the regex's in 'NERDTreeIgnore' wont be +displayed. + +For example if you put the following line in your vimrc: > + let NERDTreeIgnore=['\.vim$', '\~$'] +< +then all files ending in .vim or ~ will be ignored. + +There are 2 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only files or only dirs. +These flags are "[[dir]]" and "[[file]]". Example: > + let NERDTreeIgnore=['.d$[[dir]]', '.o$[[file]]'] +< +This will cause all dirs ending in ".d" to be ignored and all files ending in +".o" to be ignored. + +Note: to tell the NERD tree not to ignore any files you must use the following +line: > + let NERDTreeIgnore=[] +< + +The file filters can be turned on and off dynamically with the |NERDTree-f| +mapping. + +------------------------------------------------------------------------------ + *'NERDTreeRespectWildIgnore'* +Values: 0 or 1. +Default: 0. + +If set to 1, the |'wildignore'| setting is respected. + +------------------------------------------------------------------------------ + *'NERDTreeBookmarksFile'* +Values: a path +Default: $HOME/.NERDTreeBookmarks + +This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. + +------------------------------------------------------------------------------ + *'NERDTreeBookmarksSort'* +Values: 0 or 1 +Default: 1 + +If set to 0 then the bookmarks list is not sorted. +If set to 1 the bookmarks list is sorted. + +------------------------------------------------------------------------------ + *'NERDTreeMouseMode'* +Values: 1, 2 or 3. +Default: 1. + +If set to 1 then a double click on a node is required to open it. +If set to 2 then a single click will open directory nodes, while a double +click will still be required for file nodes. +If set to 3 then a single click will open any node. + +Note: a double click anywhere on a line that a tree node is on will +activate it, but all single-click activations must be done on name of the node +itself. For example, if you have the following node: > + | | |-application.rb +< +then (to single click activate it) you must click somewhere in +'application.rb'. + +------------------------------------------------------------------------------ + *'NERDTreeQuitOnOpen'* + +Values: 0 or 1. +Default: 0 + +If set to 1, the NERD tree window will close after opening a file with the +|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings. + +------------------------------------------------------------------------------ + *'NERDTreeShowBookmarks'* +Values: 0 or 1. +Default: 0. + +If this option is set to 1 then the bookmarks table will be displayed. + +This option can be toggled dynamically, per tree, with the |NERDTree-B| +mapping. + +------------------------------------------------------------------------------ + *'NERDTreeShowFiles'* +Values: 0 or 1. +Default: 1. + +If this option is set to 1 then files are displayed in the NERD tree. If it is +set to 0 then only directories are displayed. + +This option can be toggled dynamically, per tree, with the |NERDTree-F| +mapping and is useful for drastically shrinking the tree when you are +navigating to a different part of the tree. + +------------------------------------------------------------------------------ + *'NERDTreeShowHidden'* +Values: 0 or 1. +Default: 0. + +This option tells vim whether to display hidden files by default. This option +can be dynamically toggled, per tree, with the |NERDTree-I| mapping. Use one +of the follow lines to set this option: > + let NERDTreeShowHidden=0 + let NERDTreeShowHidden=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeShowLineNumbers'* +Values: 0 or 1. +Default: 0. + +This option tells vim whether to display line numbers for the NERD tree +window. Use one of the follow lines to set this option: > + let NERDTreeShowLineNumbers=0 + let NERDTreeShowLineNumbers=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeSortOrder'* +Values: a list of regular expressions. +Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] + +This option is set to a list of regular expressions which are used to +specify the order of nodes under their parent. + +For example, if the option is set to: > + ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] +< +then all .vim files will be placed at the top, followed by all .c files then +all .h files. All files containing the string 'foobar' will be placed at the +end. The star is a special flag: it tells the script that every node that +doesnt match any of the other regexps should be placed here. + +If no star is present in 'NERDTreeSortOrder' then one is automatically +appended to the array. + +The regex '\/$' should be used to match directory nodes. + +After this sorting is done, the files in each group are sorted alphabetically. + +Other examples: > + (1) ['*', '\/$'] + (2) [] + (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] +< +1. Directories will appear last, everything else will appear above. +2. Everything will simply appear in alphabetical order. +3. Dirs will appear first, then ruby and php. Swap files, bak files and vim + backup files will appear last with everything else preceding them. + +------------------------------------------------------------------------------ + *'NERDTreeStatusline'* +Values: Any valid statusline setting. +Default: %{b:NERDTree.root.path.strForOS(0)} + +Tells the script what to use as the |'statusline'| setting for NERD tree +windows. + +Note that the statusline is set using |:let-&| not |:set| so escaping spaces +isn't necessary. + +Setting this option to -1 will will deactivate it so that your global +statusline setting is used instead. + +------------------------------------------------------------------------------ + *'NERDTreeWinPos'* +Values: "left" or "right" +Default: "left". + +This option is used to determine where NERD tree window is placed on the +screen. + +This option makes it possible to use two different explorer plugins +simultaneously. For example, you could have the taglist plugin on the left of +the window and the NERD tree on the right. + +------------------------------------------------------------------------------ + *'NERDTreeWinSize'* +Values: a positive integer. +Default: 31. + +This option is used to change the size of the NERD tree when it is loaded. + +------------------------------------------------------------------------------ + *'NERDTreeMinimalUI'* +Values: 0 or 1 +Default: 0 + +This options disables the 'Bookmarks' label 'Press ? for help' text. Use one +of the following lines to set this option: > + let NERDTreeMinimalUI=0 + let NERDTreeMinimalUI=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeCascadeSingleChildDir'* +Values: 0 or 1 +Default: 1. + +When displaying dir nodes, this option tells NERDTree to collapse dirs that +have only one child. Use one of the follow lines to set this option: > + let NERDTreeCascadeSingleChildDir=0 + let NERDTreeCascadeSingleChildDir=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeCascadeOpenSingleChildDir'* +Values: 0 or 1 +Default: 1. + +When opening dir nodes, this option tells NERDTree to recursively open dirs +that have only one child which is also a dir. NERDTree will stop when it finds +a dir that contains anything but another single dir. This option also causes +the |NERDTree-x| mapping to close dirs in the same manner. This option may be +useful for Java projects. Use one of the follow lines to set this option: > + let NERDTreeCascadeOpenSingleChildDir=0 + let NERDTreeCascadeOpenSingleChildDir=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeAutoDeleteBuffer'* +Values: 0 or 1 +Default: 0. + +When using a context menu to delete or rename a file you may also want to delete +the buffer which is no more valid. If the option is not set you will see a +confirmation if you really want to delete an old buffer. If you always press 'y' +then it worths to set this option to 1. Use one of the follow lines to set this +option: > + let NERDTreeAutoDeleteBuffer=0 + let NERDTreeAutoDeleteBuffer=1 +< +------------------------------------------------------------------------------ + *'NERDTreeCreatePrefix'* +Values: Any valid command prefix. +Default: "silent". + +Internally, NERDTree uses the |:edit| command to create a buffer in which to +display its tree view. You can augment this behavior by specifying a prefix +string such as "keepalt" or similar. For example, to have NERDTree create its +tree window using `silent keepalt keepjumps edit`: + let NERDTreeCreatePrefix='silent keepalt keepjumps' +< + +============================================================================== +4. The NERD tree API *NERDTreeAPI* + +The NERD tree script allows you to add custom key mappings and menu items via +a set of API calls. Any scripts that use this API should be placed in +~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows). + +The script exposes some prototype objects that can be used to manipulate the +tree and/or get information from it: > + g:NERDTreePath + g:NERDTreeDirNode + g:NERDTreeFileNode + g:NERDTreeBookmark +< +See the code/comments in NERD_tree.vim to find how to use these objects. The +following code conventions are used: + * class members start with a capital letter + * instance members start with a lower case letter + * private members start with an underscore + +See this blog post for more details: + http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html + +------------------------------------------------------------------------------ +4.1. Key map API *NERDTreeKeymapAPI* + +NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* + Adds a new keymapping for all NERD tree buffers. + {options} must be a dictionary, and must contain the following keys: + "key" - the trigger key for the new mapping + "callback" - the function the new mapping will be bound to + "quickhelpText" - the text that will appear in the quickhelp (see + |NERDTree-?|) + "override" - if 1 then this new mapping will override whatever previous + mapping was defined for the key/scope combo. Useful for overriding the + default mappings. + + Additionally, a "scope" argument may be supplied. This constrains the + mapping so that it is only activated if the cursor is on a certain object. + That object is then passed into the handling method. Possible values are: + "FileNode" - a file node + "DirNode" - a directory node + "Node" - a file or directory node + "Bookmark" - A bookmark + "all" - the keymap is not constrained to any scope (default). When + thei is used, the handling function is not passed any arguments. + + + Example: > + call NERDTreeAddKeyMap({ + \ 'key': 'foo', + \ 'callback': 'NERDTreeCDHandler', + \ 'quickhelpText': 'echo full path of current node', + \ 'scope': 'DirNode' }) + + function! NERDTreeCDHandler(dirnode) + call a:dirnode.changeToDir() + endfunction +< + This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. + It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of + the current dir node. Note this mapping will only fire when the cursor is + on a directory node. + +------------------------------------------------------------------------------ +4.2. Menu API *NERDTreeMenuAPI* + +NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* + Creates and returns a new submenu. + + {options} must be a dictionary and must contain the following keys: + "text" - the text of the submenu that the user will see + "shortcut" - a shortcut key for the submenu (need not be unique) + + The following keys are optional: + "isActiveCallback" - a function that will be called to determine whether + this submenu item will be displayed or not. The callback function must return + 0 or 1. + "parent" - the parent submenu of the new submenu (returned from a previous + invocation of NERDTreeAddSubmenu()). If this key is left out then the new + submenu will sit under the top level menu. + + See below for an example. + +NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* + Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|). + + {options} must be a dictionary and must contain the + following keys: + "text" - the text of the menu item which the user will see + "shortcut" - a shortcut key for the menu item (need not be unique) + "callback" - the function that will be called when the user activates the + menu item. + + The following keys are optional: + "isActiveCallback" - a function that will be called to determine whether + this menu item will be displayed or not. The callback function must return + 0 or 1. + "parent" - if the menu item belongs under a submenu then this key must be + specified. This value for this key will be the object that + was returned when the submenu was created with |NERDTreeAddSubmenu()|. + + See below for an example. + +NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()* + Adds a menu separator (a row of dashes). + + {options} is an optional dictionary that may contain the following keys: + "isActiveCallback" - see description in |NERDTreeAddMenuItem()|. + +Below is an example of the menu API in action. > + call NERDTreeAddMenuSeparator() + + call NERDTreeAddMenuItem({ + \ 'text': 'a (t)op level menu item', + \ 'shortcut': 't', + \ 'callback': 'SomeFunction' }) + + let submenu = NERDTreeAddSubmenu({ + \ 'text': 'a (s)ub menu', + \ 'shortcut': 's' }) + + call NERDTreeAddMenuItem({ + \ 'text': '(n)ested item 1', + \ 'shortcut': 'n', + \ 'callback': 'SomeFunction', + \ 'parent': submenu }) + + call NERDTreeAddMenuItem({ + \ 'text': '(n)ested item 2', + \ 'shortcut': 'n', + \ 'callback': 'SomeFunction', + \ 'parent': submenu }) +< +This will create the following menu: > + -------------------- + a (t)op level menu item + a (s)ub menu +< +Where selecting "a (s)ub menu" will lead to a second menu: > + (n)ested item 1 + (n)ested item 2 +< +When any of the 3 concrete menu items are selected the function "SomeFunction" +will be called. + +------------------------------------------------------------------------------ +4.3 NERDTreeAddPathFilter(callback) *NERDTreeAddPathFilter()* + +Path filters are essentially a more powerful version of |NERDTreeIgnore|. +If the simple regex matching in |NERDTreeIgnore| is not enough then use +|NERDTreeAddPathFilter()| to add a callback function that paths will be +checked against when the decision to ignore them is made. Example > + + call NERDTreeAddPathFilter('MyFilter') + + function! MyFilter(params) + "params is a dict containing keys: 'nerdtree' and 'path' which are + "g:NERDTree and g:NERDTreePath objects + + "return 1 to ignore params['path'] or 0 otherwise + endfunction +< +------------------------------------------------------------------------------ +4.4 Path Listener API *NERDTreePathListenerAPI* + +Use this API if you want to run a callback for events on Path objects. E.G > + + call g:NERDTreePathNotifier.AddListener("init", "MyListener") + + ".... + + function! MyListener(event) + "This function will be called whenever a Path object is created. + + "a:event is an object that contains a bunch of relevant info - + "including the path in question. See lib/nerdtree/event.vim for details. + endfunction +< +Current events supported: + init ~ + refresh ~ + refreshFlags ~ + +------------------------------------------------------------------------------ +NERDTreeRender() *NERDTreeRender()* + Re-renders the NERD tree buffer. Useful if you change the state of the + tree and you want to it to be reflected in the UI. + +============================================================================== +5. About *NERDTreeAbout* + +The author of the NERD tree is a terrible terrible monster called Martyzilla +who gobbles up small children with milk and sugar for breakfast. + +He can be reached at martin.grenfell at gmail dot com. He would love to hear +from you, so feel free to send him suggestions and/or comments about this +plugin. Don't be shy --- the worst he can do is slaughter you and stuff you in +the fridge for later ;) + +The latest stable versions can be found at + http://www.vim.org/scripts/script.php?script_id=1658 + +The latest dev versions are on github + http://github.com/scrooloose/nerdtree + +============================================================================== +6. License *NERDTreeLicense* + +The NERD tree is released under the wtfpl. +See http://sam.zoy.org/wtfpl/COPYING. diff --git a/vim/bundle/nerdtree/lib/nerdtree/bookmark.vim b/vim/bundle/nerdtree/lib/nerdtree/bookmark.vim new file mode 100644 index 0000000..8124260 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/bookmark.vim @@ -0,0 +1,312 @@ +"CLASS: Bookmark +"============================================================ +let s:Bookmark = {} +let g:NERDTreeBookmark = s:Bookmark + +" FUNCTION: Bookmark.activate(nerdtree) {{{1 +function! s:Bookmark.activate(nerdtree, ...) + call self.open(a:nerdtree, a:0 ? a:1 : {}) +endfunction + +" FUNCTION: Bookmark.AddBookmark(name, path) {{{1 +" Class method to add a new bookmark to the list, if a previous bookmark exists +" with the same name, just update the path for that bookmark +function! s:Bookmark.AddBookmark(name, path) + for i in s:Bookmark.Bookmarks() + if i.name ==# a:name + let i.path = a:path + return + endif + endfor + call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) + if g:NERDTreeBookmarksSort ==# 1 + call s:Bookmark.Sort() + endif +endfunction + +" FUNCTION: Bookmark.Bookmarks() {{{1 +" Class method to get all bookmarks. Lazily initializes the bookmarks global +" variable +function! s:Bookmark.Bookmarks() + if !exists("g:NERDTreeBookmarks") + let g:NERDTreeBookmarks = [] + endif + return g:NERDTreeBookmarks +endfunction + +" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1 +" class method that returns 1 if a bookmark with the given name is found, 0 +" otherwise +function! s:Bookmark.BookmarkExistsFor(name) + try + call s:Bookmark.BookmarkFor(a:name) + return 1 + catch /^NERDTree.BookmarkNotFoundError/ + return 0 + endtry +endfunction + +" FUNCTION: Bookmark.BookmarkFor(name) {{{1 +" Class method to get the bookmark that has the given name. {} is return if no +" bookmark is found +function! s:Bookmark.BookmarkFor(name) + for i in s:Bookmark.Bookmarks() + if i.name ==# a:name + return i + endif + endfor + throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' +endfunction + +" FUNCTION: Bookmark.BookmarkNames() {{{1 +" Class method to return an array of all bookmark names +function! s:Bookmark.BookmarkNames() + let names = [] + for i in s:Bookmark.Bookmarks() + call add(names, i.name) + endfor + return names +endfunction + +" FUNCTION: Bookmark.CacheBookmarks(silent) {{{1 +" Class method to read all bookmarks from the bookmarks file initialize +" bookmark objects for each one. +" +" Args: +" silent - dont echo an error msg if invalid bookmarks are found +function! s:Bookmark.CacheBookmarks(silent) + if filereadable(g:NERDTreeBookmarksFile) + let g:NERDTreeBookmarks = [] + let g:NERDTreeInvalidBookmarks = [] + let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) + let invalidBookmarksFound = 0 + for i in bookmarkStrings + + "ignore blank lines + if i != '' + + let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') + let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') + let path = fnamemodify(path, ':p') + + try + let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path)) + call add(g:NERDTreeBookmarks, bookmark) + catch /^NERDTree.InvalidArgumentsError/ + call add(g:NERDTreeInvalidBookmarks, i) + let invalidBookmarksFound += 1 + endtry + endif + endfor + if invalidBookmarksFound + call s:Bookmark.Write() + if !a:silent + call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") + endif + endif + if g:NERDTreeBookmarksSort ==# 1 + call s:Bookmark.Sort() + endif + endif +endfunction + +" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1 +" Compare these two bookmarks for sorting purposes +function! s:Bookmark.compareTo(otherbookmark) + return a:otherbookmark.name < self.name +endfunction +" FUNCTION: Bookmark.ClearAll() {{{1 +" Class method to delete all bookmarks. +function! s:Bookmark.ClearAll() + for i in s:Bookmark.Bookmarks() + call i.delete() + endfor + call s:Bookmark.Write() +endfunction + +" FUNCTION: Bookmark.delete() {{{1 +" Delete this bookmark. If the node for this bookmark is under the current +" root, then recache bookmarks for its Path object +function! s:Bookmark.delete() + call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) + call s:Bookmark.Write() +endfunction + +" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 +" Gets the treenode for this bookmark +" +" Args: +" searchFromAbsoluteRoot: specifies whether we should search from the current +" tree root, or the highest cached node +function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) + let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root + let targetNode = searchRoot.findNode(self.path) + if empty(targetNode) + throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name + endif + return targetNode +endfunction + +" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 +" Class method that finds the bookmark with the given name and returns the +" treenode for it. +function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) + let bookmark = s:Bookmark.BookmarkFor(a:name) + return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot) +endfunction + +" FUNCTION: Bookmark.GetSelected() {{{1 +" returns the Bookmark the cursor is over, or {} +function! s:Bookmark.GetSelected() + let line = getline(".") + let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') + if name != line + try + return s:Bookmark.BookmarkFor(name) + catch /^NERDTree.BookmarkNotFoundError/ + return {} + endtry + endif + return {} +endfunction + +" FUNCTION: Bookmark.InvalidBookmarks() {{{1 +" Class method to get all invalid bookmark strings read from the bookmarks +" file +function! s:Bookmark.InvalidBookmarks() + if !exists("g:NERDTreeInvalidBookmarks") + let g:NERDTreeInvalidBookmarks = [] + endif + return g:NERDTreeInvalidBookmarks +endfunction + +" FUNCTION: Bookmark.mustExist() {{{1 +function! s:Bookmark.mustExist() + if !self.path.exists() + call s:Bookmark.CacheBookmarks(1) + throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". + \ self.name ."\" points to a non existing location: \"". self.path.str() + endif +endfunction + +" FUNCTION: Bookmark.New(name, path) {{{1 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.New(name, path) + if a:name =~# ' ' + throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name + endif + + let newBookmark = copy(self) + let newBookmark.name = a:name + let newBookmark.path = a:path + return newBookmark +endfunction + +" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1 +"Args: +" +"nerdtree: the tree to load open the bookmark in +" +"A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' (vertical split), 'h' +" (horizontal split), 't' (new tab) or 'p' (previous window). +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +" +function! s:Bookmark.open(nerdtree, ...) + let opts = a:0 ? a:1 : {} + + if self.path.isDirectory && !has_key(opts, 'where') + call self.toRoot(a:nerdtree) + else + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) + endif +endfunction + +" FUNCTION: Bookmark.openInNewTab(options) {{{1 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.openInNewTab(options) + call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') + call self.open(a:options) +endfunction + +" FUNCTION: Bookmark.setPath(path) {{{1 +" makes this bookmark point to the given path +function! s:Bookmark.setPath(path) + let self.path = a:path +endfunction + +" FUNCTION: Bookmark.Sort() {{{1 +" Class method that sorts all bookmarks +function! s:Bookmark.Sort() + let CompareFunc = function("nerdtree#compareBookmarks") + call sort(s:Bookmark.Bookmarks(), CompareFunc) +endfunction + +" FUNCTION: Bookmark.str() {{{1 +" Get the string that should be rendered in the view for this bookmark +function! s:Bookmark.str() + let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name) + if &nu + let pathStrMaxLen = pathStrMaxLen - &numberwidth + endif + + let pathStr = self.path.str({'format': 'UI'}) + if len(pathStr) > pathStrMaxLen + let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) + endif + return '>' . self.name . ' ' . pathStr +endfunction + +" FUNCTION: Bookmark.toRoot(nerdtree) {{{1 +" Make the node for this bookmark the new tree root +function! s:Bookmark.toRoot(nerdtree) + if self.validate() + try + let targetNode = self.getNode(a:nerdtree, 1) + catch /^NERDTree.BookmarkedNodeNotFoundError/ + let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) + endtry + call a:nerdtree.changeRoot(targetNode) + endif +endfunction + +" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1 +" Make the node for this bookmark the new tree root +function! s:Bookmark.ToRoot(name, nerdtree) + let bookmark = s:Bookmark.BookmarkFor(a:name) + call bookmark.toRoot(a:nerdtree) +endfunction + +" FUNCTION: Bookmark.validate() {{{1 +function! s:Bookmark.validate() + if self.path.exists() + return 1 + else + call s:Bookmark.CacheBookmarks(1) + call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") + return 0 + endif +endfunction + +" FUNCTION: Bookmark.Write() {{{1 +" Class method to write all bookmarks to the bookmarks file +function! s:Bookmark.Write() + let bookmarkStrings = [] + for i in s:Bookmark.Bookmarks() + call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~')) + endfor + + "add a blank line before the invalid ones + call add(bookmarkStrings, "") + + for j in s:Bookmark.InvalidBookmarks() + call add(bookmarkStrings, j) + endfor + call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/creator.vim b/vim/bundle/nerdtree/lib/nerdtree/creator.vim new file mode 100644 index 0000000..952811c --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/creator.vim @@ -0,0 +1,379 @@ +"CLASS: Creator +"Creates tab/window/mirror nerdtree windows. Sets up all the window and +"buffer options and key mappings etc. +"============================================================ +let s:Creator = {} +let g:NERDTreeCreator = s:Creator + +"FUNCTION: s:Creator._bindMappings() {{{1 +function! s:Creator._bindMappings() + "make do the same as the activate node mapping + nnoremap :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode) + + call g:NERDTreeKeyMap.BindAll() + + command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) + command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() + command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() + command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() +endfunction + +"FUNCTION: s:Creator._broadcastInitEvent() {{{1 +function! s:Creator._broadcastInitEvent() + silent doautocmd User NERDTreeInit +endfunction + +" FUNCTION: s:Creator.BufNamePrefix() {{{2 +function! s:Creator.BufNamePrefix() + return 'NERD_tree_' +endfunction + +"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 +function! s:Creator.CreateTabTree(name) + let creator = s:Creator.New() + call creator.createTabTree(a:name) +endfunction + +"FUNCTION: s:Creator.createTabTree(a:name) {{{1 +"name: the name of a bookmark or a directory +function! s:Creator.createTabTree(name) + let path = self._pathForString(a:name) + + "abort if exception was thrown (bookmark/dir doesn't exist) + if empty(path) + return + endif + + if path == {} + return + endif + + "if instructed to, then change the vim CWD to the dir the NERDTree is + "inited in + if g:NERDTreeChDirMode != 0 + call path.changeToDir() + endif + + if g:NERDTree.ExistsForTab() + if g:NERDTree.IsOpen() + call g:NERDTree.Close() + endif + + call self._removeTreeBufForTab() + endif + + call self._createTreeWin() + call self._createNERDTree(path, "tab") + call b:NERDTree.render() + call b:NERDTree.root.putCursorHere(0, 0) + + call self._broadcastInitEvent() +endfunction + +"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1 +function! s:Creator.CreateWindowTree(dir) + let creator = s:Creator.New() + call creator.createWindowTree(a:dir) +endfunction + +"FUNCTION: s:Creator.createWindowTree(dir) {{{1 +function! s:Creator.createWindowTree(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("Invalid directory name:" . a:name) + return + endtry + + "we want the directory buffer to disappear when we do the :edit below + setlocal bufhidden=wipe + + let previousBuf = expand("#") + + "we need a unique name for each window tree buffer to ensure they are + "all independent + exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() + + call self._createNERDTree(path, "window") + let b:NERDTree._previousBuf = bufnr(previousBuf) + call self._setCommonBufOptions() + + call b:NERDTree.render() + + call self._broadcastInitEvent() +endfunction + +" FUNCTION: s:Creator._createNERDTree(path) {{{1 +function! s:Creator._createNERDTree(path, type) + let b:NERDTree = g:NERDTree.New(a:path, a:type) + "TODO: This is kept for compatability only since many things use + "b:NERDTreeRoot instead of the new NERDTree.root + "Remove this one day + let b:NERDTreeRoot = b:NERDTree.root + + call b:NERDTree.root.open() +endfunction + +" FUNCTION: s:Creator.CreateMirror() {{{1 +function! s:Creator.CreateMirror() + let creator = s:Creator.New() + call creator.createMirror() +endfunction + +" FUNCTION: s:Creator.createMirror() {{{1 +function! s:Creator.createMirror() + "get the names off all the nerd tree buffers + let treeBufNames = [] + for i in range(1, tabpagenr("$")) + let nextName = self._tabpagevar(i, 'NERDTreeBufName') + if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) + call add(treeBufNames, nextName) + endif + endfor + let treeBufNames = self._uniq(treeBufNames) + + "map the option names (that the user will be prompted with) to the nerd + "tree buffer names + let options = {} + let i = 0 + while i < len(treeBufNames) + let bufName = treeBufNames[i] + let treeRoot = getbufvar(bufName, "NERDTree").root + let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName + let i = i + 1 + endwhile + + "work out which tree to mirror, if there is more than 1 then ask the user + let bufferName = '' + if len(keys(options)) > 1 + let choices = ["Choose a tree to mirror"] + let choices = extend(choices, sort(keys(options))) + let choice = inputlist(choices) + if choice < 1 || choice > len(options) || choice ==# '' + return + endif + + let bufferName = options[sort(keys(options))[choice-1]] + elseif len(keys(options)) ==# 1 + let bufferName = values(options)[0] + else + call nerdtree#echo("No trees to mirror") + return + endif + + if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen() + call g:NERDTree.Close() + endif + + let t:NERDTreeBufName = bufferName + call self._createTreeWin() + exec 'buffer ' . bufferName + if !&hidden + call b:NERDTree.render() + endif +endfunction + +"FUNCTION: s:Creator._createTreeWin() {{{1 +"Inits the NERD tree window. ie. opens it, sizes it, sets all the local +"options etc +function! s:Creator._createTreeWin() + "create the nerd tree window + let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " + let splitSize = g:NERDTreeWinSize + + if !exists('t:NERDTreeBufName') + let t:NERDTreeBufName = self._nextBufferName() + silent! exec splitLocation . 'vertical ' . splitSize . ' new' + silent! exec "edit " . t:NERDTreeBufName + else + silent! exec splitLocation . 'vertical ' . splitSize . ' split' + silent! exec "buffer " . t:NERDTreeBufName + endif + + setlocal winfixwidth + call self._setCommonBufOptions() +endfunction + +"FUNCTION: s:Creator._isBufHidden(nr) {{{1 +function! s:Creator._isBufHidden(nr) + redir => bufs + silent ls! + redir END + + return bufs =~ a:nr . '..h' +endfunction + +"FUNCTION: s:Creator.New() {{{1 +function! s:Creator.New() + let newCreator = copy(self) + return newCreator +endfunction + +" FUNCTION: s:Creator._nextBufferName() {{{2 +" returns the buffer name for the next nerd tree +function! s:Creator._nextBufferName() + let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() + return name +endfunction + +" FUNCTION: s:Creator._nextBufferNumber() {{{2 +" the number to add to the nerd tree buffer name to make the buf name unique +function! s:Creator._nextBufferNumber() + if !exists("s:Creator._NextBufNum") + let s:Creator._NextBufNum = 1 + else + let s:Creator._NextBufNum += 1 + endif + + return s:Creator._NextBufNum +endfunction + +"FUNCTION: s:Creator._pathForString(str) {{{1 +"find a bookmark or adirectory for the given string +function! s:Creator._pathForString(str) + let path = {} + if g:NERDTreeBookmark.BookmarkExistsFor(a:str) + let path = g:NERDTreeBookmark.BookmarkFor(a:str).path + else + let dir = a:str ==# '' ? getcwd() : a:str + + "hack to get an absolute path if a relative path is given + if dir =~# '^\.' + let dir = getcwd() . g:NERDTreePath.Slash() . dir + endif + let dir = g:NERDTreePath.Resolve(dir) + + try + let path = g:NERDTreePath.New(dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("No bookmark or directory found for: " . a:str) + return {} + endtry + endif + if !path.isDirectory + let path = path.getParent() + endif + + return path +endfunction + +" Function: s:Creator._removeTreeBufForTab() {{{1 +function! s:Creator._removeTreeBufForTab() + let buf = bufnr(t:NERDTreeBufName) + + "if &hidden is not set then it will already be gone + if buf != -1 + + "nerdtree buf may be mirrored/displayed elsewhere + if self._isBufHidden(buf) + exec "bwipeout " . buf + endif + + endif + + unlet t:NERDTreeBufName +endfunction + +"FUNCTION: s:Creator._setCommonBufOptions() {{{1 +function! s:Creator._setCommonBufOptions() + "throwaway buffer options + setlocal noswapfile + setlocal buftype=nofile + setlocal bufhidden=hide + setlocal nowrap + setlocal foldcolumn=0 + setlocal foldmethod=manual + setlocal nofoldenable + setlocal nobuflisted + setlocal nospell + if g:NERDTreeShowLineNumbers + setlocal nu + else + setlocal nonu + if v:version >= 703 + setlocal nornu + endif + endif + + iabc + + if g:NERDTreeHighlightCursorline + setlocal cursorline + endif + + call self._setupStatusline() + call self._bindMappings() + setlocal filetype=nerdtree +endfunction + +"FUNCTION: s:Creator._setupStatusline() {{{1 +function! s:Creator._setupStatusline() + if g:NERDTreeStatusline != -1 + let &l:statusline = g:NERDTreeStatusline + endif +endfunction + +" FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1 +function! s:Creator._tabpagevar(tabnr, var) + let currentTab = tabpagenr() + let old_ei = &ei + set ei=all + + exec "tabnext " . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec "tabnext " . currentTab + + let &ei = old_ei + + return v +endfunction + +"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1 +function! s:Creator.ToggleTabTree(dir) + let creator = s:Creator.New() + call creator.toggleTabTree(a:dir) +endfunction + +"FUNCTION: s:Creator.toggleTabTree(dir) {{{1 +"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is +"closed it is restored or initialized (if it doesnt exist) +" +"Args: +"dir: the full path for the root node (is only used if the NERD tree is being +"initialized. +function! s:Creator.toggleTabTree(dir) + if g:NERDTree.ExistsForTab() + if !g:NERDTree.IsOpen() + call self._createTreeWin() + if !&hidden + call b:NERDTree.render() + endif + call b:NERDTree.ui.restoreScreenState() + else + call g:NERDTree.Close() + endif + else + call self.createTabTree(a:dir) + endif +endfunction + +" Function: s:Creator._uniq(list) {{{1 +" returns a:list without duplicates +function! s:Creator._uniq(list) + let uniqlist = [] + for elem in a:list + if index(uniqlist, elem) ==# -1 + let uniqlist += [elem] + endif + endfor + return uniqlist +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/event.vim b/vim/bundle/nerdtree/lib/nerdtree/event.vim new file mode 100644 index 0000000..964e8ff --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/event.vim @@ -0,0 +1,13 @@ +"CLASS: Event +"============================================================ +let s:Event = {} +let g:NERDTreeEvent = s:Event + +function! s:Event.New(nerdtree, subject, action, params) abort + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + let newObj.subject = a:subject + let newObj.action = a:action + let newObj.params = a:params + return newObj +endfunction diff --git a/vim/bundle/nerdtree/lib/nerdtree/flag_set.vim b/vim/bundle/nerdtree/lib/nerdtree/flag_set.vim new file mode 100644 index 0000000..9d8d335 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/flag_set.vim @@ -0,0 +1,56 @@ +"CLASS: FlagSet +"============================================================ +let s:FlagSet = {} +let g:NERDTreeFlagSet = s:FlagSet + +"FUNCTION: FlagSet.addFlag(scope, flag) {{{1 +function! s:FlagSet.addFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + if index(flags, a:flag) == -1 + call add(flags, a:flag) + end +endfunction + +"FUNCTION: FlagSet.clearFlags(scope) {{{1 +function! s:FlagSet.clearFlags(scope) + let self._flags[a:scope] = [] +endfunction + +"FUNCTION: FlagSet._flagsForScope(scope) {{{1 +function! s:FlagSet._flagsForScope(scope) + if !has_key(self._flags, a:scope) + let self._flags[a:scope] = [] + endif + return self._flags[a:scope] +endfunction + +"FUNCTION: FlagSet.New() {{{1 +function! s:FlagSet.New() + let newObj = copy(self) + let newObj._flags = {} + return newObj +endfunction + +"FUNCTION: FlagSet.removeFlag(scope, flag) {{{1 +function! s:FlagSet.removeFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + + let i = index(flags, a:flag) + if i >= 0 + call remove(flags, i) + endif +endfunction + +"FUNCTION: FlagSet.renderToString() {{{1 +function! s:FlagSet.renderToString() + let flagstring = "" + for i in values(self._flags) + let flagstring .= join(i) + endfor + + if len(flagstring) == 0 + return "" + endif + + return '[' . flagstring . ']' +endfunction diff --git a/vim/bundle/nerdtree/lib/nerdtree/key_map.vim b/vim/bundle/nerdtree/lib/nerdtree/key_map.vim new file mode 100644 index 0000000..2411406 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/key_map.vim @@ -0,0 +1,159 @@ +"CLASS: KeyMap +"============================================================ +let s:KeyMap = {} +let g:NERDTreeKeyMap = s:KeyMap + +"FUNCTION: KeyMap.All() {{{1 +function! s:KeyMap.All() + if !exists("s:keyMaps") + let s:keyMaps = [] + endif + return s:keyMaps +endfunction + +"FUNCTION: KeyMap.FindFor(key, scope) {{{1 +function! s:KeyMap.FindFor(key, scope) + for i in s:KeyMap.All() + if i.key ==# a:key && i.scope ==# a:scope + return i + endif + endfor + return {} +endfunction + +"FUNCTION: KeyMap.BindAll() {{{1 +function! s:KeyMap.BindAll() + for i in s:KeyMap.All() + call i.bind() + endfor +endfunction + +"FUNCTION: KeyMap.bind() {{{1 +function! s:KeyMap.bind() + " If the key sequence we're trying to map contains any '<>' notation, we + " must replace each of the '<' characters with '' to ensure the string + " is not translated into its corresponding keycode during the later part + " of the map command below + " :he <> + let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)' + if self.key =~# specialNotationRegex + let keymapInvokeString = substitute(self.key, specialNotationRegex, '\1', 'g') + else + let keymapInvokeString = self.key + endif + + let premap = self.key == "" ? " " : " " + + exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' +endfunction + +"FUNCTION: KeyMap.Remove(key, scope) {{{1 +function! s:KeyMap.Remove(key, scope) + let maps = s:KeyMap.All() + for i in range(len(maps)) + if maps[i].key ==# a:key && maps[i].scope ==# a:scope + return remove(maps, i) + endif + endfor +endfunction + +"FUNCTION: KeyMap.invoke() {{{1 +"Call the KeyMaps callback function +function! s:KeyMap.invoke(...) + let Callback = function(self.callback) + if a:0 + call Callback(a:1) + else + call Callback() + endif +endfunction + +"FUNCTION: KeyMap.Invoke() {{{1 +"Find a keymapping for a:key and the current scope invoke it. +" +"Scope is determined as follows: +" * if the cursor is on a dir node then "DirNode" +" * if the cursor is on a file node then "FileNode" +" * if the cursor is on a bookmark then "Bookmark" +" +"If a keymap has the scope of "all" then it will be called if no other keymap +"is found for a:key and the scope. +function! s:KeyMap.Invoke(key) + + "required because clicking the command window below another window still + "invokes the mapping - but changes the window cursor + "is in first + " + "TODO: remove this check when the vim bug is fixed + if !g:NERDTree.ExistsForBuf() + return {} + endif + + let node = g:NERDTreeFileNode.GetSelected() + if !empty(node) + + "try file node + if !node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "FileNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try dir node + if node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "DirNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try generic node + let km = s:KeyMap.FindFor(a:key, "Node") + if !empty(km) + return km.invoke(node) + endif + + endif + + "try bookmark + let bm = g:NERDTreeBookmark.GetSelected() + if !empty(bm) + let km = s:KeyMap.FindFor(a:key, "Bookmark") + if !empty(km) + return km.invoke(bm) + endif + endif + + "try all + let km = s:KeyMap.FindFor(a:key, "all") + if !empty(km) + return km.invoke() + endif +endfunction + +"FUNCTION: KeyMap.Create(options) {{{1 +function! s:KeyMap.Create(options) + let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) + + "dont override other mappings unless the 'override' option is given + if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + return + end + + let newKeyMap = copy(self) + let newKeyMap.key = opts['key'] + let newKeyMap.quickhelpText = opts['quickhelpText'] + let newKeyMap.callback = opts['callback'] + let newKeyMap.scope = opts['scope'] + + call s:KeyMap.Add(newKeyMap) +endfunction + +"FUNCTION: KeyMap.Add(keymap) {{{1 +function! s:KeyMap.Add(keymap) + call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) + call add(s:KeyMap.All(), a:keymap) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim b/vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim new file mode 100644 index 0000000..ae0ee84 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim @@ -0,0 +1,180 @@ +"CLASS: MenuController +"============================================================ +let s:MenuController = {} +let g:NERDTreeMenuController = s:MenuController + +"FUNCTION: MenuController.New(menuItems) {{{1 +"create a new menu controller that operates on the given menu items +function! s:MenuController.New(menuItems) + let newMenuController = copy(self) + if a:menuItems[0].isSeparator() + let newMenuController.menuItems = a:menuItems[1:-1] + else + let newMenuController.menuItems = a:menuItems + endif + return newMenuController +endfunction + +"FUNCTION: MenuController.showMenu() {{{1 +"start the main loop of the menu and get the user to choose/execute a menu +"item +function! s:MenuController.showMenu() + call self._saveOptions() + + try + let self.selection = 0 + + let done = 0 + while !done + redraw! + call self._echoPrompt() + let key = nr2char(getchar()) + let done = self._handleKeypress(key) + endwhile + finally + call self._restoreOptions() + endtry + + if self.selection != -1 + let m = self._current() + call m.execute() + endif +endfunction + +"FUNCTION: MenuController._echoPrompt() {{{1 +function! s:MenuController._echoPrompt() + echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" + echo "==========================================================" + + for i in range(0, len(self.menuItems)-1) + if self.selection == i + echo "> " . self.menuItems[i].text + else + echo " " . self.menuItems[i].text + endif + endfor +endfunction + +"FUNCTION: MenuController._current(key) {{{1 +"get the MenuItem that is currently selected +function! s:MenuController._current() + return self.menuItems[self.selection] +endfunction + +"FUNCTION: MenuController._handleKeypress(key) {{{1 +"change the selection (if appropriate) and return 1 if the user has made +"their choice, 0 otherwise +function! s:MenuController._handleKeypress(key) + if a:key == 'j' + call self._cursorDown() + elseif a:key == 'k' + call self._cursorUp() + elseif a:key == nr2char(27) "escape + let self.selection = -1 + return 1 + elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j + return 1 + else + let index = self._nextIndexFor(a:key) + if index != -1 + let self.selection = index + if len(self._allIndexesFor(a:key)) == 1 + return 1 + endif + endif + endif + + return 0 +endfunction + +"FUNCTION: MenuController._allIndexesFor(shortcut) {{{1 +"get indexes to all menu items with the given shortcut +function! s:MenuController._allIndexesFor(shortcut) + let toReturn = [] + + for i in range(0, len(self.menuItems)-1) + if self.menuItems[i].shortcut == a:shortcut + call add(toReturn, i) + endif + endfor + + return toReturn +endfunction + +"FUNCTION: MenuController._nextIndexFor(shortcut) {{{1 +"get the index to the next menu item with the given shortcut, starts from the +"current cursor location and wraps around to the top again if need be +function! s:MenuController._nextIndexFor(shortcut) + for i in range(self.selection+1, len(self.menuItems)-1) + if self.menuItems[i].shortcut == a:shortcut + return i + endif + endfor + + for i in range(0, self.selection) + if self.menuItems[i].shortcut == a:shortcut + return i + endif + endfor + + return -1 +endfunction + +"FUNCTION: MenuController._setCmdheight() {{{1 +"sets &cmdheight to whatever is needed to display the menu +function! s:MenuController._setCmdheight() + let &cmdheight = len(self.menuItems) + 3 +endfunction + +"FUNCTION: MenuController._saveOptions() {{{1 +"set any vim options that are required to make the menu work (saving their old +"values) +function! s:MenuController._saveOptions() + let self._oldLazyredraw = &lazyredraw + let self._oldCmdheight = &cmdheight + set nolazyredraw + call self._setCmdheight() +endfunction + +"FUNCTION: MenuController._restoreOptions() {{{1 +"restore the options we saved in _saveOptions() +function! s:MenuController._restoreOptions() + let &cmdheight = self._oldCmdheight + let &lazyredraw = self._oldLazyredraw +endfunction + +"FUNCTION: MenuController._cursorDown() {{{1 +"move the cursor to the next menu item, skipping separators +function! s:MenuController._cursorDown() + let done = 0 + while !done + if self.selection < len(self.menuItems)-1 + let self.selection += 1 + else + let self.selection = 0 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + +"FUNCTION: MenuController._cursorUp() {{{1 +"move the cursor to the previous menu item, skipping separators +function! s:MenuController._cursorUp() + let done = 0 + while !done + if self.selection > 0 + let self.selection -= 1 + else + let self.selection = len(self.menuItems)-1 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/menu_item.vim b/vim/bundle/nerdtree/lib/nerdtree/menu_item.vim new file mode 100644 index 0000000..92c1bbb --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/menu_item.vim @@ -0,0 +1,114 @@ +"CLASS: MenuItem +"============================================================ +let s:MenuItem = {} +let g:NERDTreeMenuItem = s:MenuItem + +"FUNCTION: MenuItem.All() {{{1 +"get all top level menu items +function! s:MenuItem.All() + if !exists("s:menuItems") + let s:menuItems = [] + endif + return s:menuItems +endfunction + +"FUNCTION: MenuItem.AllEnabled() {{{1 +"get all top level menu items that are currently enabled +function! s:MenuItem.AllEnabled() + let toReturn = [] + for i in s:MenuItem.All() + if i.enabled() + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +"FUNCTION: MenuItem.Create(options) {{{1 +"make a new menu item and add it to the global list +function! s:MenuItem.Create(options) + let newMenuItem = copy(self) + + let newMenuItem.text = a:options['text'] + let newMenuItem.shortcut = a:options['shortcut'] + let newMenuItem.children = [] + + let newMenuItem.isActiveCallback = -1 + if has_key(a:options, 'isActiveCallback') + let newMenuItem.isActiveCallback = a:options['isActiveCallback'] + endif + + let newMenuItem.callback = -1 + if has_key(a:options, 'callback') + let newMenuItem.callback = a:options['callback'] + endif + + if has_key(a:options, 'parent') + call add(a:options['parent'].children, newMenuItem) + else + call add(s:MenuItem.All(), newMenuItem) + endif + + return newMenuItem +endfunction + +"FUNCTION: MenuItem.CreateSeparator(options) {{{1 +"make a new separator menu item and add it to the global list +function! s:MenuItem.CreateSeparator(options) + let standard_options = { 'text': '--------------------', + \ 'shortcut': -1, + \ 'callback': -1 } + let options = extend(a:options, standard_options, "force") + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.CreateSubmenu(options) {{{1 +"make a new submenu and add it to global list +function! s:MenuItem.CreateSubmenu(options) + let standard_options = { 'callback': -1 } + let options = extend(a:options, standard_options, "force") + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.enabled() {{{1 +"return 1 if this menu item should be displayed +" +"delegates off to the isActiveCallback, and defaults to 1 if no callback was +"specified +function! s:MenuItem.enabled() + if self.isActiveCallback != -1 + return {self.isActiveCallback}() + endif + return 1 +endfunction + +"FUNCTION: MenuItem.execute() {{{1 +"perform the action behind this menu item, if this menuitem has children then +"display a new menu for them, otherwise deletegate off to the menuitem's +"callback +function! s:MenuItem.execute() + if len(self.children) + let mc = g:NERDTreeMenuController.New(self.children) + call mc.showMenu() + else + if self.callback != -1 + call {self.callback}() + endif + endif +endfunction + +"FUNCTION: MenuItem.isSeparator() {{{1 +"return 1 if this menuitem is a separator +function! s:MenuItem.isSeparator() + return self.callback == -1 && self.children == [] +endfunction + +"FUNCTION: MenuItem.isSubmenu() {{{1 +"return 1 if this menuitem is a submenu +function! s:MenuItem.isSubmenu() + return self.callback == -1 && !empty(self.children) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim b/vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim new file mode 100644 index 0000000..1404cee --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim @@ -0,0 +1,197 @@ +"CLASS: NERDTree +"============================================================ +let s:NERDTree = {} +let g:NERDTree = s:NERDTree + +"FUNCTION: s:NERDTree.AddPathFilter() {{{1 +function! s:NERDTree.AddPathFilter(callback) + call add(s:NERDTree.PathFilters(), a:callback) +endfunction + +"FUNCTION: s:NERDTree.changeRoot(node) {{{1 +function! s:NERDTree.changeRoot(node) + if a:node.path.isDirectory + let self.root = a:node + else + call a:node.cacheParent() + let self.root = a:node.parent + endif + + call self.root.open() + + "change dir to the dir of the new root if instructed to + if g:NERDTreeChDirMode ==# 2 + exec "cd " . self.root.path.str({'format': 'Edit'}) + endif + + call self.render() + call self.root.putCursorHere(0, 0) + + silent doautocmd User NERDTreeNewRoot +endfunction + +"FUNCTION: s:NERDTree.Close() {{{1 +"Closes the tab tree window for this tab +function! s:NERDTree.Close() + if !s:NERDTree.IsOpen() + return + endif + + if winnr("$") != 1 + if winnr() == s:NERDTree.GetWinNum() + call nerdtree#exec("wincmd p") + let bufnr = bufnr("") + call nerdtree#exec("wincmd p") + else + let bufnr = bufnr("") + endif + + call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w") + close + call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") + else + close + endif +endfunction + +"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 +"Closes the NERD tree window if the close on open option is set +function! s:NERDTree.CloseIfQuitOnOpen() + if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen() + call s:NERDTree.Close() + endif +endfunction + +"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 +"Places the cursor at the top of the bookmarks table +function! s:NERDTree.CursorToBookmarkTable() + if !b:NERDTree.ui.getShowBookmarks() + throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" + endif + + if g:NERDTreeMinimalUI + return cursor(1, 2) + endif + + let rootNodeLine = b:NERDTree.ui.getRootLineNum() + + let line = 1 + while getline(line) !~# '^>-\+Bookmarks-\+$' + let line = line + 1 + if line >= rootNodeLine + throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" + endif + endwhile + call cursor(line, 2) +endfunction + +"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 +"Places the cursor in the nerd tree window +function! s:NERDTree.CursorToTreeWin() + call g:NERDTree.MustBeOpen() + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") +endfunction + +" Function: s:NERDTree.ExistsForBuffer() {{{1 +" Returns 1 if a nerd tree root exists in the current buffer +function! s:NERDTree.ExistsForBuf() + return exists("b:NERDTree") +endfunction + +" Function: s:NERDTree.ExistsForTab() {{{1 +" Returns 1 if a nerd tree root exists in the current tab +function! s:NERDTree.ExistsForTab() + if !exists("t:NERDTreeBufName") + return + end + + "check b:NERDTree is still there and hasn't been e.g. :bdeleted + return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree')) +endfunction + +function! s:NERDTree.ForCurrentBuf() + if s:NERDTree.ExistsForBuf() + return b:NERDTree + else + return {} + endif +endfunction + +"FUNCTION: s:NERDTree.ForCurrentTab() {{{1 +function! s:NERDTree.ForCurrentTab() + if !s:NERDTree.ExistsForTab() + return + endif + + let bufnr = bufnr(t:NERDTreeBufName) + return getbufvar(bufnr, "NERDTree") +endfunction + +"FUNCTION: s:NERDTree.getRoot() {{{1 +function! s:NERDTree.getRoot() + return self.root +endfunction + +"FUNCTION: s:NERDTree.GetWinNum() {{{1 +"gets the nerd tree window number for this tab +function! s:NERDTree.GetWinNum() + if exists("t:NERDTreeBufName") + return bufwinnr(t:NERDTreeBufName) + endif + + return -1 +endfunction + +"FUNCTION: s:NERDTree.IsOpen() {{{1 +function! s:NERDTree.IsOpen() + return s:NERDTree.GetWinNum() != -1 +endfunction + +"FUNCTION: s:NERDTree.isTabTree() {{{1 +function! s:NERDTree.isTabTree() + return self._type == "tab" +endfunction + +"FUNCTION: s:NERDTree.isWinTree() {{{1 +function! s:NERDTree.isWinTree() + return self._type == "window" +endfunction + +"FUNCTION: s:NERDTree.MustBeOpen() {{{1 +function! s:NERDTree.MustBeOpen() + if !s:NERDTree.IsOpen() + throw "NERDTree.TreeNotOpen" + endif +endfunction + +"FUNCTION: s:NERDTree.New() {{{1 +function! s:NERDTree.New(path, type) + let newObj = copy(self) + let newObj.ui = g:NERDTreeUI.New(newObj) + let newObj.root = g:NERDTreeDirNode.New(a:path, newObj) + let newObj._type = a:type + return newObj +endfunction + +"FUNCTION: s:NERDTree.PathFilters() {{{1 +function! s:NERDTree.PathFilters() + if !exists('s:NERDTree._PathFilters') + let s:NERDTree._PathFilters = [] + endif + return s:NERDTree._PathFilters +endfunction + +"FUNCTION: s:NERDTree.previousBuf() {{{1 +function! s:NERDTree.previousBuf() + return self._previousBuf +endfunction + +function! s:NERDTree.setPreviousBuf(bnum) + let self._previousBuf = a:bnum +endfunction + +"FUNCTION: s:NERDTree.render() {{{1 +"A convenience function - since this is called often +function! s:NERDTree.render() + call self.ui.render() +endfunction diff --git a/vim/bundle/nerdtree/lib/nerdtree/notifier.vim b/vim/bundle/nerdtree/lib/nerdtree/notifier.vim new file mode 100644 index 0000000..00041b8 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/notifier.vim @@ -0,0 +1,35 @@ +"CLASS: Notifier +"============================================================ +let s:Notifier = {} + +function! s:Notifier.AddListener(event, funcname) + let listeners = s:Notifier.GetListenersForEvent(a:event) + if listeners == [] + let listenersMap = s:Notifier.GetListenersMap() + let listenersMap[a:event] = listeners + endif + call add(listeners, a:funcname) +endfunction + +function! s:Notifier.NotifyListeners(event, path, nerdtree, params) + let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) + + for listener in s:Notifier.GetListenersForEvent(a:event) + call {listener}(event) + endfor +endfunction + +function! s:Notifier.GetListenersMap() + if !exists("s:refreshListenersMap") + let s:refreshListenersMap = {} + endif + return s:refreshListenersMap +endfunction + +function! s:Notifier.GetListenersForEvent(name) + let listenersMap = s:Notifier.GetListenersMap() + return get(listenersMap, a:name, []) +endfunction + +let g:NERDTreePathNotifier = deepcopy(s:Notifier) + diff --git a/vim/bundle/nerdtree/lib/nerdtree/opener.vim b/vim/bundle/nerdtree/lib/nerdtree/opener.vim new file mode 100644 index 0000000..ac0f92e --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/opener.vim @@ -0,0 +1,343 @@ +"CLASS: Opener +"============================================================ +let s:Opener = {} +let g:NERDTreeOpener = s:Opener + +"FUNCTION: s:Opener._bufInWindows(bnum){{{1 +"[[STOLEN FROM VTREEEXPLORER.VIM]] +"Determine the number of windows open to this buffer number. +"Care of Yegappan Lakshman. Thanks! +" +"Args: +"bnum: the subject buffers buffer number +function! s:Opener._bufInWindows(bnum) + let cnt = 0 + let winnum = 1 + while 1 + let bufnum = winbufnr(winnum) + if bufnum < 0 + break + endif + if bufnum ==# a:bnum + let cnt = cnt + 1 + endif + let winnum = winnum + 1 + endwhile + + return cnt +endfunction +"FUNCTION: Opener._checkToCloseTree(newtab) {{{1 +"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see +"if the tree should be closed now. +" +"Args: +"a:newtab - boolean. If set, only close the tree now if we are opening the +"target in a new tab. This is needed because we have to close tree before we +"leave the tab +function! s:Opener._checkToCloseTree(newtab) + if self._keepopen + return + endif + + if (a:newtab && self._where == 't') || !a:newtab + call g:NERDTree.CloseIfQuitOnOpen() + endif +endfunction + + +"FUNCTION: s:Opener._firstUsableWindow(){{{1 +"find the window number of the first normal window +function! s:Opener._firstUsableWindow() + let i = 1 + while i <= winnr("$") + let bnum = winbufnr(i) + if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + \ && !getwinvar(i, '&previewwindow') + \ && (!getbufvar(bnum, '&modified') || &hidden) + return i + endif + + let i += 1 + endwhile + return -1 +endfunction + +"FUNCTION: Opener._gotoTargetWin() {{{1 +function! s:Opener._gotoTargetWin() + if b:NERDTree.isWinTree() + if self._where == 'v' + vsplit + elseif self._where == 'h' + split + elseif self._where == 't' + tabnew + endif + else + call self._checkToCloseTree(1) + + if self._where == 'v' + call self._newVSplit() + elseif self._where == 'h' + call self._newSplit() + elseif self._where == 't' + tabnew + elseif self._where == 'p' + call self._previousWindow() + endif + + call self._checkToCloseTree(0) + endif +endfunction + +"FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1 +"Returns 0 if opening a file from the tree in the given window requires it to +"be split, 1 otherwise +" +"Args: +"winnumber: the number of the window in question +function! s:Opener._isWindowUsable(winnumber) + "gotta split if theres only one window (i.e. the NERD tree) + if winnr("$") ==# 1 + return 0 + endif + + let oldwinnr = winnr() + call nerdtree#exec(a:winnumber . "wincmd p") + let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') + let modified = &modified + call nerdtree#exec(oldwinnr . "wincmd p") + + "if its a special window e.g. quickfix or another explorer plugin then we + "have to split + if specialWindow + return 0 + endif + + if &hidden + return 1 + endif + + return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2 +endfunction + +"FUNCTION: Opener.New(path, opts) {{{1 +"Args: +" +"a:path: The path object that is to be opened. +" +"a:opts: +" +"A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there. Can +" 'all', 'currenttab' or empty to not reuse. +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +function! s:Opener.New(path, opts) + let newObj = copy(self) + + let newObj._path = a:path + let newObj._stay = nerdtree#has_opt(a:opts, 'stay') + + if has_key(a:opts, 'reuse') + let newObj._reuse = a:opts['reuse'] + else + let newObj._reuse = '' + endif + + let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen') + let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' + let newObj._nerdtree = b:NERDTree + call newObj._saveCursorPos() + + return newObj +endfunction + +"FUNCTION: Opener._newSplit() {{{1 +function! s:Opener._newSplit() + " Save the user's settings for splitbelow and splitright + let savesplitbelow=&splitbelow + let savesplitright=&splitright + + " 'there' will be set to a command to move from the split window + " back to the explorer window + " + " 'back' will be set to a command to move from the explorer window + " back to the newly split window + " + " 'right' and 'below' will be set to the settings needed for + " splitbelow and splitright IF the explorer is the only window. + " + let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" + let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" + let right= g:NERDTreeWinPos ==# "left" + let below=0 + + " Attempt to go to adjacent window + call nerdtree#exec(back) + + let onlyOneWin = (winnr("$") ==# 1) + + " If no adjacent window, set splitright and splitbelow appropriately + if onlyOneWin + let &splitright=right + let &splitbelow=below + else + " found adjacent window - invert split direction + let &splitright=!right + let &splitbelow=!below + endif + + let splitMode = onlyOneWin ? "vertical" : "" + + " Open the new window + try + exec(splitMode." sp ") + catch /^Vim\%((\a\+)\)\=:E37/ + call g:NERDTree.CursorToTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + "do nothing + endtry + + "resize the tree window if no other window was open before + if onlyOneWin + let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call nerdtree#exec(there) + exec("silent ". splitMode ." resize ". size) + call nerdtree#exec('wincmd p') + endif + + " Restore splitmode settings + let &splitbelow=savesplitbelow + let &splitright=savesplitright +endfunction + +"FUNCTION: Opener._newVSplit() {{{1 +function! s:Opener._newVSplit() + let winwidth = winwidth(".") + if winnr("$")==#1 + let winwidth = g:NERDTreeWinSize + endif + + call nerdtree#exec("wincmd p") + vnew + + "resize the nerd tree back to the original size + call g:NERDTree.CursorToTreeWin() + exec("silent vertical resize ". winwidth) + call nerdtree#exec('wincmd p') +endfunction + +"FUNCTION: Opener.open(target) {{{1 +function! s:Opener.open(target) + if self._path.isDirectory + call self._openDirectory(a:target) + else + call self._openFile() + endif +endfunction + +"FUNCTION: Opener._openFile() {{{1 +function! s:Opener._openFile() + if self._reuseWindow() + return + endif + + call self._gotoTargetWin() + call self._path.edit() + if self._stay + call self._restoreCursorPos() + endif +endfunction + +"FUNCTION: Opener._openDirectory(node) {{{1 +function! s:Opener._openDirectory(node) + if self._nerdtree.isWinTree() + call self._gotoTargetWin() + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) + else + call self._gotoTargetWin() + if empty(self._where) + call b:NERDTree.changeRoot(a:node) + elseif self._where == 't' + call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) + else + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) + endif + endif + + if self._stay + call self._restoreCursorPos() + endif +endfunction + +"FUNCTION: Opener._previousWindow() {{{1 +function! s:Opener._previousWindow() + if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1 + call self._newSplit() + else + try + if !self._isWindowUsable(winnr("#")) + call nerdtree#exec(self._firstUsableWindow() . "wincmd w") + else + call nerdtree#exec('wincmd p') + endif + catch /^Vim\%((\a\+)\)\=:E37/ + call g:NERDTree.CursorToTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + echo v:exception + endtry + endif +endfunction + +"FUNCTION: Opener._restoreCursorPos(){{{1 +function! s:Opener._restoreCursorPos() + call nerdtree#exec('normal ' . self._tabnr . 'gt') + call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') +endfunction + +"FUNCTION: Opener._reuseWindow(){{{1 +"put the cursor in the first window we find for this file +" +"return 1 if we were successful +function! s:Opener._reuseWindow() + if empty(self._reuse) + return 0 + endif + + "check the current tab for the window + let winnr = bufwinnr('^' . self._path.str() . '$') + if winnr != -1 + call nerdtree#exec(winnr . "wincmd w") + call self._checkToCloseTree(0) + return 1 + endif + + if self._reuse == 'currenttab' + return 0 + endif + + "check other tabs + let tabnr = self._path.tabnr() + if tabnr + call self._checkToCloseTree(1) + call nerdtree#exec('normal! ' . tabnr . 'gt') + let winnr = bufwinnr('^' . self._path.str() . '$') + call nerdtree#exec(winnr . "wincmd w") + return 1 + endif + + return 0 +endfunction + +"FUNCTION: Opener._saveCursorPos(){{{1 +function! s:Opener._saveCursorPos() + let self._bufnr = bufnr("") + let self._tabnr = tabpagenr() +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/path.vim b/vim/bundle/nerdtree/lib/nerdtree/path.vim new file mode 100644 index 0000000..26db4a3 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/path.vim @@ -0,0 +1,798 @@ +"we need to use this number many times for sorting... so we calculate it only +"once here +let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') +" used in formating sortKey, e.g. '%04d' +if exists("log10") + let s:sortKeyFormat = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" +else + let s:sortKeyFormat = "%04d" +endif + +"CLASS: Path +"============================================================ +let s:Path = {} +let g:NERDTreePath = s:Path + +"FUNCTION: Path.AbsolutePathFor(str) {{{1 +function! s:Path.AbsolutePathFor(str) + let prependCWD = 0 + if nerdtree#runningWindows() + let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)' + else + let prependCWD = a:str !~# '^/' + endif + + let toReturn = a:str + if prependCWD + let toReturn = getcwd() . s:Path.Slash() . a:str + endif + + return toReturn +endfunction + +"FUNCTION: Path.bookmarkNames() {{{1 +function! s:Path.bookmarkNames() + if !exists("self._bookmarkNames") + call self.cacheDisplayString() + endif + return self._bookmarkNames +endfunction + +"FUNCTION: Path.cacheDisplayString() {{{1 +function! s:Path.cacheDisplayString() abort + let self.cachedDisplayString = self.getLastPathComponent(1) + + if self.isExecutable + let self.cachedDisplayString = self.cachedDisplayString . '*' + endif + + let self._bookmarkNames = [] + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self) + call add(self._bookmarkNames, i.name) + endif + endfor + if !empty(self._bookmarkNames) + let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' + endif + + if self.isSymLink + let self.cachedDisplayString .= ' -> ' . self.symLinkDest + endif + + if self.isReadOnly + let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' + endif +endfunction + +"FUNCTION: Path.changeToDir() {{{1 +function! s:Path.changeToDir() + let dir = self.str({'format': 'Cd'}) + if self.isDirectory ==# 0 + let dir = self.getParent().str({'format': 'Cd'}) + endif + + try + execute "cd " . dir + call nerdtree#echo("CWD is now: " . getcwd()) + catch + throw "NERDTree.PathChangeError: cannot change CWD to " . dir + endtry +endfunction + +"FUNCTION: Path.compareTo() {{{1 +" +"Compares this Path to the given path and returns 0 if they are equal, -1 if +"this Path is "less than" the given path, or 1 if it is "greater". +" +"Args: +"path: the path object to compare this to +" +"Return: +"1, -1 or 0 +function! s:Path.compareTo(path) + let thisPath = self.getLastPathComponent(1) + let thatPath = a:path.getLastPathComponent(1) + + "if the paths are the same then clearly we return 0 + if thisPath ==# thatPath + return 0 + endif + + let thisSS = self.getSortOrderIndex() + let thatSS = a:path.getSortOrderIndex() + + "compare the sort sequences, if they are different then the return + "value is easy + if thisSS < thatSS + return -1 + elseif thisSS > thatSS + return 1 + else + if !g:NERDTreeSortHiddenFirst + let thisPath = substitute(thisPath, '^[._]', '', '') + let thatPath = substitute(thatPath, '^[._]', '', '') + endif + "if the sort sequences are the same then compare the paths + "alphabetically + let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath $" + endif + + return " \\`\|\"#%&,?()\*^<>[]$" +endfunction + +"FUNCTION: Path.getDir() {{{1 +" +"Returns this path if it is a directory, else this paths parent. +" +"Return: +"a Path object +function! s:Path.getDir() + if self.isDirectory + return self + else + return self.getParent() + endif +endfunction + +"FUNCTION: Path.getParent() {{{1 +" +"Returns a new path object for this paths parent +" +"Return: +"a new Path object +function! s:Path.getParent() + if nerdtree#runningWindows() + let path = self.drive . '\' . join(self.pathSegments[0:-2], '\') + else + let path = '/'. join(self.pathSegments[0:-2], '/') + endif + + return s:Path.New(path) +endfunction + +"FUNCTION: Path.getLastPathComponent(dirSlash) {{{1 +" +"Gets the last part of this path. +" +"Args: +"dirSlash: if 1 then a trailing slash will be added to the returned value for +"directory nodes. +function! s:Path.getLastPathComponent(dirSlash) + if empty(self.pathSegments) + return '' + endif + let toReturn = self.pathSegments[-1] + if a:dirSlash && self.isDirectory + let toReturn = toReturn . '/' + endif + return toReturn +endfunction + +"FUNCTION: Path.getSortOrderIndex() {{{1 +"returns the index of the pattern in g:NERDTreeSortOrder that this path matches +function! s:Path.getSortOrderIndex() + let i = 0 + while i < len(g:NERDTreeSortOrder) + if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i] + return i + endif + let i = i + 1 + endwhile + return s:NERDTreeSortStarIndex +endfunction + +"FUNCTION: Path.getSortKey() {{{1 +"returns a string used in compare function for sorting +function! s:Path.getSortKey() + if !exists("self._sortKey") + let path = self.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + let self._sortKey = printf(s:sortKeyFormat, self.getSortOrderIndex()) . path + endif + + return self._sortKey +endfunction + + +"FUNCTION: Path.isUnixHiddenFile() {{{1 +"check for unix hidden files +function! s:Path.isUnixHiddenFile() + return self.getLastPathComponent(0) =~# '^\.' +endfunction + +"FUNCTION: Path.isUnixHiddenPath() {{{1 +"check for unix path with hidden components +function! s:Path.isUnixHiddenPath() + if self.getLastPathComponent(0) =~# '^\.' + return 1 + else + for segment in self.pathSegments + if segment =~# '^\.' + return 1 + endif + endfor + return 0 + endif +endfunction + +"FUNCTION: Path.ignore(nerdtree) {{{1 +"returns true if this path should be ignored +function! s:Path.ignore(nerdtree) + "filter out the user specified paths to ignore + if a:nerdtree.ui.isIgnoreFilterEnabled() + for i in g:NERDTreeIgnore + if self._ignorePatternMatches(i) + return 1 + endif + endfor + + for callback in g:NERDTree.PathFilters() + if {callback}({'path': self, 'nerdtree': a:nerdtree}) + return 1 + endif + endfor + endif + + "dont show hidden files unless instructed to + if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile() + return 1 + endif + + if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0 + return 1 + endif + + return 0 +endfunction + +"FUNCTION: Path._ignorePatternMatches(pattern) {{{1 +"returns true if this path matches the given ignore pattern +function! s:Path._ignorePatternMatches(pattern) + let pat = a:pattern + if strpart(pat,len(pat)-7) == '[[dir]]' + if !self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-7) + elseif strpart(pat,len(pat)-8) == '[[file]]' + if self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-8) + endif + + return self.getLastPathComponent(0) =~# pat +endfunction + +"FUNCTION: Path.isAncestor(path) {{{1 +"return 1 if this path is somewhere above the given path in the filesystem. +" +"a:path should be a dir +function! s:Path.isAncestor(path) + if !self.isDirectory + return 0 + endif + + let this = self.str() + let that = a:path.str() + return stridx(that, this) == 0 +endfunction + +"FUNCTION: Path.isUnder(path) {{{1 +"return 1 if this path is somewhere under the given path in the filesystem. +function! s:Path.isUnder(path) + if a:path.isDirectory == 0 + return 0 + endif + + let this = self.str() + let that = a:path.str() + return stridx(this, that . s:Path.Slash()) == 0 +endfunction + +"FUNCTION: Path.JoinPathStrings(...) {{{1 +function! s:Path.JoinPathStrings(...) + let components = [] + for i in a:000 + let components = extend(components, split(i, '/')) + endfor + return '/' . join(components, '/') +endfunction + +"FUNCTION: Path.equals() {{{1 +" +"Determines whether 2 path objects are "equal". +"They are equal if the paths they represent are the same +" +"Args: +"path: the other path obj to compare this with +function! s:Path.equals(path) + return self.str() ==# a:path.str() +endfunction + +"FUNCTION: Path.New() {{{1 +"The Constructor for the Path object +function! s:Path.New(path) + let newPath = copy(self) + + call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path)) + + let newPath.cachedDisplayString = "" + let newPath.flagSet = g:NERDTreeFlagSet.New() + + return newPath +endfunction + +"FUNCTION: Path.Slash() {{{1 +"return the slash to use for the current OS +function! s:Path.Slash() + return nerdtree#runningWindows() ? '\' : '/' +endfunction + +"FUNCTION: Path.Resolve() {{{1 +"Invoke the vim resolve() function and return the result +"This is necessary because in some versions of vim resolve() removes trailing +"slashes while in other versions it doesn't. This always removes the trailing +"slash +function! s:Path.Resolve(path) + let tmp = resolve(a:path) + return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp +endfunction + +"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 +" +" +"Throws NERDTree.Path.InvalidArguments exception. +function! s:Path.readInfoFromDisk(fullpath) + call self.extractDriveLetter(a:fullpath) + + let fullpath = s:Path.WinToUnixPath(a:fullpath) + + if getftype(fullpath) ==# "fifo" + throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath + endif + + let self.pathSegments = split(fullpath, '/') + + let self.isReadOnly = 0 + if isdirectory(a:fullpath) + let self.isDirectory = 1 + elseif filereadable(a:fullpath) + let self.isDirectory = 0 + let self.isReadOnly = filewritable(a:fullpath) ==# 0 + else + throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath + endif + + let self.isExecutable = 0 + if !self.isDirectory + let self.isExecutable = getfperm(a:fullpath) =~# 'x' + endif + + "grab the last part of the path (minus the trailing slash) + let lastPathComponent = self.getLastPathComponent(0) + + "get the path to the new node with the parent dir fully resolved + let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent + + "if the last part of the path is a symlink then flag it as such + let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) + if self.isSymLink + let self.symLinkDest = s:Path.Resolve(fullpath) + + "if the link is a dir then slap a / on the end of its dest + if isdirectory(self.symLinkDest) + + "we always wanna treat MS windows shortcuts as files for + "simplicity + if hardPath !~# '\.lnk$' + + let self.symLinkDest = self.symLinkDest . '/' + endif + endif + endif +endfunction + +"FUNCTION: Path.refresh(nerdtree) {{{1 +function! s:Path.refresh(nerdtree) + call self.readInfoFromDisk(self.str()) + call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {}) + call self.cacheDisplayString() +endfunction + +"FUNCTION: Path.refreshFlags(nerdtree) {{{1 +function! s:Path.refreshFlags(nerdtree) + call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {}) + call self.cacheDisplayString() +endfunction + +"FUNCTION: Path.rename() {{{1 +" +"Renames this node on the filesystem +function! s:Path.rename(newPath) + if a:newPath ==# '' + throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath + endif + + let success = rename(self.str(), a:newPath) + if success != 0 + throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath + endif + call self.readInfoFromDisk(a:newPath) + + for i in self.bookmarkNames() + let b = g:NERDTreeBookmark.BookmarkFor(i) + call b.setPath(copy(self)) + endfor + call g:NERDTreeBookmark.Write() +endfunction + +"FUNCTION: Path.str() {{{1 +" +"Returns a string representation of this Path +" +"Takes an optional dictionary param to specify how the output should be +"formatted. +" +"The dict may have the following keys: +" 'format' +" 'escape' +" 'truncateTo' +" +"The 'format' key may have a value of: +" 'Cd' - a string to be used with the :cd command +" 'Edit' - a string to be used with :e :sp :new :tabedit etc +" 'UI' - a string used in the NERD tree UI +" +"The 'escape' key, if specified will cause the output to be escaped with +"shellescape() +" +"The 'truncateTo' key causes the resulting string to be truncated to the value +"'truncateTo' maps to. A '<' char will be prepended. +function! s:Path.str(...) + let options = a:0 ? a:1 : {} + let toReturn = "" + + if has_key(options, 'format') + let format = options['format'] + if has_key(self, '_strFor' . format) + exec 'let toReturn = self._strFor' . format . '()' + else + throw 'NERDTree.UnknownFormatError: unknown format "'. format .'"' + endif + else + let toReturn = self._str() + endif + + if nerdtree#has_opt(options, 'escape') + let toReturn = shellescape(toReturn) + endif + + if has_key(options, 'truncateTo') + let limit = options['truncateTo'] + if len(toReturn) > limit-1 + let toReturn = toReturn[(len(toReturn)-limit+1):] + if len(split(toReturn, '/')) > 1 + let toReturn = ' len(array_to_search) + throw "NERDTree.InvalidArgumentsError: Index is out of bounds." + endif + return array_to_search[a:indx] +endfunction + +"FUNCTION: TreeDirNode.getChildIndex(path) {{{1 +"Returns the index of the child node of this node that has the given path or +"-1 if no such node exists. +" +"This function doesnt not recurse into child dir nodes +" +"Args: +"path: a path object +function! s:TreeDirNode.getChildIndex(path) + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return -1 + endif + + "do a binary search for the child + let a = 0 + let z = self.getChildCount() + while a < z + let mid = (a+z)/2 + let diff = a:path.compareTo(self.children[mid].path) + + if diff ==# -1 + let z = mid + elseif diff ==# 1 + let a = mid+1 + else + return mid + endif + endwhile + return -1 +endfunction + +"FUNCTION: TreeDirNode.getDirChildren() {{{1 +"Get all children that are directories +function! s:TreeDirNode.getDirChildren() + return filter(self.children, 'v:val.path.isDirectory == 1') +endfunction + +"FUNCTION: TreeDirNode.GetSelected() {{{1 +"Returns the current node if it is a dir node, or else returns the current +"nodes parent +unlet s:TreeDirNode.GetSelected +function! s:TreeDirNode.GetSelected() + let currentDir = g:NERDTreeFileNode.GetSelected() + if currentDir != {} && !currentDir.isRoot() + if currentDir.path.isDirectory ==# 0 + let currentDir = currentDir.parent + endif + endif + return currentDir +endfunction + +"FUNCTION: TreeDirNode.getVisibleChildCount() {{{1 +"Returns the number of visible children this node has +function! s:TreeDirNode.getVisibleChildCount() + return len(self.getVisibleChildren()) +endfunction + +"FUNCTION: TreeDirNode.getVisibleChildren() {{{1 +"Returns a list of children to display for this node, in the correct order +" +"Return: +"an array of treenodes +function! s:TreeDirNode.getVisibleChildren() + let toReturn = [] + for i in self.children + if i.path.ignore(self.getNerdtree()) ==# 0 + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +"FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 +"returns 1 if this node has any childre, 0 otherwise.. +function! s:TreeDirNode.hasVisibleChildren() + return self.getVisibleChildCount() != 0 +endfunction + +"FUNCTION: TreeDirNode.isCascadable() {{{1 +"true if this dir has only one visible child - which is also a dir +function! s:TreeDirNode.isCascadable() + if g:NERDTreeCascadeSingleChildDir == 0 + return 0 + endif + + let c = self.getVisibleChildren() + return len(c) == 1 && c[0].path.isDirectory +endfunction + +"FUNCTION: TreeDirNode._initChildren() {{{1 +"Removes all childen from this node and re-reads them +" +"Args: +"silent: 1 if the function should not echo any "please wait" messages for +"large directories +" +"Return: the number of child nodes read +function! s:TreeDirNode._initChildren(silent) + "remove all the current child nodes + let self.children = [] + + "get an array of all the files in the nodes dir + let dir = self.path + let globDir = dir.str({'format': 'Glob'}) + + if version >= 703 + let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore) + else + let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + endif + + let files = split(filesStr, "\n") + + if !a:silent && len(files) > g:NERDTreeNotificationThreshold + call nerdtree#echo("Please wait, caching a large dir ...") + endif + + let invalidFilesFound = 0 + for i in files + + "filter out the .. and . directories + "Note: we must match .. AND ../ since sometimes the globpath returns + "../ for path with strange chars (eg $) + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + \ i[len(i)-2:1] != "." && i[len(i)-1] != "." + "put the next file in a new node and attach it + try + let path = g:NERDTreePath.New(i) + call self.createChild(path, 0) + call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound += 1 + endtry + endif + endfor + + call self.sortChildren() + + if !a:silent && len(files) > g:NERDTreeNotificationThreshold + call nerdtree#echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).") + endif + + if invalidFilesFound + call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") + endif + return self.getChildCount() +endfunction + +"FUNCTION: TreeDirNode.New(path, nerdtree) {{{1 +"Returns a new TreeNode object with the given path and parent +" +"Args: +"path: dir that the node represents +"nerdtree: the tree the node belongs to +function! s:TreeDirNode.New(path, nerdtree) + if a:path.isDirectory != 1 + throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." + endif + + let newTreeNode = copy(self) + let newTreeNode.path = a:path + + let newTreeNode.isOpen = 0 + let newTreeNode.children = [] + + let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree + + return newTreeNode +endfunction + +"FUNCTION: TreeDirNode.open([opts]) {{{1 +"Open the dir in the current tree or in a new tree elsewhere. +" +"If opening in the current tree, return the number of cached nodes. +unlet s:TreeDirNode.open +function! s:TreeDirNode.open(...) + let opts = a:0 ? a:1 : {} + + if has_key(opts, 'where') && !empty(opts['where']) + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) + else + let self.isOpen = 1 + if self.children ==# [] + return self._initChildren(0) + else + return 0 + endif + endif +endfunction + +"FUNCTION: TreeDirNode.openAlong([opts]) {{{1 +"recursive open the dir if it has only one directory child. +" +"return the level of opened directories. +function! s:TreeDirNode.openAlong(...) + let opts = a:0 ? a:1 : {} + let level = 0 + + let node = self + while node.path.isDirectory + call node.open(opts) + let level += 1 + if node.getVisibleChildCount() == 1 + let node = node.getChildByIndex(0, 1) + else + break + endif + endwhile + return level +endfunction + +" FUNCTION: TreeDirNode.openExplorer() {{{1 +" opens an explorer window for this node in the previous window (could be a +" nerd tree or a netrw) +function! s:TreeDirNode.openExplorer() + call self.open({'where': 'p'}) +endfunction + +"FUNCTION: TreeDirNode.openInNewTab(options) {{{1 +unlet s:TreeDirNode.openInNewTab +function! s:TreeDirNode.openInNewTab(options) + call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') + call self.open({'where': 't'}) +endfunction + +"FUNCTION: TreeDirNode._openInNewTab() {{{1 +function! s:TreeDirNode._openInNewTab() + tabnew + call g:NERDTreeCreator.CreateTabTree(self.path.str()) +endfunction + +"FUNCTION: TreeDirNode.openRecursively() {{{1 +"Opens this treenode and all of its children whose paths arent 'ignored' +"because of the file filters. +" +"This method is actually a wrapper for the OpenRecursively2 method which does +"the work. +function! s:TreeDirNode.openRecursively() + call self._openRecursively2(1) +endfunction + +"FUNCTION: TreeDirNode._openRecursively2() {{{1 +"Opens this all children of this treenode recursively if either: +" *they arent filtered by file filters +" *a:forceOpen is 1 +" +"Args: +"forceOpen: 1 if this node should be opened regardless of file filters +function! s:TreeDirNode._openRecursively2(forceOpen) + if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen + let self.isOpen = 1 + if self.children ==# [] + call self._initChildren(1) + endif + + for i in self.children + if i.path.isDirectory ==# 1 + call i._openRecursively2(0) + endif + endfor + endif +endfunction + +"FUNCTION: TreeDirNode.refresh() {{{1 +unlet s:TreeDirNode.refresh +function! s:TreeDirNode.refresh() + call self.path.refresh(self.getNerdtree()) + + "if this node was ever opened, refresh its children + if self.isOpen || !empty(self.children) + "go thru all the files/dirs under this node + let newChildNodes = [] + let invalidFilesFound = 0 + let dir = self.path + let globDir = dir.str({'format': 'Glob'}) + let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + let files = split(filesStr, "\n") + for i in files + "filter out the .. and . directories + "Note: we must match .. AND ../ cos sometimes the globpath returns + "../ for path with strange chars (eg $) + "if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' + + " Regular expression is too expensive. Use simply string comparison + " instead + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + \ i[len(i)-2:1] != "." && i[len(i)-1] != "." + try + "create a new path and see if it exists in this nodes children + let path = g:NERDTreePath.New(i) + let newNode = self.getChild(path) + if newNode != {} + call newNode.refresh() + call add(newChildNodes, newNode) + + "the node doesnt exist so create it + else + let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree()) + let newNode.parent = self + call add(newChildNodes, newNode) + endif + + + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound = 1 + endtry + endif + endfor + + "swap this nodes children out for the children we just read/refreshed + let self.children = newChildNodes + call self.sortChildren() + + if invalidFilesFound + call nerdtree#echoWarning("some files could not be loaded into the NERD tree") + endif + endif +endfunction + +"FUNCTION: TreeDirNode.refreshFlags() {{{1 +unlet s:TreeDirNode.refreshFlags +function! s:TreeDirNode.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) + for i in self.children + call i.refreshFlags() + endfor +endfunction + +"FUNCTION: TreeDirNode.refreshDirFlags() {{{1 +function! s:TreeDirNode.refreshDirFlags() + call self.path.refreshFlags(self.getNerdtree()) +endfunction + +"FUNCTION: TreeDirNode.reveal(path) {{{1 +"reveal the given path, i.e. cache and open all treenodes needed to display it +"in the UI +"Returns the revealed node +function! s:TreeDirNode.reveal(path, ...) + let opts = a:0 ? a:1 : {} + + if !a:path.isUnder(self.path) + throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() + endif + + call self.open() + + if self.path.equals(a:path.getParent()) + let n = self.findNode(a:path) + if has_key(opts, "open") + call n.open() + endif + return n + endif + + let p = a:path + while !p.getParent().equals(self.path) + let p = p.getParent() + endwhile + + let n = self.findNode(p) + return n.reveal(a:path, opts) +endfunction + +"FUNCTION: TreeDirNode.removeChild(treenode) {{{1 +" +"Removes the given treenode from this nodes set of children +" +"Args: +"treenode: the node to remove +" +"Throws a NERDTree.ChildNotFoundError if the given treenode is not found +function! s:TreeDirNode.removeChild(treenode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:treenode) + call remove(self.children, i) + return + endif + endfor + + throw "NERDTree.ChildNotFoundError: child node was not found" +endfunction + +"FUNCTION: TreeDirNode.sortChildren() {{{1 +" +"Sorts the children of this node according to alphabetical order and the +"directory priority. +" +function! s:TreeDirNode.sortChildren() + let CompareFunc = function("nerdtree#compareNodesBySortKey") + call sort(self.children, CompareFunc) +endfunction + +"FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 +"Opens this directory if it is closed and vice versa +function! s:TreeDirNode.toggleOpen(...) + let opts = a:0 ? a:1 : {} + if self.isOpen ==# 1 + call self.close() + else + if g:NERDTreeCascadeOpenSingleChildDir == 0 + call self.open(opts) + else + call self.openAlong(opts) + endif + endif +endfunction + +"FUNCTION: TreeDirNode.transplantChild(newNode) {{{1 +"Replaces the child of this with the given node (where the child node's full +"path matches a:newNode's fullpath). The search for the matching node is +"non-recursive +" +"Arg: +"newNode: the node to graft into the tree +function! s:TreeDirNode.transplantChild(newNode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:newNode) + let self.children[i] = a:newNode + let a:newNode.parent = self + break + endif + endfor +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim b/vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim new file mode 100644 index 0000000..adb0e96 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim @@ -0,0 +1,368 @@ +"CLASS: TreeFileNode +"This class is the parent of the TreeDirNode class and is the +"'Component' part of the composite design pattern between the treenode +"classes. +"============================================================ +let s:TreeFileNode = {} +let g:NERDTreeFileNode = s:TreeFileNode + +"FUNCTION: TreeFileNode.activate(...) {{{1 +function! s:TreeFileNode.activate(...) + call self.open(a:0 ? a:1 : {}) +endfunction + +"FUNCTION: TreeFileNode.bookmark(name) {{{1 +"bookmark this node with a:name +function! s:TreeFileNode.bookmark(name) + + "if a bookmark exists with the same name and the node is cached then save + "it so we can update its display string + let oldMarkedNode = {} + try + let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree()) + catch /^NERDTree.BookmarkNotFoundError/ + catch /^NERDTree.BookmarkedNodeNotFoundError/ + endtry + + call g:NERDTreeBookmark.AddBookmark(a:name, self.path) + call self.path.cacheDisplayString() + call g:NERDTreeBookmark.Write() + + if !empty(oldMarkedNode) + call oldMarkedNode.path.cacheDisplayString() + endif +endfunction + +"FUNCTION: TreeFileNode.cacheParent() {{{1 +"initializes self.parent if it isnt already +function! s:TreeFileNode.cacheParent() + if empty(self.parent) + let parentPath = self.path.getParent() + if parentPath.equals(self.path) + throw "NERDTree.CannotCacheParentError: already at root" + endif + let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree()) + endif +endfunction + +"FUNCTION: TreeFileNode.clearBookmarks() {{{1 +function! s:TreeFileNode.clearBookmarks() + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self.path) + call i.delete() + end + endfor + call self.path.cacheDisplayString() +endfunction + +"FUNCTION: TreeFileNode.copy(dest) {{{1 +function! s:TreeFileNode.copy(dest) + call self.path.copy(a:dest) + let newPath = g:NERDTreePath.New(a:dest) + let parent = self.getNerdtree().root.findNode(newPath.getParent()) + if !empty(parent) + call parent.refresh() + return parent.findNode(newPath) + else + return {} + endif +endfunction + +"FUNCTION: TreeFileNode.delete {{{1 +"Removes this node from the tree and calls the Delete method for its path obj +function! s:TreeFileNode.delete() + call self.path.delete() + call self.parent.removeChild(self) +endfunction + +"FUNCTION: TreeFileNode.displayString() {{{1 +" +"Returns a string that specifies how the node should be represented as a +"string +" +"Return: +"a string that can be used in the view to represent this node +function! s:TreeFileNode.displayString() + return self.path.flagSet.renderToString() . self.path.displayString() +endfunction + +"FUNCTION: TreeFileNode.equals(treenode) {{{1 +" +"Compares this treenode to the input treenode and returns 1 if they are the +"same node. +" +"Use this method instead of == because sometimes when the treenodes contain +"many children, vim seg faults when doing == +" +"Args: +"treenode: the other treenode to compare to +function! s:TreeFileNode.equals(treenode) + return self.path.str() ==# a:treenode.path.str() +endfunction + +"FUNCTION: TreeFileNode.findNode(path) {{{1 +"Returns self if this node.path.Equals the given path. +"Returns {} if not equal. +" +"Args: +"path: the path object to compare against +function! s:TreeFileNode.findNode(path) + if a:path.equals(self.path) + return self + endif + return {} +endfunction + +"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1 +" +"Finds the next sibling for this node in the indicated direction. This sibling +"must be a directory and may/may not have children as specified. +" +"Args: +"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" +"Return: +"a treenode object or {} if no appropriate sibling could be found +function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) + "if we have no parent then we can have no siblings + if self.parent != {} + let nextSibling = self.findSibling(a:direction) + + while nextSibling != {} + if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen + return nextSibling + endif + let nextSibling = nextSibling.findSibling(a:direction) + endwhile + endif + + return {} +endfunction + +"FUNCTION: TreeFileNode.findSibling(direction) {{{1 +" +"Finds the next sibling for this node in the indicated direction +" +"Args: +"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" +"Return: +"a treenode object or {} if no sibling could be found +function! s:TreeFileNode.findSibling(direction) + "if we have no parent then we can have no siblings + if self.parent != {} + + "get the index of this node in its parents children + let siblingIndx = self.parent.getChildIndex(self.path) + + if siblingIndx != -1 + "move a long to the next potential sibling node + let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 + + "keep moving along to the next sibling till we find one that is valid + let numSiblings = self.parent.getChildCount() + while siblingIndx >= 0 && siblingIndx < numSiblings + + "if the next node is not an ignored node (i.e. wont show up in the + "view) then return it + if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0 + return self.parent.children[siblingIndx] + endif + + "go to next node + let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 + endwhile + endif + endif + + return {} +endfunction + +"FUNCTION: TreeFileNode.getNerdtree(){{{1 +function! s:TreeFileNode.getNerdtree() + return self._nerdtree +endfunction + +"FUNCTION: TreeFileNode.GetRootForTab(){{{1 +"get the root node for this tab +function! s:TreeFileNode.GetRootForTab() + if g:NERDTree.ExistsForTab() + return getbufvar(t:NERDTreeBufName, 'NERDTree').root + end + return {} +endfunction + +"FUNCTION: TreeFileNode.GetSelected() {{{1 +"gets the treenode that the cursor is currently over +function! s:TreeFileNode.GetSelected() + try + let path = b:NERDTree.ui.getPath(line(".")) + if path ==# {} + return {} + endif + return b:NERDTree.root.findNode(path) + catch /^NERDTree/ + return {} + endtry +endfunction + +"FUNCTION: TreeFileNode.isVisible() {{{1 +"returns 1 if this node should be visible according to the tree filters and +"hidden file filters (and their on/off status) +function! s:TreeFileNode.isVisible() + return !self.path.ignore(self.getNerdtree()) +endfunction + +"FUNCTION: TreeFileNode.isRoot() {{{1 +function! s:TreeFileNode.isRoot() + if !g:NERDTree.ExistsForBuf() + throw "NERDTree.NoTreeError: No tree exists for the current buffer" + endif + + return self.equals(self.getNerdtree().root) +endfunction + +"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1 +"Returns a new TreeNode object with the given path and parent +" +"Args: +"path: file/dir that the node represents +"nerdtree: the tree the node belongs to +function! s:TreeFileNode.New(path, nerdtree) + if a:path.isDirectory + return g:NERDTreeDirNode.New(a:path, a:nerdtree) + else + let newTreeNode = copy(self) + let newTreeNode.path = a:path + let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree + return newTreeNode + endif +endfunction + +"FUNCTION: TreeFileNode.open() {{{1 +function! s:TreeFileNode.open(...) + let opts = a:0 ? a:1 : {} + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) +endfunction + +"FUNCTION: TreeFileNode.openSplit() {{{1 +"Open this node in a new window +function! s:TreeFileNode.openSplit() + call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'h'}) +endfunction + +"FUNCTION: TreeFileNode.openVSplit() {{{1 +"Open this node in a new vertical window +function! s:TreeFileNode.openVSplit() + call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'v'}) +endfunction + +"FUNCTION: TreeFileNode.openInNewTab(options) {{{1 +function! s:TreeFileNode.openInNewTab(options) + echomsg 'TreeFileNode.openInNewTab is deprecated' + call self.open(extend({'where': 't'}, a:options)) +endfunction + +"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 +"Places the cursor on the line number this node is rendered on +" +"Args: +"isJump: 1 if this cursor movement should be counted as a jump by vim +"recurseUpward: try to put the cursor on the parent if the this node isnt +"visible +function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) + let ln = self.getNerdtree().ui.getLineNum(self) + if ln != -1 + if a:isJump + mark ' + endif + call cursor(ln, col(".")) + else + if a:recurseUpward + let node = self + while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1 + let node = node.parent + call node.open() + endwhile + call self._nerdtree.render() + call node.putCursorHere(a:isJump, 0) + endif + endif +endfunction + +"FUNCTION: TreeFileNode.refresh() {{{1 +function! s:TreeFileNode.refresh() + call self.path.refresh(self.getNerdtree()) +endfunction + +"FUNCTION: TreeFileNode.refreshFlags() {{{1 +function! s:TreeFileNode.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) +endfunction + +"FUNCTION: TreeFileNode.rename() {{{1 +"Calls the rename method for this nodes path obj +function! s:TreeFileNode.rename(newName) + let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') + call self.path.rename(newName) + call self.parent.removeChild(self) + + let parentPath = self.path.getParent() + let newParent = self.getNerdtree().root.findNode(parentPath) + + if newParent != {} + call newParent.createChild(self.path, 1) + call newParent.refresh() + endif +endfunction + +"FUNCTION: TreeFileNode.renderToString {{{1 +"returns a string representation for this tree to be rendered in the view +function! s:TreeFileNode.renderToString() + return self._renderToString(0, 0) +endfunction + +"Args: +"depth: the current depth in the tree for this call +"drawText: 1 if we should actually draw the line for this node (if 0 then the +"child nodes are rendered only) +"for each depth in the tree +function! s:TreeFileNode._renderToString(depth, drawText) + let output = "" + if a:drawText ==# 1 + + let treeParts = repeat(' ', a:depth - 1) + + if !self.path.isDirectory + let treeParts = treeParts . ' ' + endif + + let line = treeParts . self.displayString() + + let output = output . line . "\n" + endif + + "if the node is an open dir, draw its children + if self.path.isDirectory ==# 1 && self.isOpen ==# 1 + + let childNodesToDraw = self.getVisibleChildren() + + if self.isCascadable() && a:depth > 0 + + let output = output . childNodesToDraw[0]._renderToString(a:depth, 0) + + elseif len(childNodesToDraw) > 0 + for i in childNodesToDraw + let output = output . i._renderToString(a:depth + 1, 1) + endfor + endif + endif + + return output +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/lib/nerdtree/ui.vim b/vim/bundle/nerdtree/lib/nerdtree/ui.vim new file mode 100644 index 0000000..65ebfd9 --- /dev/null +++ b/vim/bundle/nerdtree/lib/nerdtree/ui.vim @@ -0,0 +1,534 @@ +"CLASS: UI +"============================================================ +let s:UI = {} +let g:NERDTreeUI = s:UI + +"FUNCTION: s:UI.centerView() {{{2 +"centers the nerd tree window around the cursor (provided the nerd tree +"options permit) +function! s:UI.centerView() + if g:NERDTreeAutoCenter + let current_line = winline() + let lines_to_top = current_line + let lines_to_bottom = winheight(g:NERDTree.GetWinNum()) - current_line + if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold + normal! zz + endif + endif +endfunction + +"FUNCTION: s:UI._dumpHelp {{{1 +"prints out the quick help +function! s:UI._dumpHelp() + if self.getShowHelp() + let help = "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" + let help .= "\" ============================\n" + let help .= "\" File node mappings~\n" + let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let help .= "\" ,\n" + if self.nerdtree.isTabTree() + let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + else + let help .= "\" ". g:NERDTreeMapActivateNode .": open in current window\n" + endif + if self.nerdtree.isTabTree() + let help .= "\" ". g:NERDTreeMapPreview .": preview\n" + endif + let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" middle-click,\n" + let help .= "\" ". g:NERDTreeMapOpenSplit .": open split\n" + let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Directory node mappings~\n" + let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n" + let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" + let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let help .= "\" current node recursively\n" + let help .= "\" middle-click,\n" + let help .= "\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark table mappings~\n" + let help .= "\" double-click,\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n" + let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree navigation mappings~\n" + let help .= "\" ". g:NERDTreeMapJumpRoot .": go to root\n" + let help .= "\" ". g:NERDTreeMapJumpParent .": go to parent\n" + let help .= "\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" + let help .= "\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" + let help .= "\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let help .= "\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Filesystem mappings~\n" + let help .= "\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let help .= "\" selected dir\n" + let help .= "\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" + let help .= "\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let help .= "\" but leave old root open\n" + let help .= "\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" + let help .= "\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" + let help .= "\" ". g:NERDTreeMapMenu .": Show menu\n" + let help .= "\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let help .= "\" selected dir\n" + let help .= "\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree filtering mappings~\n" + let help .= "\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" + + "add quickhelp entries for each custom key map + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Custom mappings~\n" + for i in g:NERDTreeKeyMap.All() + if !empty(i.quickhelpText) + let help .= "\" ". i.key .": ". i.quickhelpText ."\n" + endif + endfor + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Other mappings~\n" + let help .= "\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" + let help .= "\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let help .= "\" the NERDTree window\n" + let help .= "\" ". g:NERDTreeMapHelp .": toggle help\n" + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark commands~\n" + let help .= "\" :Bookmark []\n" + let help .= "\" :BookmarkToRoot \n" + let help .= "\" :RevealBookmark \n" + let help .= "\" :OpenBookmark \n" + let help .= "\" :ClearBookmarks []\n" + let help .= "\" :ClearAllBookmarks\n" + silent! put =help + elseif !self.isMinimal() + let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" + silent! put =help + endif +endfunction + + +"FUNCTION: s:UI.new(nerdtree) {{{1 +function! s:UI.New(nerdtree) + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + let newObj._showHelp = 0 + let newObj._ignoreEnabled = 1 + let newObj._showFiles = g:NERDTreeShowFiles + let newObj._showHidden = g:NERDTreeShowHidden + let newObj._showBookmarks = g:NERDTreeShowBookmarks + + return newObj +endfunction + +"FUNCTION: s:UI.getPath(ln) {{{1 +"Gets the full path to the node that is rendered on the given line number +" +"Args: +"ln: the line number to get the path for +" +"Return: +"A path if a node was selected, {} if nothing is selected. +"If the 'up a dir' line was selected then the path to the parent of the +"current root is returned +function! s:UI.getPath(ln) + let line = getline(a:ln) + + let rootLine = self.getRootLineNum() + + "check to see if we have the root node + if a:ln == rootLine + return self.nerdtree.root.path + endif + + if line ==# s:UI.UpDirLine() + return self.nerdtree.root.path.getParent() + endif + + let indent = self._indentLevelFor(line) + + "remove the tree parts and the leading space + let curFile = self._stripMarkup(line, 0) + + let wasdir = 0 + if curFile =~# '/$' + let wasdir = 1 + let curFile = substitute(curFile, '/\?$', '/', "") + endif + + let dir = "" + let lnum = a:ln + while lnum > 0 + let lnum = lnum - 1 + let curLine = getline(lnum) + let curLineStripped = self._stripMarkup(curLine, 1) + + "have we reached the top of the tree? + if lnum == rootLine + let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir + break + endif + if curLineStripped =~# '/$' + let lpindent = self._indentLevelFor(curLine) + if lpindent < indent + let indent = indent - 1 + + let dir = substitute (curLineStripped,'^\\', "", "") . dir + continue + endif + endif + endwhile + let curFile = self.nerdtree.root.path.drive . dir . curFile + let toReturn = g:NERDTreePath.New(curFile) + return toReturn +endfunction + +"FUNCTION: s:UI.getLineNum(file_node){{{1 +"returns the line number this node is rendered on, or -1 if it isnt rendered +function! s:UI.getLineNum(file_node) + "if the node is the root then return the root line no. + if a:file_node.isRoot() + return self.getRootLineNum() + endif + + let totalLines = line("$") + + "the path components we have matched so far + let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')] + "the index of the component we are searching for + let curPathComponent = 1 + + let fullpath = a:file_node.path.str({'format': 'UI'}) + + let lnum = self.getRootLineNum() + while lnum > 0 + let lnum = lnum + 1 + "have we reached the bottom of the tree? + if lnum ==# totalLines+1 + return -1 + endif + + let curLine = getline(lnum) + + let indent = self._indentLevelFor(curLine) + if indent ==# curPathComponent + let curLine = self._stripMarkup(curLine, 1) + + let curPath = join(pathcomponents, '/') . '/' . curLine + if stridx(fullpath, curPath, 0) ==# 0 + if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' + let curLine = substitute(curLine, '/ *$', '', '') + call add(pathcomponents, curLine) + let curPathComponent = curPathComponent + 1 + + if fullpath ==# curPath + return lnum + endif + endif + endif + endif + endwhile + return -1 +endfunction + +"FUNCTION: s:UI.getRootLineNum(){{{1 +"gets the line number of the root node +function! s:UI.getRootLineNum() + let rootLine = 1 + while getline(rootLine) !~# '^\(/\|<\)' + let rootLine = rootLine + 1 + endwhile + return rootLine +endfunction + +"FUNCTION: s:UI.getShowBookmarks() {{{1 +function! s:UI.getShowBookmarks() + return self._showBookmarks +endfunction + +"FUNCTION: s:UI.getShowFiles() {{{1 +function! s:UI.getShowFiles() + return self._showFiles +endfunction + +"FUNCTION: s:UI.getShowHelp() {{{1 +function! s:UI.getShowHelp() + return self._showHelp +endfunction + +"FUNCTION: s:UI.getShowHidden() {{{1 +function! s:UI.getShowHidden() + return self._showHidden +endfunction + +"FUNCTION: s:UI._indentLevelFor(line) {{{1 +function! s:UI._indentLevelFor(line) + "have to do this work around because match() returns bytes, not chars + let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') + " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ + let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) + + return leadChars / s:UI.IndentWid() +endfunction + +"FUNCTION: s:UI.IndentWid() {{{1 +function! s:UI.IndentWid() + return 2 +endfunction + +"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 +function! s:UI.isIgnoreFilterEnabled() + return self._ignoreEnabled == 1 +endfunction + +"FUNCTION: s:UI.isMinimal() {{{1 +function! s:UI.isMinimal() + return g:NERDTreeMinimalUI +endfunction + +"FUNCTION: s:UI.MarkupReg() {{{1 +function! s:UI.MarkupReg() + return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' +endfunction + +"FUNCTION: s:UI._renderBookmarks {{{1 +function! s:UI._renderBookmarks() + + if !self.isMinimal() + call setline(line(".")+1, ">----------Bookmarks----------") + call cursor(line(".")+1, col(".")) + endif + + for i in g:NERDTreeBookmark.Bookmarks() + call setline(line(".")+1, i.str()) + call cursor(line(".")+1, col(".")) + endfor + + call setline(line(".")+1, '') + call cursor(line(".")+1, col(".")) +endfunction + +"FUNCTION: s:UI.restoreScreenState() {{{1 +" +"Sets the screen state back to what it was when nerdtree#saveScreenState was last +"called. +" +"Assumes the cursor is in the NERDTree window +function! s:UI.restoreScreenState() + if !has_key(self, '_screenState') + return + endif + exec("silent vertical resize " . self._screenState['oldWindowSize']) + + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(self._screenState['oldTopLine'], 0) + normal! zt + call setpos(".", self._screenState['oldPos']) + let &scrolloff=old_scrolloff +endfunction + +"FUNCTION: s:UI.saveScreenState() {{{1 +"Saves the current cursor position in the current buffer and the window +"scroll position +function! s:UI.saveScreenState() + let win = winnr() + call g:NERDTree.CursorToTreeWin() + let self._screenState = {} + let self._screenState['oldPos'] = getpos(".") + let self._screenState['oldTopLine'] = line("w0") + let self._screenState['oldWindowSize']= winwidth("") + call nerdtree#exec(win . "wincmd w") +endfunction + +"FUNCTION: s:UI.setShowHidden(val) {{{1 +function! s:UI.setShowHidden(val) + let self._showHidden = a:val +endfunction + +"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 +"returns the given line with all the tree parts stripped off +" +"Args: +"line: the subject line +"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = +"any spaces before the actual text of the node) +function! s:UI._stripMarkup(line, removeLeadingSpaces) + let line = a:line + "remove the tree parts and the leading space + let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") + + "strip off any read only flag + let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","") + + "strip off any bookmark flags + let line = substitute (line, ' {[^}]*}', "","") + + "strip off any executable flags + let line = substitute (line, '*\ze\($\| \)', "","") + + "strip off any generic flags + let line = substitute (line, '\[[^]]*\]', "","") + + let wasdir = 0 + if line =~# '/$' + let wasdir = 1 + endif + let line = substitute (line,' -> .*',"","") " remove link to + if wasdir ==# 1 + let line = substitute (line, '/\?$', '/', "") + endif + + if a:removeLeadingSpaces + let line = substitute (line, '^ *', '', '') + endif + + return line +endfunction + +"FUNCTION: s:UI.render() {{{1 +function! s:UI.render() + setlocal modifiable + + "remember the top line of the buffer and the current line so we can + "restore the view exactly how it was + let curLine = line(".") + let curCol = col(".") + let topLine = line("w0") + + "delete all lines in the buffer (being careful not to clobber a register) + silent 1,$delete _ + + call self._dumpHelp() + + "delete the blank line before the help and add one after it + if !self.isMinimal() + call setline(line(".")+1, "") + call cursor(line(".")+1, col(".")) + endif + + if self.getShowBookmarks() + call self._renderBookmarks() + endif + + "add the 'up a dir' line + if !self.isMinimal() + call setline(line(".")+1, s:UI.UpDirLine()) + call cursor(line(".")+1, col(".")) + endif + + "draw the header line + let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + call setline(line(".")+1, header) + call cursor(line(".")+1, col(".")) + + "draw the tree + silent put =self.nerdtree.root.renderToString() + + "delete the blank line at the top of the buffer + silent 1,1delete _ + + "restore the view + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(topLine, 1) + normal! zt + call cursor(curLine, curCol) + let &scrolloff = old_scrolloff + + setlocal nomodifiable +endfunction + + +"FUNCTION: UI.renderViewSavingPosition {{{1 +"Renders the tree and ensures the cursor stays on the current node or the +"current nodes parent if it is no longer available upon re-rendering +function! s:UI.renderViewSavingPosition() + let currentNode = g:NERDTreeFileNode.GetSelected() + + "go up the tree till we find a node that will be visible or till we run + "out of nodes + while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() + let currentNode = currentNode.parent + endwhile + + call self.render() + + if currentNode != {} + call currentNode.putCursorHere(0, 0) + endif +endfunction + +"FUNCTION: s:UI.toggleHelp() {{{1 +function! s:UI.toggleHelp() + let self._showHelp = !self._showHelp +endfunction + +" FUNCTION: s:UI.toggleIgnoreFilter() {{{1 +" toggles the use of the NERDTreeIgnore option +function! s:UI.toggleIgnoreFilter() + let self._ignoreEnabled = !self._ignoreEnabled + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowBookmarks() {{{1 +" toggles the display of bookmarks +function! s:UI.toggleShowBookmarks() + let self._showBookmarks = !self._showBookmarks + if self.getShowBookmarks() + call self.nerdtree.render() + call g:NERDTree.CursorToBookmarkTable() + else + call self.renderViewSavingPosition() + endif + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowFiles() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowFiles() + let self._showFiles = !self._showFiles + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowHidden() + let self._showHidden = !self._showHidden + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleZoom() {{{1 +" zoom (maximize/minimize) the NERDTree window +function! s:UI.toggleZoom() + if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + exec "silent vertical resize ". size + let b:NERDTreeZoomed = 0 + else + exec "vertical resize" + let b:NERDTreeZoomed = 1 + endif +endfunction + +"FUNCTION: s:UI.UpDirLine() {{{1 +function! s:UI.UpDirLine() + return '.. (up a dir)' +endfunction diff --git a/vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim b/vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim new file mode 100644 index 0000000..c53650a --- /dev/null +++ b/vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim @@ -0,0 +1,40 @@ +" ============================================================================ +" File: exec_menuitem.vim +" Description: plugin for NERD Tree that provides an execute file menu item +" Maintainer: Martin Grenfell +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ +if exists("g:loaded_nerdtree_exec_menuitem") + finish +endif +let g:loaded_nerdtree_exec_menuitem = 1 + +call NERDTreeAddMenuItem({ + \ 'text': '(!)Execute file', + \ 'shortcut': '!', + \ 'callback': 'NERDTreeExecFile', + \ 'isActiveCallback': 'NERDTreeExecFileActive' }) + +function! NERDTreeExecFileActive() + let node = g:NERDTreeFileNode.GetSelected() + return !node.path.isDirectory && node.path.isExecutable +endfunction + +function! NERDTreeExecFile() + let treenode = g:NERDTreeFileNode.GetSelected() + echo "==========================================================\n" + echo "Complete the command to execute (add arguments etc):\n" + let cmd = treenode.path.str({'escape': 1}) + let cmd = input(':!', cmd . ' ') + + if cmd != '' + exec ':!' . cmd + else + echo "Aborted" + endif +endfunction diff --git a/vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim b/vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim new file mode 100644 index 0000000..e563a94 --- /dev/null +++ b/vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim @@ -0,0 +1,287 @@ +" ============================================================================ +" File: fs_menu.vim +" Description: plugin for the NERD Tree that provides a file system menu +" Maintainer: Martin Grenfell +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ +if exists("g:loaded_nerdtree_fs_menu") + finish +endif +let g:loaded_nerdtree_fs_menu = 1 + +"Automatically delete the buffer after deleting or renaming a file +if !exists("g:NERDTreeAutoDeleteBuffer") + let g:NERDTreeAutoDeleteBuffer = 0 +endif + +call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) +call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) +call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) + +if has("gui_mac") || has("gui_macvim") || has("mac") + call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) + call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) +endif + +if g:NERDTreePath.CopyingSupported() + call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) +endif + +if has("unix") || has("osx") + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) +else + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) +endif + +"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 +"prints out the given msg and, if the user responds by pushing 'y' then the +"buffer with the given bufnum is deleted +" +"Args: +"bufnum: the buffer that may be deleted +"msg: a message that will be echoed to the user asking them if they wish to +" del the buffer +function! s:promptToDelBuffer(bufnum, msg) + echo a:msg + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + " 1. ensure that all windows which display the just deleted filename + " now display an empty buffer (so a layout is preserved). + " Is not it better to close single tabs with this file only ? + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif" + exec "tabnext " . s:originalTabNumber + exec s:originalWindowNumber . "wincmd w" + " 3. We don't need a previous buffer anymore + exec "bwipeout! " . a:bufnum + endif +endfunction + +"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1 +"prints out the given msg and, if the user responds by pushing 'y' then the +"buffer with the given bufnum is replaced with a new one +" +"Args: +"bufnum: the buffer that may be deleted +"msg: a message that will be echoed to the user asking them if they wish to +" del the buffer +function! s:promptToRenameBuffer(bufnum, msg, newFileName) + echo a:msg + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + let quotedFileName = fnameescape(a:newFileName) + " 1. ensure that a new buffer is loaded + exec "badd " . quotedFileName + " 2. ensure that all windows which display the just deleted filename + " display a buffer for a new filename. + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + let editStr = g:NERDTreePath.New(a:newFileName).str({'format': 'Edit'}) + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . editStr . "' | endif" + exec "tabnext " . s:originalTabNumber + exec s:originalWindowNumber . "wincmd w" + " 3. We don't need a previous buffer anymore + exec "bwipeout! " . a:bufnum + endif +endfunction +"FUNCTION: NERDTreeAddNode(){{{1 +function! NERDTreeAddNode() + let curDirNode = g:NERDTreeDirNode.GetSelected() + + let newNodeName = input("Add a childnode\n". + \ "==========================================================\n". + \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . + \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file") + + if newNodeName ==# '' + call nerdtree#echo("Node Creation Aborted.") + return + endif + + try + let newPath = g:NERDTreePath.Create(newNodeName) + let parentNode = b:NERDTree.root.findNode(newPath.getParent()) + + let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) + if empty(parentNode) + call b:NERDTree.root.refresh() + call b:NERDTree.render() + elseif parentNode.isOpen || !empty(parentNode.children) + call parentNode.addChild(newTreeNode, 1) + call NERDTreeRender() + call newTreeNode.putCursorHere(1, 0) + endif + catch /^NERDTree/ + call nerdtree#echoWarning("Node Not Created.") + endtry +endfunction + +"FUNCTION: NERDTreeMoveNode(){{{1 +function! NERDTreeMoveNode() + let curNode = g:NERDTreeFileNode.GetSelected() + let newNodePath = input("Rename the current node\n" . + \ "==========================================================\n" . + \ "Enter the new path for the node: \n" . + \ "", curNode.path.str(), "file") + + if newNodePath ==# '' + call nerdtree#echo("Node Renaming Aborted.") + return + endif + + try + let bufnum = bufnr("^".curNode.path.str()."$") + + call curNode.rename(newNodePath) + call NERDTreeRender() + + "if the node is open in a buffer, ask the user if they want to + "close that buffer + if bufnum != -1 + let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)" + call s:promptToRenameBuffer(bufnum, prompt, newNodePath) + endif + + call curNode.putCursorHere(1, 0) + + redraw + catch /^NERDTree/ + call nerdtree#echoWarning("Node Not Renamed.") + endtry +endfunction + +" FUNCTION: NERDTreeDeleteNode() {{{1 +function! NERDTreeDeleteNode() + let currentNode = g:NERDTreeFileNode.GetSelected() + let confirmed = 0 + + if currentNode.path.isDirectory && currentNode.getChildCount() > 0 + let choice =input("Delete the current node\n" . + \ "==========================================================\n" . + \ "STOP! Directory is not empty! To delete, type 'yes'\n" . + \ "" . currentNode.path.str() . ": ") + let confirmed = choice ==# 'yes' + else + echo "Delete the current node\n" . + \ "==========================================================\n". + \ "Are you sure you wish to delete the node:\n" . + \ "" . currentNode.path.str() . " (yN):" + let choice = nr2char(getchar()) + let confirmed = choice ==# 'y' + endif + + + if confirmed + try + call currentNode.delete() + call NERDTreeRender() + + "if the node is open in a buffer, ask the user if they want to + "close that buffer + let bufnum = bufnr("^".currentNode.path.str()."$") + if buflisted(bufnum) + let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" + call s:promptToDelBuffer(bufnum, prompt) + endif + + redraw + catch /^NERDTree/ + call nerdtree#echoWarning("Could not remove node") + endtry + else + call nerdtree#echo("delete aborted") + endif + +endfunction + +" FUNCTION: NERDTreeListNode() {{{1 +function! NERDTreeListNode() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') + call nerdtree#echo(metadata[0]) + else + call nerdtree#echo("No information avaialable") + endif +endfunction + +" FUNCTION: NERDTreeListNodeWin32() {{{1 +function! NERDTreeListNodeWin32() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') + call nerdtree#echo(metadata[0]) + else + call nerdtree#echo("No information avaialable") + endif + +endfunction + +" FUNCTION: NERDTreeCopyNode() {{{1 +function! NERDTreeCopyNode() + let currentNode = g:NERDTreeFileNode.GetSelected() + let newNodePath = input("Copy the current node\n" . + \ "==========================================================\n" . + \ "Enter the new path to copy the node to: \n" . + \ "", currentNode.path.str(), "file") + + if newNodePath != "" + "strip trailing slash + let newNodePath = substitute(newNodePath, '\/$', '', '') + + let confirmed = 1 + if currentNode.path.copyingWillOverwrite(newNodePath) + call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)") + let choice = nr2char(getchar()) + let confirmed = choice ==# 'y' + endif + + if confirmed + try + let newNode = currentNode.copy(newNodePath) + if empty(newNode) + call b:NERDTree.root.refresh() + call b:NERDTree.render() + else + call NERDTreeRender() + call newNode.putCursorHere(0, 0) + endif + catch /^NERDTree/ + call nerdtree#echoWarning("Could not copy node") + endtry + endif + else + call nerdtree#echo("Copy aborted.") + endif + redraw +endfunction + +" FUNCTION: NERDTreeQuickLook() {{{1 +function! NERDTreeQuickLook() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + endif +endfunction + +" FUNCTION: NERDTreeRevealInFinder() {{{1 +function! NERDTreeRevealInFinder() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + call system("open -R '" . treenode.path.str() . "'") + endif +endfunction + +" FUNCTION: NERDTreeExecuteFile() {{{1 +function! NERDTreeExecuteFile() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + call system("open '" . treenode.path.str() . "'") + endif +endfunction +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/plugin/NERD_tree.vim b/vim/bundle/nerdtree/plugin/NERD_tree.vim new file mode 100644 index 0000000..451b431 --- /dev/null +++ b/vim/bundle/nerdtree/plugin/NERD_tree.vim @@ -0,0 +1,221 @@ +" ============================================================================ +" File: NERD_tree.vim +" Maintainer: Martin Grenfell +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ +" +" SECTION: Script init stuff {{{1 +"============================================================ +if exists("loaded_nerd_tree") + finish +endif +if v:version < 700 + echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!" + finish +endif +let loaded_nerd_tree = 1 + +"for line continuation - i.e dont want C in &cpo +let s:old_cpo = &cpo +set cpo&vim + +"Function: s:initVariable() function {{{2 +"This function is used to initialise a given variable to a given value. The +"variable is only initialised if it does not exist prior +" +"Args: +"var: the name of the var to be initialised +"value: the value to initialise var to +" +"Returns: +"1 if the var is set, 0 otherwise +function! s:initVariable(var, value) + if !exists(a:var) + exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'" + return 1 + endif + return 0 +endfunction + +"SECTION: Init variable calls and other random constants {{{2 +call s:initVariable("g:NERDTreeAutoCenter", 1) +call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) +call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) +call s:initVariable("g:NERDTreeSortHiddenFirst", 1) +call s:initVariable("g:NERDTreeChDirMode", 0) +call s:initVariable("g:NERDTreeCreatePrefix", "silent") +call s:initVariable("g:NERDTreeMinimalUI", 0) +if !exists("g:NERDTreeIgnore") + let g:NERDTreeIgnore = ['\~$'] +endif +call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') +call s:initVariable("g:NERDTreeBookmarksSort", 1) +call s:initVariable("g:NERDTreeHighlightCursorline", 1) +call s:initVariable("g:NERDTreeHijackNetrw", 1) +call s:initVariable("g:NERDTreeMouseMode", 1) +call s:initVariable("g:NERDTreeNotificationThreshold", 100) +call s:initVariable("g:NERDTreeQuitOnOpen", 0) +call s:initVariable("g:NERDTreeRespectWildIgnore", 0) +call s:initVariable("g:NERDTreeShowBookmarks", 0) +call s:initVariable("g:NERDTreeShowFiles", 1) +call s:initVariable("g:NERDTreeShowHidden", 0) +call s:initVariable("g:NERDTreeShowLineNumbers", 0) +call s:initVariable("g:NERDTreeSortDirs", 1) + +if !nerdtree#runningWindows() + call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") +else + call s:initVariable("g:NERDTreeDirArrowExpandable", "+") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") +endif +call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) +call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) + +if !exists("g:NERDTreeSortOrder") + let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] +else + "if there isnt a * in the sort sequence then add one + if count(g:NERDTreeSortOrder, '*') < 1 + call add(g:NERDTreeSortOrder, '*') + endif +endif + +call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") + +if !exists('g:NERDTreeStatusline') + + "the exists() crap here is a hack to stop vim spazzing out when + "loading a session that was created with an open nerd tree. It spazzes + "because it doesnt store b:NERDTree(its a b: var, and its a hash) + let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" + +endif +call s:initVariable("g:NERDTreeWinPos", "left") +call s:initVariable("g:NERDTreeWinSize", 31) + +"init the shell commands that will be used to copy nodes, and remove dir trees +" +"Note: the space after the command is important +if nerdtree#runningWindows() + call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') + call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') + call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') +else + call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') + call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') +endif + + +"SECTION: Init variable calls for key mappings {{{2 +call s:initVariable("g:NERDTreeMapActivateNode", "o") +call s:initVariable("g:NERDTreeMapChangeRoot", "C") +call s:initVariable("g:NERDTreeMapChdir", "cd") +call s:initVariable("g:NERDTreeMapCloseChildren", "X") +call s:initVariable("g:NERDTreeMapCloseDir", "x") +call s:initVariable("g:NERDTreeMapDeleteBookmark", "D") +call s:initVariable("g:NERDTreeMapMenu", "m") +call s:initVariable("g:NERDTreeMapHelp", "?") +call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") +call s:initVariable("g:NERDTreeMapJumpLastChild", "J") +call s:initVariable("g:NERDTreeMapJumpNextSibling", "") +call s:initVariable("g:NERDTreeMapJumpParent", "p") +call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") +call s:initVariable("g:NERDTreeMapJumpRoot", "P") +call s:initVariable("g:NERDTreeMapOpenExpl", "e") +call s:initVariable("g:NERDTreeMapOpenInTab", "t") +call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T") +call s:initVariable("g:NERDTreeMapOpenRecursively", "O") +call s:initVariable("g:NERDTreeMapOpenSplit", "i") +call s:initVariable("g:NERDTreeMapOpenVSplit", "s") +call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode) +call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit) +call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit) +call s:initVariable("g:NERDTreeMapQuit", "q") +call s:initVariable("g:NERDTreeMapRefresh", "r") +call s:initVariable("g:NERDTreeMapRefreshRoot", "R") +call s:initVariable("g:NERDTreeMapToggleBookmarks", "B") +call s:initVariable("g:NERDTreeMapToggleFiles", "F") +call s:initVariable("g:NERDTreeMapToggleFilters", "f") +call s:initVariable("g:NERDTreeMapToggleHidden", "I") +call s:initVariable("g:NERDTreeMapToggleZoom", "A") +call s:initVariable("g:NERDTreeMapUpdir", "u") +call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") +call s:initVariable("g:NERDTreeMapCWD", "CD") + +"SECTION: Load class files{{{2 +call nerdtree#loadClassFiles() + +" SECTION: Commands {{{1 +"============================================================ +call nerdtree#ui_glue#setupCommands() + +" SECTION: Auto commands {{{1 +"============================================================ +augroup NERDTree + "Save the cursor position whenever we close the nerd tree + exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" + + "disallow insert mode in the NERDTree + exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" +augroup END + +if g:NERDTreeHijackNetrw + augroup NERDTreeHijackNetrw + autocmd VimEnter * silent! autocmd! FileExplorer + au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("")) + augroup END +endif + +" SECTION: Public API {{{1 +"============================================================ +function! NERDTreeAddMenuItem(options) + call g:NERDTreeMenuItem.Create(a:options) +endfunction + +function! NERDTreeAddMenuSeparator(...) + let opts = a:0 ? a:1 : {} + call g:NERDTreeMenuItem.CreateSeparator(opts) +endfunction + +function! NERDTreeAddSubmenu(options) + return g:NERDTreeMenuItem.Create(a:options) +endfunction + +function! NERDTreeAddKeyMap(options) + call g:NERDTreeKeyMap.Create(a:options) +endfunction + +function! NERDTreeRender() + call nerdtree#renderView() +endfunction + +function! NERDTreeFocus() + if g:NERDTree.IsOpen() + call g:NERDTree.CursorToTreeWin() + else + call g:NERDTreeCreator.ToggleTabTree("") + endif +endfunction + +function! NERDTreeCWD() + call NERDTreeFocus() + call nerdtree#ui_glue#chRootCwd() +endfunction + +function! NERDTreeAddPathFilter(callback) + call g:NERDTree.AddPathFilter(a:callback) +endfunction + +" SECTION: Post Source Actions {{{1 +call nerdtree#postSourceActions() + +"reset &cpo back to users setting +let &cpo = s:old_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/nerdtree/syntax/nerdtree.vim b/vim/bundle/nerdtree/syntax/nerdtree.vim new file mode 100644 index 0000000..e93ca1d --- /dev/null +++ b/vim/bundle/nerdtree/syntax/nerdtree.vim @@ -0,0 +1,82 @@ +let s:tree_up_dir_line = '.. (up a dir)' +syn match NERDTreeIgnore #\~# +exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' + +"highlighting for the .. (up dir) line at the top of the tree +execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" + +"quickhelp syntax elements +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 +syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1 +syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 +syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1 +syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 +syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeIgnore,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand + +"highlighting for sym links +syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile +syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile +syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir + +"highlighing for directory nodes and file nodes +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' +exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' + +let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') +exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' +syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark +exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' + +"highlighting for readonly files +exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' + +syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile +syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir + +syn match NERDTreeCWD #^[# +syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader + +hi def link NERDTreePart Special +hi def link NERDTreePartFile Type +hi def link NERDTreeExecFile Title +hi def link NERDTreeDirSlash Identifier + +hi def link NERDTreeBookmarksHeader statement +hi def link NERDTreeBookmarksLeader ignore +hi def link NERDTreeBookmarkName Identifier +hi def link NERDTreeBookmark normal + +hi def link NERDTreeHelp String +hi def link NERDTreeHelpKey Identifier +hi def link NERDTreeHelpCommand Identifier +hi def link NERDTreeHelpTitle Macro +hi def link NERDTreeToggleOn Question +hi def link NERDTreeToggleOff WarningMsg + +hi def link NERDTreeLinkTarget Type +hi def link NERDTreeLinkFile Macro +hi def link NERDTreeLinkDir Macro + +hi def link NERDTreeDir Directory +hi def link NERDTreeUp Directory +hi def link NERDTreeFile Normal +hi def link NERDTreeCWD Statement +hi def link NERDTreeOpenable Directory +hi def link NERDTreeClosable Directory +hi def link NERDTreeIgnore ignore +hi def link NERDTreeRO WarningMsg +hi def link NERDTreeBookmark Statement +hi def link NERDTreeFlags Number + +hi def link NERDTreeCurrentNode Search diff --git a/vim/bundle/nvim/.netrwhist b/vim/bundle/nvim/.netrwhist new file mode 100644 index 0000000..56bd361 --- /dev/null +++ b/vim/bundle/nvim/.netrwhist @@ -0,0 +1,7 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhist_cnt =5 +let g:netrw_dirhist_1='/home/jacob/.config/nvim/colors' +let g:netrw_dirhist_2='/home/jacob/.config/nvim' +let g:netrw_dirhist_3='/home/jacob/.config/nvim/bundle' +let g:netrw_dirhist_4='/home/jacob/.config/nvim' +let g:netrw_dirhist_5='/home/jacob/.config/nvim/colors' diff --git a/vim/bundle/nvim/colors/custom.vim b/vim/bundle/nvim/colors/custom.vim new file mode 100644 index 0000000..47229d8 --- /dev/null +++ b/vim/bundle/nvim/colors/custom.vim @@ -0,0 +1,51 @@ +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "custom" + +" Vim >= 7.0 specific colors +if version >= 700 + hi CursorLine term=none cterm=none guibg=#2d2d2d ctermbg=236 + hi CursorColumn guibg=#2d2d2d ctermbg=236 + hi MatchParen guifg=#d0ffc0 guibg=#2f2f2f gui=bold ctermfg=157 ctermbg=237 cterm=bold + hi Pmenu guifg=#ffffff guibg=#444444 ctermfg=255 ctermbg=238 + hi PmenuSel guifg=#000000 guibg=#b1d631 ctermfg=0 ctermbg=148 +endif + +" General colors +hi Cursor guifg=NONE guibg=#626262 gui=none ctermbg=241 +hi Normal guifg=#e2e2e5 guibg=#202020 gui=none ctermfg=253 ctermbg=234 +hi NonText guifg=#808080 guibg=#303030 gui=none ctermfg=244 ctermbg=235 +hi LineNr guifg=#808080 guibg=#000000 gui=none ctermfg=244 ctermbg=232 +hi StatusLine guifg=#d3d3d5 guibg=#444444 gui=italic ctermfg=253 ctermbg=238 cterm=italic +hi StatusLineNC guifg=#939395 guibg=#444444 gui=none ctermfg=246 ctermbg=238 +hi VertSplit guifg=#444444 guibg=#444444 gui=none ctermfg=238 ctermbg=238 +hi Folded guibg=#384048 guifg=#a0a8b0 gui=none ctermbg=4 ctermfg=248 +hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=254 cterm=bold +hi Visual guifg=#faf4c6 guibg=#3c414c gui=none ctermfg=254 ctermbg=4 +hi SpecialKey guifg=#808080 guibg=#343434 gui=none ctermfg=244 ctermbg=236 + +" Syntax highlighting +hi Comment guifg=#808080 gui=italic ctermfg=244 +hi Todo guifg=#8f8f8f gui=italic ctermfg=245 +hi Boolean guifg=#b1d631 gui=none ctermfg=148 +hi String guifg=#b1d631 gui=italic ctermfg=148 +hi Identifier guifg=#b1d631 gui=none ctermfg=148 +hi Function guifg=#000000 gui=bold ctermfg=255 +hi Type guifg=#7e8aa2 gui=none ctermfg=103 +hi Statement guifg=#7e8aa2 gui=none ctermfg=103 +hi Keyword guifg=#ff9800 gui=none ctermfg=208 +hi Constant guifg=#ff9800 gui=none ctermfg=208 +hi Number guifg=#ff9800 gui=none ctermfg=208 +hi Special guifg=#ff9800 gui=none ctermfg=208 +hi PreProc guifg=#faf4c6 gui=none ctermfg=230 +hi Todo guifg=#000000 guibg=#e6ea50 gui=italic + +" Code-specific colors +hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103 + diff --git a/vim/bundle/nvim/colors/lyla.vim b/vim/bundle/nvim/colors/lyla.vim new file mode 100644 index 0000000..4545477 --- /dev/null +++ b/vim/bundle/nvim/colors/lyla.vim @@ -0,0 +1,91 @@ +" Vim color file - lyla +" (c) Copyright 2015 Jacob Lindahl +set background=dark +if version > 580 + hi clear + if exists("syntax_on") + syntax reset + endif +endif + +set t_Co=256 +let g:colors_name = "lyla" + +hi Normal guifg=#ffffff guibg=#191a21 guisp=#191a21 gui=NONE ctermfg=15 ctermbg=234 cterm=NONE + +hi Boolean guifg=#a1a6a8 guibg=NONE guisp=NONE gui=NONE ctermfg=248 ctermbg=NONE cterm=NONE +hi Character guifg=#a1a6a8 guibg=NONE guisp=NONE gui=NONE ctermfg=248 ctermbg=NONE cterm=NONE +hi Comment guifg=#707070 guibg=NONE guisp=NONE gui=NONE ctermfg=242 ctermbg=NONE cterm=NONE +hi Conditional guifg=#5f5fff guibg=NONE guisp=NONE gui=bold ctermfg=63 ctermbg=NONE cterm=bold +hi Constant guifg=#00ff84 guibg=NONE guisp=NONE gui=NONE ctermfg=48 ctermbg=NONE cterm=NONE +hi Cursor guifg=#00d5ff guibg=#ffffff guisp=#ffffff gui=NONE ctermfg=45 ctermbg=15 cterm=NONE +hi CursorColumn guifg=NONE guibg=#222e30 guisp=#222e30 gui=NONE ctermfg=NONE ctermbg=236 cterm=NONE +hi CursorLine guifg=NONE guibg=#222e30 guisp=#222e30 gui=NONE ctermfg=NONE ctermbg=236 cterm=NONE +hi CursorLineNr guifg=#00ff1e guibg=NONE guisp=NONE gui=bold ctermfg=10 ctermbg=NONE cterm=bold +hi Debug guifg=#bd9800 guibg=NONE guisp=NONE gui=NONE ctermfg=11 ctermbg=NONE cterm=NONE +hi Define guifg=#bd9800 guibg=NONE guisp=NONE gui=NONE ctermfg=11 ctermbg=NONE cterm=NONE +hi Delimiter guifg=#ffffff guibg=#191a21 guisp=#191a21 gui=NONE ctermfg=15 ctermbg=234 cterm=NONE +hi DiffAdd guifg=NONE guibg=#004d21 guisp=#004d21 gui=NONE ctermfg=NONE ctermbg=22 cterm=NONE +hi DiffChange guifg=NONE guibg=#492224 guisp=#492224 gui=NONE ctermfg=NONE ctermbg=52 cterm=NONE +hi DiffDelete guifg=NONE guibg=#192224 guisp=#192224 gui=NONE ctermfg=NONE ctermbg=235 cterm=NONE +hi DiffText guifg=NONE guibg=#492224 guisp=#492224 gui=NONE ctermfg=NONE ctermbg=52 cterm=NONE +hi Directory guifg=#005eff guibg=NONE guisp=NONE gui=bold ctermfg=27 ctermbg=NONE cterm=bold +hi Error guifg=#a1a6a8 guibg=#912c00 guisp=#912c00 gui=NONE ctermfg=248 ctermbg=88 cterm=NONE +hi ErrorMsg guifg=#ffffff guibg=#ff0000 guisp=#ff0000 gui=NONE ctermfg=15 ctermbg=196 cterm=NONE +hi Exception guifg=#bd9800 guibg=NONE guisp=NONE gui=bold ctermfg=11 ctermbg=NONE cterm=bold +hi Float guifg=#a1a6a8 guibg=NONE guisp=NONE gui=NONE ctermfg=248 ctermbg=NONE cterm=NONE +hi FoldColumn guifg=#192224 guibg=#a1a6a8 guisp=#a1a6a8 gui=italic ctermfg=235 ctermbg=248 cterm=NONE +hi Folded guifg=#192224 guibg=#a1a6a8 guisp=#a1a6a8 gui=italic ctermfg=235 ctermbg=248 cterm=NONE +hi Function guifg=#005eff guibg=NONE guisp=NONE gui=bold ctermfg=27 ctermbg=NONE cterm=bold +hi Identifier guifg=#ffffff guibg=NONE guisp=NONE gui=NONE ctermfg=15 ctermbg=NONE cterm=NONE +hi IncSearch guifg=#ffffff guibg=#5b008f guisp=#5b008f gui=NONE ctermfg=15 ctermbg=54 cterm=NONE +hi Include guifg=#bd9800 guibg=NONE guisp=NONE gui=NONE ctermfg=11 ctermbg=NONE cterm=NONE +hi Keyword guifg=#00ff1e guibg=NONE guisp=NONE gui=bold ctermfg=10 ctermbg=NONE cterm=bold +hi Label guifg=#5f5fff guibg=NONE guisp=NONE gui=bold ctermfg=63 ctermbg=NONE cterm=bold +hi LineNr guifg=#ffffff guibg=NONE guisp=NONE gui=NONE ctermfg=15 ctermbg=NONE cterm=NONE +hi Macro guifg=#4cccff guibg=NONE guisp=NONE gui=NONE ctermfg=81 ctermbg=NONE cterm=NONE +hi MatchParen guifg=#bd9800 guibg=NONE guisp=NONE gui=bold ctermfg=11 ctermbg=NONE cterm=bold +hi ModeMsg guifg=#f9f9f9 guibg=#192224 guisp=#192224 gui=bold ctermfg=15 ctermbg=235 cterm=bold +hi MoreMsg guifg=#bd9800 guibg=NONE guisp=NONE gui=bold ctermfg=11 ctermbg=NONE cterm=bold +hi NonText guifg=#707070 guibg=NONE guisp=NONE gui=italic ctermfg=242 ctermbg=NONE cterm=NONE +hi Number guifg=#d90048 guibg=NONE guisp=NONE gui=bold ctermfg=161 ctermbg=NONE cterm=bold +hi Operator guifg=#0088ff guibg=NONE guisp=NONE gui=NONE ctermfg=33 ctermbg=NONE cterm=NONE +hi PMenu guifg=#8f8f8f guibg=#000000 guisp=#282f36 gui=NONE ctermfg=245 ctermbg=0 cterm=NONE +hi PMenuSbar guifg=NONE guibg=#848688 guisp=#848688 gui=NONE ctermfg=NONE ctermbg=102 cterm=NONE +hi PMenuSel guifg=#ffffff guibg=#005eff guisp=#005eff gui=NONE ctermfg=15 ctermbg=27 cterm=NONE +hi PMenuThumb guifg=NONE guibg=#a4a6a8 guisp=#a4a6a8 gui=NONE ctermfg=NONE ctermbg=248 cterm=NONE +hi PreCondit guifg=#5f5fff guibg=NONE guisp=NONE gui=bold ctermfg=63 ctermbg=NONE cterm=bold +hi PreProc guifg=#00ff1e guibg=NONE guisp=NONE gui=NONE ctermfg=10 ctermbg=NONE cterm=NONE +hi Repeat guifg=#5f5fff guibg=NONE guisp=NONE gui=bold ctermfg=63 ctermbg=NONE cterm=bold +hi Search guifg=#ffffff guibg=#53007d guisp=#53007d gui=NONE ctermfg=15 ctermbg=54 cterm=NONE +hi SignColumn guifg=#192224 guibg=#536991 guisp=#536991 gui=NONE ctermfg=235 ctermbg=60 cterm=NONE +hi Special guifg=#0088ff guibg=NONE guisp=NONE gui=NONE ctermfg=33 ctermbg=NONE cterm=NONE +hi SpecialChar guifg=#ffffff guibg=NONE guisp=NONE gui=NONE ctermfg=15 ctermbg=NONE cterm=NONE +hi SpecialComment guifg=#bd9800 guibg=NONE guisp=NONE gui=NONE ctermfg=11 ctermbg=NONE cterm=NONE +hi SpecialKey guifg=#5e6c70 guibg=NONE guisp=NONE gui=italic ctermfg=66 ctermbg=NONE cterm=NONE +hi SpellBad guifg=#f9f9ff guibg=#192224 guisp=#192224 gui=underline ctermfg=189 ctermbg=235 cterm=underline +hi SpellCap guifg=#f9f9ff guibg=#192224 guisp=#192224 gui=underline ctermfg=189 ctermbg=235 cterm=underline +hi SpellLocal guifg=#f9f9ff guibg=#192224 guisp=#192224 gui=underline ctermfg=189 ctermbg=235 cterm=underline +hi SpellRare guifg=#f9f9ff guibg=#192224 guisp=#192224 gui=underline ctermfg=189 ctermbg=235 cterm=underline +hi Statement guifg=#008a00 guibg=NONE guisp=NONE gui=bold ctermfg=28 ctermbg=NONE cterm=bold +hi StatusLine guifg=#ffffff guibg=#005eff guisp=#005eff gui=bold ctermfg=15 ctermbg=27 cterm=bold +hi StatusLineNC guifg=#1b1b24 guibg=#707070 guisp=#707070 gui=bold ctermfg=235 ctermbg=242 cterm=bold +hi StorageClass guifg=#536991 guibg=NONE guisp=NONE gui=bold ctermfg=60 ctermbg=NONE cterm=bold +hi String guifg=#4cccff guibg=NONE guisp=NONE gui=NONE ctermfg=81 ctermbg=NONE cterm=NONE +hi Structure guifg=#536991 guibg=NONE guisp=NONE gui=bold ctermfg=60 ctermbg=NONE cterm=bold +hi TabLine guifg=#1b1b24 guibg=#707070 guisp=#707070 gui=bold ctermfg=235 ctermbg=242 cterm=bold +hi TabLineFill guifg=#192224 guibg=#707070 guisp=#707070 gui=bold ctermfg=235 ctermbg=242 cterm=bold +hi TabLineSel guifg=#ffffff guibg=#005eff guisp=#005eff gui=bold ctermfg=15 ctermbg=27 cterm=bold +hi Tag guifg=#bd9800 guibg=NONE guisp=NONE gui=NONE ctermfg=11 ctermbg=NONE cterm=NONE +hi Title guifg=#f9f9ff guibg=NONE guisp=NONE gui=NONE ctermfg=189 ctermbg=NONE cterm=NONE +hi Todo guifg=#ffffff guibg=#0050d9 guisp=#0050d9 gui=NONE ctermfg=15 ctermbg=26 cterm=NONE +hi Type guifg=#00e1dd guibg=NONE guisp=NONE gui=NONE ctermfg=44 ctermbg=NONE cterm=NONE +hi Typedef guifg=#536991 guibg=NONE guisp=NONE gui=bold ctermfg=60 ctermbg=NONE cterm=bold +hi Underlined guifg=#f9f9ff guibg=#192224 guisp=#192224 gui=underline ctermfg=189 ctermbg=235 cterm=underline +hi VertSplit guifg=#1b1b24 guibg=#707070 guisp=#707070 gui=bold ctermfg=235 ctermbg=242 cterm=bold +hi Visual guifg=#192224 guibg=#f9f9ff guisp=#f9f9ff gui=NONE ctermfg=235 ctermbg=189 cterm=NONE +hi VisualNOS guifg=#192224 guibg=#f9f9ff guisp=#f9f9ff gui=underline ctermfg=235 ctermbg=189 cterm=underline +hi WarningMsg guifg=#a1a6a8 guibg=#912c00 guisp=#912c00 gui=NONE ctermfg=248 ctermbg=88 cterm=NONE +hi WildMenu guifg=NONE guibg=#a1a6a8 guisp=#a1a6a8 gui=NONE ctermfg=NONE ctermbg=248 cterm=NONE +hi cursorim guifg=#192224 guibg=#536991 guisp=#536991 gui=NONE ctermfg=235 ctermbg=60 cterm=NONE + diff --git a/vim/bundle/nvim/colors/molokai.vim b/vim/bundle/nvim/colors/molokai.vim new file mode 100644 index 0000000..6d97053 --- /dev/null +++ b/vim/bundle/nvim/colors/molokai.vim @@ -0,0 +1,276 @@ +" Vim color file +" +" Author: Tomas Restrepo +" https://github.com/tomasr/molokai +" +" Note: Based on the Monokai theme for TextMate +" by Wimer Hazenberg and its darker variant +" by Hamish Stuart Macpherson +" + +hi clear + +if version > 580 + " no guarantees for version 5.8 and below, but this makes it stop + " complaining + hi clear + if exists("syntax_on") + syntax reset + endif +endif +let g:colors_name="molokai" + +if exists("g:molokai_original") + let s:molokai_original = g:molokai_original +else + let s:molokai_original = 0 +endif + + +hi Boolean guifg=#AE81FF +hi Character guifg=#E6DB74 +hi Number guifg=#AE81FF +hi String guifg=#E6DB74 +hi Conditional guifg=#F92672 gui=bold +hi Constant guifg=#AE81FF gui=bold +hi Cursor guifg=#000000 guibg=#F8F8F0 +hi iCursor guifg=#000000 guibg=#F8F8F0 +hi Debug guifg=#BCA3A3 gui=bold +hi Define guifg=#66D9EF +hi Delimiter guifg=#8F8F8F +hi DiffAdd guibg=#13354A +hi DiffChange guifg=#89807D guibg=#4C4745 +hi DiffDelete guifg=#960050 guibg=#1E0010 +hi DiffText guibg=#4C4745 gui=italic,bold + +hi Directory guifg=#A6E22E gui=bold +hi Error guifg=#E6DB74 guibg=#1E0010 +hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold +hi Exception guifg=#A6E22E gui=bold +hi Float guifg=#AE81FF +hi FoldColumn guifg=#465457 guibg=#000000 +hi Folded guifg=#465457 guibg=#000000 +hi Function guifg=#A6E22E +hi Identifier guifg=#FD971F +hi Ignore guifg=#808080 guibg=bg +hi IncSearch guifg=#C4BE89 guibg=#000000 + +hi Keyword guifg=#F92672 gui=bold +hi Label guifg=#E6DB74 gui=none +hi Macro guifg=#C4BE89 gui=italic +hi SpecialKey guifg=#66D9EF gui=italic + +hi MatchParen guifg=#000000 guibg=#FD971F gui=bold +hi ModeMsg guifg=#E6DB74 +hi MoreMsg guifg=#E6DB74 +hi Operator guifg=#F92672 + +" complete menu +hi Pmenu guifg=#66D9EF guibg=#000000 +hi PmenuSel guibg=#808080 +hi PmenuSbar guibg=#080808 +hi PmenuThumb guifg=#66D9EF + +hi PreCondit guifg=#A6E22E gui=bold +hi PreProc guifg=#A6E22E +hi Question guifg=#66D9EF +hi Repeat guifg=#F92672 gui=bold +hi Search guifg=#000000 guibg=#FFE792 +" marks +hi SignColumn guifg=#A6E22E guibg=#232526 +hi SpecialChar guifg=#F92672 gui=bold +hi SpecialComment guifg=#7E8E91 gui=bold +hi Special guifg=#66D9EF guibg=bg gui=italic +if has("spell") + hi SpellBad guisp=#FF0000 gui=undercurl + hi SpellCap guisp=#7070F0 gui=undercurl + hi SpellLocal guisp=#70F0F0 gui=undercurl + hi SpellRare guisp=#FFFFFF gui=undercurl +endif +hi Statement guifg=#F92672 gui=bold +hi StatusLine guifg=#455354 guibg=fg +hi StatusLineNC guifg=#808080 guibg=#080808 +hi StorageClass guifg=#FD971F gui=italic +hi Structure guifg=#66D9EF +hi Tag guifg=#F92672 gui=italic +hi Title guifg=#ef5939 +hi Todo guifg=#FFFFFF guibg=bg gui=bold + +hi Typedef guifg=#66D9EF +hi Type guifg=#66D9EF gui=none +hi Underlined guifg=#808080 gui=underline + +hi VertSplit guifg=#808080 guibg=#080808 gui=bold +hi VisualNOS guibg=#403D3D +hi Visual guibg=#403D3D +hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold +hi WildMenu guifg=#66D9EF guibg=#000000 + +hi TabLineFill guifg=#1B1D1E guibg=#1B1D1E +hi TabLine guibg=#1B1D1E guifg=#808080 gui=none + +if s:molokai_original == 1 + hi Normal guifg=#F8F8F2 guibg=#272822 + hi Comment guifg=#75715E + hi CursorLine guibg=#3E3D32 + hi CursorLineNr guifg=#FD971F gui=none + hi CursorColumn guibg=#3E3D32 + hi ColorColumn guibg=#3B3A32 + hi LineNr guifg=#BCBCBC guibg=#3B3A32 + hi NonText guifg=#75715E + hi SpecialKey guifg=#75715E +else + hi Normal guifg=#F8F8F2 guibg=#1B1D1E + hi Comment guifg=#7E8E91 + hi CursorLine guibg=#293739 + hi CursorLineNr guifg=#FD971F gui=none + hi CursorColumn guibg=#293739 + hi ColorColumn guibg=#232526 + hi LineNr guifg=#465457 guibg=#232526 + hi NonText guifg=#465457 + hi SpecialKey guifg=#465457 +end + +" +" Support for 256-color terminal +" +if &t_Co > 255 + if s:molokai_original == 1 + hi Normal ctermbg=234 + hi CursorLine ctermbg=235 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + else + hi Normal ctermfg=252 ctermbg=233 + hi CursorLine ctermbg=234 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + endif + hi Boolean ctermfg=135 + hi Character ctermfg=144 + hi Number ctermfg=135 + hi String ctermfg=144 + hi Conditional ctermfg=161 cterm=bold + hi Constant ctermfg=135 cterm=bold + hi Cursor ctermfg=16 ctermbg=253 + hi Debug ctermfg=225 cterm=bold + hi Define ctermfg=81 + hi Delimiter ctermfg=241 + + hi DiffAdd ctermbg=24 + hi DiffChange ctermfg=181 ctermbg=239 + hi DiffDelete ctermfg=162 ctermbg=53 + hi DiffText ctermbg=102 cterm=bold + + hi Directory ctermfg=118 cterm=bold + hi Error ctermfg=219 ctermbg=89 + hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold + hi Exception ctermfg=118 cterm=bold + hi Float ctermfg=135 + hi FoldColumn ctermfg=67 ctermbg=16 + hi Folded ctermfg=67 ctermbg=16 + hi Function ctermfg=118 + hi Identifier ctermfg=208 cterm=none + hi Ignore ctermfg=244 ctermbg=232 + hi IncSearch ctermfg=193 ctermbg=16 + + hi keyword ctermfg=161 cterm=bold + hi Label ctermfg=229 cterm=none + hi Macro ctermfg=193 + hi SpecialKey ctermfg=81 + + hi MatchParen ctermfg=233 ctermbg=208 cterm=bold + hi ModeMsg ctermfg=229 + hi MoreMsg ctermfg=229 + hi Operator ctermfg=161 + + " complete menu + hi Pmenu ctermfg=81 ctermbg=16 + hi PmenuSel ctermfg=255 ctermbg=242 + hi PmenuSbar ctermbg=232 + hi PmenuThumb ctermfg=81 + + hi PreCondit ctermfg=118 cterm=bold + hi PreProc ctermfg=118 + hi Question ctermfg=81 + hi Repeat ctermfg=161 cterm=bold + hi Search ctermfg=0 ctermbg=222 cterm=NONE + + " marks column + hi SignColumn ctermfg=118 ctermbg=235 + hi SpecialChar ctermfg=161 cterm=bold + hi SpecialComment ctermfg=245 cterm=bold + hi Special ctermfg=81 + if has("spell") + hi SpellBad ctermbg=52 + hi SpellCap ctermbg=17 + hi SpellLocal ctermbg=17 + hi SpellRare ctermfg=none ctermbg=none cterm=reverse + endif + hi Statement ctermfg=161 cterm=bold + hi StatusLine ctermfg=238 ctermbg=253 + hi StatusLineNC ctermfg=244 ctermbg=232 + hi StorageClass ctermfg=208 + hi Structure ctermfg=81 + hi Tag ctermfg=161 + hi Title ctermfg=166 + hi Todo ctermfg=231 ctermbg=232 cterm=bold + + hi Typedef ctermfg=81 + hi Type ctermfg=81 cterm=none + hi Underlined ctermfg=244 cterm=underline + + hi VertSplit ctermfg=244 ctermbg=232 cterm=bold + hi VisualNOS ctermbg=238 + hi Visual ctermbg=235 + hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold + hi WildMenu ctermfg=81 ctermbg=16 + + hi Comment ctermfg=59 + hi CursorColumn ctermbg=236 + hi ColorColumn ctermbg=236 + hi LineNr ctermfg=250 ctermbg=236 + hi NonText ctermfg=59 + + hi SpecialKey ctermfg=59 + + if exists("g:rehash256") && g:rehash256 == 1 + hi Normal ctermfg=252 ctermbg=234 + hi CursorLine ctermbg=236 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + + hi Boolean ctermfg=141 + hi Character ctermfg=222 + hi Number ctermfg=141 + hi String ctermfg=222 + hi Conditional ctermfg=197 cterm=bold + hi Constant ctermfg=141 cterm=bold + + hi DiffDelete ctermfg=125 ctermbg=233 + + hi Directory ctermfg=154 cterm=bold + hi Error ctermfg=222 ctermbg=233 + hi Exception ctermfg=154 cterm=bold + hi Float ctermfg=141 + hi Function ctermfg=154 + hi Identifier ctermfg=208 + + hi Keyword ctermfg=197 cterm=bold + hi Operator ctermfg=197 + hi PreCondit ctermfg=154 cterm=bold + hi PreProc ctermfg=154 + hi Repeat ctermfg=197 cterm=bold + + hi Statement ctermfg=197 cterm=bold + hi Tag ctermfg=197 + hi Title ctermfg=203 + hi Visual ctermbg=238 + + hi Comment ctermfg=244 + hi LineNr ctermfg=239 ctermbg=235 + hi NonText ctermfg=239 + hi SpecialKey ctermfg=239 + endif +end + +" Must be at the end, because of ctermbg=234 bug. +" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ +set background=dark diff --git a/vim/bundle/nvim/colors/mustang.vim b/vim/bundle/nvim/colors/mustang.vim new file mode 100644 index 0000000..715605a --- /dev/null +++ b/vim/bundle/nvim/colors/mustang.vim @@ -0,0 +1,55 @@ +" Maintainer: Henrique C. Alves (hcarvalhoalves@gmail.com) +" Version: 1.0 +" Last Change: September 25 2008 + +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "mustang" + +" Vim >= 7.0 specific colors +if version >= 700 + hi CursorLine guibg=#2d2d2d ctermbg=236 + hi CursorColumn guibg=#2d2d2d ctermbg=236 + hi MatchParen guifg=#d0ffc0 guibg=#2f2f2f gui=bold ctermfg=157 ctermbg=237 cterm=bold + hi Pmenu guifg=#ffffff guibg=#444444 ctermfg=255 ctermbg=238 + hi PmenuSel guifg=#000000 guibg=#b1d631 ctermfg=0 ctermbg=148 +endif + +" General colors +hi Cursor guifg=NONE guibg=#626262 gui=none ctermbg=241 +hi Normal guifg=#e2e2e5 guibg=#202020 gui=none ctermfg=253 ctermbg=234 +hi NonText guifg=#808080 guibg=#303030 gui=none ctermfg=244 ctermbg=235 +hi LineNr guifg=#808080 guibg=#000000 gui=none ctermfg=244 ctermbg=232 +hi StatusLine guifg=#d3d3d5 guibg=#444444 gui=italic ctermfg=253 ctermbg=238 cterm=italic +hi StatusLineNC guifg=#939395 guibg=#444444 gui=none ctermfg=246 ctermbg=238 +hi VertSplit guifg=#444444 guibg=#444444 gui=none ctermfg=238 ctermbg=238 +hi Folded guibg=#384048 guifg=#a0a8b0 gui=none ctermbg=4 ctermfg=248 +hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=254 cterm=bold +hi Visual guifg=#faf4c6 guibg=#3c414c gui=none ctermfg=254 ctermbg=4 +hi SpecialKey guifg=#808080 guibg=#343434 gui=none ctermfg=244 ctermbg=236 + +" Syntax highlighting +hi Comment guifg=#808080 gui=italic ctermfg=244 +hi Todo guifg=#8f8f8f gui=italic ctermfg=245 +hi Boolean guifg=#b1d631 gui=none ctermfg=148 +hi String guifg=#b1d631 gui=italic ctermfg=148 +hi Identifier guifg=#b1d631 gui=none ctermfg=148 +hi Function guifg=#ffffff gui=bold ctermfg=255 +hi Type guifg=#7e8aa2 gui=none ctermfg=103 +hi Statement guifg=#7e8aa2 gui=none ctermfg=103 +hi Keyword guifg=#ff9800 gui=none ctermfg=208 +hi Constant guifg=#ff9800 gui=none ctermfg=208 +hi Number guifg=#ff9800 gui=none ctermfg=208 +hi Special guifg=#ff9800 gui=none ctermfg=208 +hi PreProc guifg=#faf4c6 gui=none ctermfg=230 +hi Todo guifg=#000000 guibg=#e6ea50 gui=italic + +" Code-specific colors +hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103 + diff --git a/vim/bundle/nvim/colors/wombat.vim b/vim/bundle/nvim/colors/wombat.vim new file mode 100644 index 0000000..9ad1e56 --- /dev/null +++ b/vim/bundle/nvim/colors/wombat.vim @@ -0,0 +1,51 @@ +" Maintainer: Lars H. Nielsen (dengmao@gmail.com) +" Last Change: January 22 2007 + +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "wombat" + + +" Vim >= 7.0 specific colors +if version >= 700 + hi CursorLine guibg=#2d2d2d + hi CursorColumn guibg=#2d2d2d + hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=bold + hi Pmenu guifg=#f6f3e8 guibg=#444444 + hi PmenuSel guifg=#000000 guibg=#cae682 +endif + +" General colors +hi Cursor guifg=NONE guibg=#656565 gui=none +hi Normal guifg=#f6f3e8 guibg=#242424 gui=none +hi NonText guifg=#808080 guibg=#303030 gui=none +hi LineNr guifg=#857b6f guibg=#000000 gui=none +hi StatusLine guifg=#f6f3e8 guibg=#444444 gui=italic +hi StatusLineNC guifg=#857b6f guibg=#444444 gui=none +hi VertSplit guifg=#444444 guibg=#444444 gui=none +hi Folded guibg=#384048 guifg=#a0a8b0 gui=none +hi Title guifg=#f6f3e8 guibg=NONE gui=bold +hi Visual guifg=#f6f3e8 guibg=#444444 gui=none +hi SpecialKey guifg=#808080 guibg=#343434 gui=none + +" Syntax highlighting +hi Comment guifg=#99968b gui=italic +hi Todo guifg=#8f8f8f gui=italic +hi Constant guifg=#e5786d gui=none +hi String guifg=#95e454 gui=italic +hi Identifier guifg=#cae682 gui=none +hi Function guifg=#cae682 gui=none +hi Type guifg=#cae682 gui=none +hi Statement guifg=#8ac6f2 gui=none +hi Keyword guifg=#8ac6f2 gui=none +hi PreProc guifg=#e5786d gui=none +hi Number guifg=#e5786d gui=none +hi Special guifg=#e7f6da gui=none + + diff --git a/vim/bundle/nvim/init.vim b/vim/bundle/nvim/init.vim new file mode 100644 index 0000000..7e956fd --- /dev/null +++ b/vim/bundle/nvim/init.vim @@ -0,0 +1,144 @@ +" don't be compatible :) +set nocompatible + + + +" vundle +filetype off +set rtp+=~/.config/nvim/bundle/vundle +call vundle#begin('~/.config/nvim/bundle') + +" ======= +" Plugins +" ======= + +Plugin 'gmarik/vundle' +Plugin 'scrooloose/nerdtree' +Plugin 'Xuyuanp/nerdtree-git-plugin' +Plugin 'tpope/vim-fugitive' +Plugin 'kien/ctrlp.vim' +Plugin 'scrooloose/syntastic' +Plugin 'Yggdroot/indentLine' +Plugin 'marijnh/tern_for_vim' +Plugin 'bling/vim-airline' +Plugin 'othree/html5.vim' +Plugin 'airblade/vim-gitgutter' +Plugin 'pangloss/vim-javascript' + +call vundle#end() + +filetype on + + + +" ============= +" Plugin config +" ============= + +" ctrlp +let g:ctrlp_map = '' +let g:ctrlp_follow_symlinks = 1 + +" Syntastic n00b settings :) +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 + +" indentLine +let g:indentLine_char = '│' +let g:indentLine_leadingSpaceChar = '·' +let g:indentLine_leadingSpaceEnabled = 1 +let g:indentLine_color_term = 239 +let g:indentLine_color_gui = '#A4E57E' + +" NERDTree +autocmd VimEnter * NERDTree +let NERDTreeShowHidden = 1 +let g:NERDTreeWinSize=34 + +" airline +" NeoVim doesn't currently support changing the font, +" so no patched power/airline fonts :( +let g:airline_powerline_fonts = 1 + + + +" ================ +" display settings +" ================ + +" syntax highlighting +syntax enable +colorscheme lyla + +" display whitespace +set list +set listchars=eol:¬,tab:»·,extends:>,precedes:<,trail:· + +" set indentation to be four spaces +set tabstop=4 softtabstop=4 expandtab shiftwidth=4 + +" enable autoindent +set autoindent +filetype plugin indent on + +" highlight current line +set cursorline + +" don't highlight searches +set nohlsearch + +" show line numbers +set number + +" show relative line numbers +set relativenumber + +" show absolute line numbers in insert mode +autocmd InsertEnter * set number norelativenumber +autocmd InsertLeave * set relativenumber + +" enable soft word wrap +set linebreak + +" only redraw when needed +set lazyredraw + +" set gui font +" NeoVim doesn't currently support changing the font, +" so no patched power/airline fonts :( +set guifont=Deja\ Vu\ Sans\ Mono\ for\ Powerline + + + +" ================ +" command settings +" ================ + +" show autocomplete for commands +set wildmenu + +" search while typing +set incsearch + + + +" ============= +" misc settings +" ============= + +" hide buffers +set hidden + +" backup settings +set backup +set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp +set backupskip=/tmp/*,/private/tmp/* +set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp +set writebackup + diff --git a/vim/bundle/tagbar/pax_global_header b/vim/bundle/tagbar/pax_global_header new file mode 100644 index 0000000..9bcb683 --- /dev/null +++ b/vim/bundle/tagbar/pax_global_header @@ -0,0 +1 @@ +52 comment=959f48798136bfd4ce60075d3c86c580fcf5e5c5 diff --git a/vim/bundle/tagbar/tagbar-master/LICENSE b/vim/bundle/tagbar/tagbar-master/LICENSE new file mode 100644 index 0000000..5ae1a75 --- /dev/null +++ b/vim/bundle/tagbar/tagbar-master/LICENSE @@ -0,0 +1,82 @@ +TAGBAR LICENSE + +This is the normal Vim license (see ':h license' in Vim) with the necessary +replacements for the project and maintainer information. + +I) There are no restrictions on distributing unmodified copies of Tagbar + except that they must include this license text. You can also distribute + unmodified parts of Tagbar, likewise unrestricted except that they must + include this license text. You are also allowed to include executables + that you made from the unmodified Tagbar sources, plus your own usage + examples and scripts. + +II) It is allowed to distribute a modified (or extended) version of Tagbar, + including executables and/or source code, when the following four + conditions are met: + 1) This license text must be included unmodified. + 2) The modified Tagbar must be distributed in one of the following five ways: + a) If you make changes to Tagbar yourself, you must clearly describe in + the distribution how to contact you. When the maintainer asks you + (in any way) for a copy of the modified Tagbar you distributed, you + must make your changes, including source code, available to the + maintainer without fee. The maintainer reserves the right to + include your changes in the official version of Tagbar. What the + maintainer will do with your changes and under what license they + will be distributed is negotiable. If there has been no negotiation + then this license, or a later version, also applies to your changes. + The current maintainer is Jan Larres . If this + changes it will be announced in appropriate places (most likely + majutsushi.github.io/tagbar and/or github.com/majutsushi/tagbar). + When it is completely impossible to contact the maintainer, the + obligation to send him your changes ceases. Once the maintainer has + confirmed that he has received your changes they will not have to be + sent again. + b) If you have received a modified Tagbar that was distributed as + mentioned under a) you are allowed to further distribute it + unmodified, as mentioned at I). If you make additional changes the + text under a) applies to those changes. + c) Provide all the changes, including source code, with every copy of + the modified Tagbar you distribute. This may be done in the form of + a context diff. You can choose what license to use for new code you + add. The changes and their license must not restrict others from + making their own changes to the official version of Tagbar. + d) When you have a modified Tagbar which includes changes as mentioned + under c), you can distribute it without the source code for the + changes if the following three conditions are met: + - The license that applies to the changes permits you to distribute + the changes to the Tagbar maintainer without fee or restriction, and + permits the Tagbar maintainer to include the changes in the official + version of Tagbar without fee or restriction. + - You keep the changes for at least three years after last + distributing the corresponding modified Tagbar. When the + maintainer or someone who you distributed the modified Tagbar to + asks you (in any way) for the changes within this period, you must + make them available to him. + - You clearly describe in the distribution how to contact you. This + contact information must remain valid for at least three years + after last distributing the corresponding modified Tagbar, or as + long as possible. + e) When the GNU General Public License (GPL) applies to the changes, + you can distribute the modified Tagbar under the GNU GPL version 2 + or any later version. + 3) A message must be added, at least in the documentation, such that the + user of the modified Tagbar is able to see that it was modified. When + distributing as mentioned under 2)e) adding the message is only + required for as far as this does not conflict with the license used for + the changes. + 4) The contact information as required under 2)a) and 2)d) must not be + removed or changed, except that the person himself can make + corrections. + +III) If you distribute a modified version of Tagbar, you are encouraged to use + the Tagbar license for your changes and make them available to the + maintainer, including the source code. The preferred way to do this is + by e-mail or by uploading the files to a server and e-mailing the URL. If + the number of changes is small (e.g., a modified Makefile) e-mailing a + context diff will do. The e-mail address to be used is + + +IV) It is not allowed to remove this license from the distribution of the + Tagbar sources, parts of it or from a modified version. You may use this + license for previous Tagbar releases instead of the license that they + came with, at your option. diff --git a/vim/bundle/tagbar/tagbar-master/README.md b/vim/bundle/tagbar/tagbar-master/README.md new file mode 100644 index 0000000..eceddbe --- /dev/null +++ b/vim/bundle/tagbar/tagbar-master/README.md @@ -0,0 +1,89 @@ +# Tagbar: a class outline viewer for Vim + +## What Tagbar is + +Tagbar is a Vim plugin that provides an easy way to browse the tags of the +current file and get an overview of its structure. It does this by creating a +sidebar that displays the ctags-generated tags of the current file, ordered by +their scope. This means that for example methods in C++ are displayed under +the class they are defined in. + +## What Tagbar is not + +Tagbar is not a general-purpose tool for managing `tags` files. It only +creates the tags it needs on-the-fly in-memory without creating any files. +`tags` file management is provided by other plugins, like for example +[easytags](https://github.com/xolox/vim-easytags). + +## Dependencies + +[Vim 7.0](http://www.vim.org/) (But see note below) +[Exuberant ctags 5.5](http://ctags.sourceforge.net/) + +## Installation + +Extract the archive or clone the repository into a directory in your +`'runtimepath'`, or use a plugin manager of your choice like +[pathogen](https://github.com/tpope/vim-pathogen). Don't forget to run +`:helptags` if your plugin manager doesn't do it for you so you can access the +documentation with `:help tagbar`. + +Note: Vim versions < 7.0.167 have a bug that prevents Tagbar from working. If +you are affected by this use this alternate Tagbar download instead: +[zip](https://github.com/majutsushi/tagbar/zipball/70fix). It is on par with +version 2.2 but probably won't be updated after that due to the amount of +changes required. + +If the ctags executable is not installed in one of the directories in your +`$PATH` environment variable you have to set the `g:tagbar_ctags_bin` +variable, see the documentation for more info. + +## Quickstart + +Put something like the following into your ~/.vimrc: + +```vim +nmap :TagbarToggle +``` + +If you do this the F8 key will toggle the Tagbar window. You can of course use +any shortcut you want. For more flexible ways to open and close the window +(and the rest of the functionality) see the documentation. + +## Support for additional filetypes + +For filetypes that are not supported by Exuberant Ctags check out [the +wiki](https://github.com/majutsushi/tagbar/wiki) to see whether other projects +offer support for them and how to use them. Please add any other +projects/configurations that you find or create yourself so that others can +benefit from them, too. + +## Note: If the file structure display is wrong + +If you notice that there are some errors in the way your file's structure is +displayed in Tagbar, please make sure that the bug is actually in Tagbar +before you report an issue. Since Tagbar uses +[exuberant-ctags](http://ctags.sourceforge.net/) and compatible programs to do +the actual file parsing, it is likely that the bug is actually in the program +responsible for that filetype instead. + +There is an example in `:h tagbar-issues` about how to run ctags manually so +you can determine where the bug actually is. If the bug is actually in ctags, +please report it on their website instead, as there is nothing I can do about +it in Tagbar. Thank you! + +You can also have a look at [ctags bugs that have previously been filed +against Tagbar](https://github.com/majutsushi/tagbar/issues?labels=ctags-bug&page=1&state=closed). + +## Screenshots + +![screenshot1](https://i.imgur.com/Sf9Ls2r.png) +![screenshot2](https://i.imgur.com/n4bpPv3.png) + +## License + +Vim license, see LICENSE + +## Maintainer + +Jan Larres <[jan@majutsushi.net](mailto:jan@majutsushi.net)> diff --git a/vim/bundle/tagbar/tagbar-master/autoload/tagbar.vim b/vim/bundle/tagbar/tagbar-master/autoload/tagbar.vim new file mode 100644 index 0000000..c1f6914 --- /dev/null +++ b/vim/bundle/tagbar/tagbar-master/autoload/tagbar.vim @@ -0,0 +1,4657 @@ +" ============================================================================ +" File: tagbar.vim +" Description: List the current file's tags in a sidebar, ordered by class etc +" Author: Jan Larres +" Licence: Vim licence +" Website: http://majutsushi.github.com/tagbar/ +" Version: 2.7 +" Note: This plugin was heavily inspired by the 'Taglist' plugin by +" Yegappan Lakshmanan and uses a small amount of code from it. +" +" Original taglist copyright notice: +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" taglist.vim is provided *as is* and comes with no warranty of +" any kind, either expressed or implied. In no event will the +" copyright holder be liable for any damamges resulting from the +" use of this software. +" ============================================================================ + +scriptencoding utf-8 + +" Initialization {{{1 + +" If another plugin calls an autoloaded Tagbar function on startup before the +" plugin/tagbar.vim file got loaded, load it explicitly +if exists(':Tagbar') == 0 + runtime plugin/tagbar.vim +endif + +if exists(':Tagbar') == 0 + echomsg 'Tagbar: Could not load plugin code, check your runtimepath!' + finish +endif + +" Basic init {{{2 + +redir => s:ftype_out +silent filetype +redir END +if s:ftype_out !~# 'detection:ON' + echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' + unlet s:ftype_out + finish +endif +unlet s:ftype_out + +let s:icon_closed = g:tagbar_iconchars[0] +let s:icon_open = g:tagbar_iconchars[1] + +let s:type_init_done = 0 +let s:autocommands_done = 0 +let s:statusline_in_use = 0 + +" 0: not checked yet; 1: checked and found; 2: checked and not found +let s:checked_ctags = 0 +let s:checked_ctags_types = 0 +let s:ctags_is_uctags = 0 +let s:ctags_types = {} + +let s:new_window = 1 +let s:is_maximized = 0 +let s:winrestcmd = '' +let s:short_help = 1 +let s:nearby_disabled = 0 +let s:paused = 0 +let s:pwin_by_tagbar = 0 +let s:buffer_seqno = 0 +let s:vim_quitting = 0 +let s:last_alt_bufnr = -1 + +let s:window_expanded = 0 +let s:expand_bufnr = -1 +let s:window_pos = { + \ 'pre' : { 'x' : 0, 'y' : 0 }, + \ 'post' : { 'x' : 0, 'y' : 0 } +\} + +let s:delayed_update_files = [] + +" Script-local variable needed since compare functions can't +" take extra arguments +let s:compare_typeinfo = {} + +let s:visibility_symbols = { + \ 'public' : '+', + \ 'protected' : '#', + \ 'private' : '-' +\ } + +let g:loaded_tagbar = 1 + +let s:last_highlight_tline = 0 +let s:debug = 0 +let s:debug_file = '' + +let s:warnings = { + \ 'type': [], + \ 'encoding': 0 +\ } + +" s:Init() {{{2 +function! s:Init(silent) abort + if s:checked_ctags == 2 && a:silent + return 0 + elseif s:checked_ctags != 1 + if !s:CheckForExCtags(a:silent) + return 0 + endif + endif + + if !s:checked_ctags_types + call s:GetSupportedFiletypes() + endif + + if !s:type_init_done + call s:InitTypes() + endif + + if !s:autocommands_done + call s:CreateAutocommands() + call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) + endif + + return 1 +endfunction + +" s:InitTypes() {{{2 +function! s:InitTypes() abort + call s:debug('Initializing types') + + let s:known_types = {} + + " Ant {{{3 + let type_ant = s:TypeInfo.New() + let type_ant.ctagstype = 'ant' + let type_ant.kinds = [ + \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.ant = type_ant + " Asm {{{3 + let type_asm = s:TypeInfo.New() + let type_asm.ctagstype = 'asm' + let type_asm.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.asm = type_asm + " ASP {{{3 + let type_aspvbs = s:TypeInfo.New() + let type_aspvbs.ctagstype = 'asp' + let type_aspvbs.kinds = [ + \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.aspvbs = type_aspvbs + " Asymptote {{{3 + " Asymptote gets parsed well using filetype = c + let type_asy = s:TypeInfo.New() + let type_asy.ctagstype = 'c' + let type_asy.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_asy.sro = '::' + let type_asy.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_asy.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let s:known_types.asy = type_asy + " Awk {{{3 + let type_awk = s:TypeInfo.New() + let type_awk.ctagstype = 'awk' + let type_awk.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.awk = type_awk + " Basic {{{3 + let type_basic = s:TypeInfo.New() + let type_basic.ctagstype = 'basic' + let type_basic.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.basic = type_basic + " BETA {{{3 + let type_beta = s:TypeInfo.New() + let type_beta.ctagstype = 'beta' + let type_beta.kinds = [ + \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.beta = type_beta + " C {{{3 + let type_c = s:TypeInfo.New() + let type_c.ctagstype = 'c' + let type_c.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_c.sro = '::' + let type_c.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_c.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let s:known_types.c = type_c + " C++ {{{3 + let type_cpp = s:TypeInfo.New() + let type_cpp.ctagstype = 'c++' + let type_cpp.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_cpp.sro = '::' + let type_cpp.kind2scope = { + \ 'g' : 'enum', + \ 'n' : 'namespace', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_cpp.scope2kind = { + \ 'enum' : 'g', + \ 'namespace' : 'n', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let s:known_types.cpp = type_cpp + let s:known_types.cuda = type_cpp + " C# {{{3 + let type_cs = s:TypeInfo.New() + let type_cs.ctagstype = 'c#' + let type_cs.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} + \ ] + let type_cs.sro = '.' + let type_cs.kind2scope = { + \ 'n' : 'namespace', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'g' : 'enum' + \ } + let type_cs.scope2kind = { + \ 'namespace' : 'n', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'enum' : 'g' + \ } + let s:known_types.cs = type_cs + " COBOL {{{3 + let type_cobol = s:TypeInfo.New() + let type_cobol.ctagstype = 'cobol' + let type_cobol.kinds = [ + \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.cobol = type_cobol + " DOS Batch {{{3 + let type_dosbatch = s:TypeInfo.New() + let type_dosbatch.ctagstype = 'dosbatch' + let type_dosbatch.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.dosbatch = type_dosbatch + " Eiffel {{{3 + let type_eiffel = s:TypeInfo.New() + let type_eiffel.ctagstype = 'eiffel' + let type_eiffel.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} + \ ] + let type_eiffel.sro = '.' " Not sure, is nesting even possible? + let type_eiffel.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'feature' + \ } + let type_eiffel.scope2kind = { + \ 'class' : 'c', + \ 'feature' : 'f' + \ } + let s:known_types.eiffel = type_eiffel + " Erlang {{{3 + let type_erlang = s:TypeInfo.New() + let type_erlang.ctagstype = 'erlang' + let type_erlang.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} + \ ] + let type_erlang.sro = '.' " Not sure, is nesting even possible? + let type_erlang.kind2scope = { + \ 'm' : 'module' + \ } + let type_erlang.scope2kind = { + \ 'module' : 'm' + \ } + let s:known_types.erlang = type_erlang + " Flex {{{3 + " Vim doesn't support Flex out of the box, this is based on rough + " guesses and probably requires + " http://www.vim.org/scripts/script.php?script_id=2909 + " Improvements welcome! + let type_as = s:TypeInfo.New() + let type_as.ctagstype = 'flex' + let type_as.kinds = [ + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} + \ ] + let type_as.sro = '.' + let type_as.kind2scope = { + \ 'c' : 'class' + \ } + let type_as.scope2kind = { + \ 'class' : 'c' + \ } + let s:known_types.mxml = type_as + let s:known_types.actionscript = type_as + " Fortran {{{3 + let type_fortran = s:TypeInfo.New() + let type_fortran.ctagstype = 'fortran' + let type_fortran.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, + \ 'stl' : 1}, + \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_fortran.sro = '.' " Not sure, is nesting even possible? + let type_fortran.kind2scope = { + \ 'm' : 'module', + \ 'p' : 'program', + \ 'f' : 'function', + \ 's' : 'subroutine' + \ } + let type_fortran.scope2kind = { + \ 'module' : 'm', + \ 'program' : 'p', + \ 'function' : 'f', + \ 'subroutine' : 's' + \ } + let s:known_types.fortran = type_fortran + " HTML {{{3 + let type_html = s:TypeInfo.New() + let type_html.ctagstype = 'html' + if s:ctags_is_uctags + let type_html.kinds = [ + \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'h', 'long' : 'H1 headings', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'H2 headings', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'j', 'long' : 'H3 headings', 'fold' : 0, 'stl' : 1}, + \ ] + else + let type_html.kinds = [ + \ {'short' : 'f', 'long' : 'JavaScript functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1} + \ ] + endif + let s:known_types.html = type_html + " Java {{{3 + let type_java = s:TypeInfo.New() + let type_java.ctagstype = 'java' + let type_java.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_java.sro = '.' + let type_java.kind2scope = { + \ 'g' : 'enum', + \ 'i' : 'interface', + \ 'c' : 'class' + \ } + let type_java.scope2kind = { + \ 'enum' : 'g', + \ 'interface' : 'i', + \ 'class' : 'c' + \ } + let s:known_types.java = type_java + " JavaScript {{{3 + " jsctags/doctorjs will be used if available. + let type_javascript = s:TypeInfo.New() + let type_javascript.ctagstype = 'javascript' + let jsctags = s:CheckFTCtags('jsctags', 'javascript') + if jsctags != '' + let type_javascript.kinds = [ + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_javascript.sro = '.' + let type_javascript.kind2scope = { + \ 'v' : 'namespace', + \ 'f' : 'namespace' + \ } + let type_javascript.scope2kind = { + \ 'namespace' : 'v' + \ } + let type_javascript.ctagsbin = jsctags + let type_javascript.ctagsargs = '-f -' + else + let type_javascript.kinds = [ + \ {'short': 'v', 'long': 'global variables', 'fold': 0, 'stl': 0}, + \ {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1}, + \ {'short': 'p', 'long': 'properties', 'fold': 0, 'stl': 0}, + \ {'short': 'm', 'long': 'methods', 'fold': 0, 'stl': 1}, + \ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1}, + \ ] + let type_javascript.sro = '.' + let type_javascript.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'method', + \ 'p' : 'property', + \ } + let type_javascript.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f', + \ } + endif + let s:known_types.javascript = type_javascript + " Lisp {{{3 + let type_lisp = s:TypeInfo.New() + let type_lisp.ctagstype = 'lisp' + let type_lisp.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.lisp = type_lisp + let s:known_types.clojure = type_lisp + " Lua {{{3 + let type_lua = s:TypeInfo.New() + let type_lua.ctagstype = 'lua' + let type_lua.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.lua = type_lua + " Make {{{3 + let type_make = s:TypeInfo.New() + let type_make.ctagstype = 'make' + let type_make.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.make = type_make + " Matlab {{{3 + let type_matlab = s:TypeInfo.New() + let type_matlab.ctagstype = 'matlab' + let type_matlab.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.matlab = type_matlab + " Ocaml {{{3 + let type_ocaml = s:TypeInfo.New() + let type_ocaml.ctagstype = 'ocaml' + let type_ocaml.kinds = [ + \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} + \ ] + let type_ocaml.sro = '.' " Not sure, is nesting even possible? + let type_ocaml.kind2scope = { + \ 'M' : 'Module', + \ 'c' : 'class', + \ 't' : 'type' + \ } + let type_ocaml.scope2kind = { + \ 'Module' : 'M', + \ 'class' : 'c', + \ 'type' : 't' + \ } + let s:known_types.ocaml = type_ocaml + " Pascal {{{3 + let type_pascal = s:TypeInfo.New() + let type_pascal.ctagstype = 'pascal' + let type_pascal.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.pascal = type_pascal + " Perl {{{3 + let type_perl = s:TypeInfo.New() + let type_perl.ctagstype = 'perl' + let type_perl.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.perl = type_perl + " PHP {{{3 + let type_php = s:TypeInfo.New() + let type_php.ctagstype = 'php' + let type_php.kinds = [ + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.php = type_php + " Python {{{3 + let type_python = s:TypeInfo.New() + let type_python.ctagstype = 'python' + let type_python.kinds = [ + \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_python.sro = '.' + let type_python.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'function' + \ } + let type_python.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f' + \ } + if s:ctags_is_uctags + " Universal Ctags treats member functions differently from normal + " functions + let type_python.kind2scope.m = 'member' + let type_python.scope2kind.member = 'm' + endif + let s:known_types.python = type_python + let s:known_types.pyrex = type_python + let s:known_types.cython = type_python + " REXX {{{3 + let type_rexx = s:TypeInfo.New() + let type_rexx.ctagstype = 'rexx' + let type_rexx.kinds = [ + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.rexx = type_rexx + " Ruby {{{3 + let type_ruby = s:TypeInfo.New() + let type_ruby.ctagstype = 'ruby' + let type_ruby.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_ruby.sro = '.' + let type_ruby.kind2scope = { + \ 'c' : 'class', + \ 'm' : 'class', + \ 'f' : 'class' + \ } + let type_ruby.scope2kind = { + \ 'class' : 'c' + \ } + let s:known_types.ruby = type_ruby + " Scheme {{{3 + let type_scheme = s:TypeInfo.New() + let type_scheme.ctagstype = 'scheme' + let type_scheme.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.scheme = type_scheme + let s:known_types.racket = type_scheme + " Shell script {{{3 + let type_sh = s:TypeInfo.New() + let type_sh.ctagstype = 'sh' + let type_sh.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.sh = type_sh + let s:known_types.csh = type_sh + let s:known_types.zsh = type_sh + " SLang {{{3 + let type_slang = s:TypeInfo.New() + let type_slang.ctagstype = 'slang' + let type_slang.kinds = [ + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.slang = type_slang + " SML {{{3 + let type_sml = s:TypeInfo.New() + let type_sml.ctagstype = 'sml' + let type_sml.kinds = [ + \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} + \ ] + let s:known_types.sml = type_sml + " SQL {{{3 + " The SQL ctags parser seems to be buggy for me, so this just uses the + " normal kinds even though scopes should be available. Improvements + " welcome! + let type_sql = s:TypeInfo.New() + let type_sql.ctagstype = 'sql' + let type_sql.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.sql = type_sql + " Tcl {{{3 + let type_tcl = s:TypeInfo.New() + let type_tcl.ctagstype = 'tcl' + let type_tcl.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.tcl = type_tcl + " LaTeX {{{3 + let type_tex = s:TypeInfo.New() + let type_tex.ctagstype = 'tex' + let type_tex.kinds = [ + \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} + \ ] + let type_tex.sro = '""' + let type_tex.kind2scope = { + \ 'p' : 'part', + \ 'c' : 'chapter', + \ 's' : 'section', + \ 'u' : 'subsection', + \ 'b' : 'subsubsection' + \ } + let type_tex.scope2kind = { + \ 'part' : 'p', + \ 'chapter' : 'c', + \ 'section' : 's', + \ 'subsection' : 'u', + \ 'subsubsection' : 'b' + \ } + let type_tex.sort = 0 + let s:known_types.tex = type_tex + " Vala {{{3 + " Vala is supported by the ctags fork provided by Anjuta, so only add the + " type if the fork is used to prevent error messages otherwise + if has_key(s:ctags_types, 'vala') || executable('anjuta-tags') + let type_vala = s:TypeInfo.New() + let type_vala.ctagstype = 'vala' + let type_vala.kinds = [ + \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} + \ ] + let type_vala.sro = '.' + " 'enum' doesn't seem to be used as a scope, but it can't hurt to have + " it here + let type_vala.kind2scope = { + \ 's' : 'struct', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 'e' : 'enum' + \ } + let type_vala.scope2kind = { + \ 'struct' : 's', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'enum' : 'e' + \ } + let s:known_types.vala = type_vala + endif + if !has_key(s:ctags_types, 'vala') && executable('anjuta-tags') + let s:known_types.vala.ctagsbin = 'anjuta-tags' + endif + " Vera {{{3 + " Why are variables 'virtual'? + let type_vera = s:TypeInfo.New() + let type_vera.ctagstype = 'vera' + let type_vera.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} + \ ] + let type_vera.sro = '.' " Nesting doesn't seem to be possible + let type_vera.kind2scope = { + \ 'g' : 'enum', + \ 'c' : 'class', + \ 'v' : 'virtual' + \ } + let type_vera.scope2kind = { + \ 'enum' : 'g', + \ 'class' : 'c', + \ 'virtual' : 'v' + \ } + let s:known_types.vera = type_vera + " Verilog {{{3 + let type_verilog = s:TypeInfo.New() + let type_verilog.ctagstype = 'verilog' + let type_verilog.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.verilog = type_verilog + " VHDL {{{3 + " The VHDL ctags parser unfortunately doesn't generate proper scopes + let type_vhdl = s:TypeInfo.New() + let type_vhdl.ctagstype = 'vhdl' + let type_vhdl.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.vhdl = type_vhdl + " Vim {{{3 + let type_vim = s:TypeInfo.New() + let type_vim.ctagstype = 'vim' + let type_vim.kinds = [ + \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} + \ ] + let s:known_types.vim = type_vim + " YACC {{{3 + let type_yacc = s:TypeInfo.New() + let type_yacc.ctagstype = 'yacc' + let type_yacc.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let s:known_types.yacc = type_yacc + " }}}3 + + for [type, typeinfo] in items(s:known_types) + let typeinfo.ftype = type + endfor + + for typeinfo in values(s:known_types) + call typeinfo.createKinddict() + endfor + + call s:LoadUserTypeDefs() + + " Add an 'unknown' kind to the types for pseudotags that we can't + " determine the correct kind for since they don't have any children that + " are not pseudotags and that therefore don't provide scope information + for typeinfo in values(s:known_types) + if has_key(typeinfo, 'kind2scope') + let unknown_kind = + \ {'short' : '?', 'long' : 'unknown', 'fold' : 0, 'stl' : 1} + " Check for existence first since some types exist under more than + " one name + if index(typeinfo.kinds, unknown_kind) == -1 + call add(typeinfo.kinds, unknown_kind) + endif + let typeinfo.kind2scope['?'] = 'unknown' + endif + endfor + + let s:type_init_done = 1 +endfunction + +" s:LoadUserTypeDefs() {{{2 +function! s:LoadUserTypeDefs(...) abort + if a:0 > 0 + let type = a:1 + + call s:debug("Initializing user type '" . type . "'") + + let defdict = {} + let defdict[type] = g:tagbar_type_{type} + else + call s:debug('Initializing user types') + + let defdict = tagbar#getusertypes() + endif + + let transformed = {} + for [type, def] in items(defdict) + let transformed[type] = s:TransformUserTypeDef(def) + let transformed[type].ftype = type + endfor + + for [key, value] in items(transformed) + if !has_key(s:known_types, key) || get(value, 'replace', 0) + let s:known_types[key] = s:TypeInfo.New(value) + else + call extend(s:known_types[key], value) + endif + call s:known_types[key].createKinddict() + endfor +endfunction + +" s:TransformUserTypeDef() {{{2 +" Transform the user definitions into the internal format +function! s:TransformUserTypeDef(def) abort + let newdef = copy(a:def) + + if has_key(a:def, 'kinds') + let newdef.kinds = [] + let kinds = a:def.kinds + for kind in kinds + let kindlist = split(kind, ':') + let kinddict = {'short' : kindlist[0], 'long' : kindlist[1]} + let kinddict.fold = get(kindlist, 2, 0) + let kinddict.stl = get(kindlist, 3, 1) + call add(newdef.kinds, kinddict) + endfor + endif + + " If the user only specified one of kind2scope and scope2kind then use it + " to generate the respective other + if has_key(a:def, 'kind2scope') && !has_key(a:def, 'scope2kind') + let newdef.scope2kind = {} + for [key, value] in items(a:def.kind2scope) + let newdef.scope2kind[value] = key + endfor + elseif has_key(a:def, 'scope2kind') && !has_key(a:def, 'kind2scope') + let newdef.kind2scope = {} + for [key, value] in items(a:def.scope2kind) + let newdef.kind2scope[value] = key + endfor + endif + + return newdef +endfunction + +" s:RestoreSession() {{{2 +" Properly restore Tagbar after a session got loaded +function! s:RestoreSession() abort + call s:debug('Restoring session') + + let curfile = fnamemodify(bufname('%'), ':p') + + let tagbarwinnr = bufwinnr(s:TagbarBufName()) + if tagbarwinnr == -1 + " Tagbar wasn't open in the saved session, nothing to do + return + else + let in_tagbar = 1 + if winnr() != tagbarwinnr + call s:goto_win(tagbarwinnr) + let in_tagbar = 0 + endif + endif + + let s:last_autofocus = 0 + + call s:Init(0) + + call s:InitWindow(g:tagbar_autoclose) + + call s:AutoUpdate(curfile, 0) + + if !in_tagbar + call s:goto_win('p') + endif +endfunction + +" s:MapKeys() {{{2 +function! s:MapKeys() abort + call s:debug('Mapping keys') + + nnoremap