diff --git a/pack/acp/README.md b/pack/acp/README.md index c4d60e4..c423776 100644 --- a/pack/acp/README.md +++ b/pack/acp/README.md @@ -3,10 +3,11 @@ Git submodules are slow, so handle this manually. * [opt/vim-pathogen](https://github.com/tpope/vim-pathogen) +* [start/TextFormat](https://github.com/vim-scripts/TextFormat) * [start/jellybeans.vim](https://github.com/nanotech/jellybeans.vim) * [start/mom.vim](https://github.com/vim-scripts/mom.vim) +* [start/neocomplete.vim](https://github.com/Shougo/neocomplete.vim) * [start/rust.vim](https://github.com/rust-lang/rust.vim) -* [start/TextFormat](https://github.com/vim-scripts/TextFormat) * [start/vim-airline](https://github.com/bling/vim-airline) * [start/vim-ps1](https://github.com/PProvost/vim-ps1) * [start/vim-surround](https://github.com/tpope/vim-surround) diff --git a/pack/acp/start/neocomplete.vim/.github/ISSUE_TEMPLATE.md b/pack/acp/start/neocomplete.vim/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5388e75 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,31 @@ +# Problems summary + + +## Expected + + +## Environment Information + * OS: + * Vim version: + + +## Provide a minimal .vimrc with less than 50 lines (Required!) + +```vim +" Your minimal .vimrc +set runtimepath+=~/path/to/neocomplete.nvim/ +let g:neocomplete#enable_at_startup = 1 +``` + + +## The reproduce ways from Vim starting (Required!) + + 1. foo + 2. bar + 3. baz + + +## Screen shot (if possible) + + +## Upload the log messages by `:redir` and `:message` diff --git a/pack/acp/start/neocomplete.vim/.gitignore b/pack/acp/start/neocomplete.vim/.gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/pack/acp/start/neocomplete.vim/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/pack/acp/start/neocomplete.vim/.travis.yml b/pack/acp/start/neocomplete.vim/.travis.yml new file mode 100644 index 0000000..ea0d78f --- /dev/null +++ b/pack/acp/start/neocomplete.vim/.travis.yml @@ -0,0 +1,8 @@ +sudo: false + +before_script: + - git clone https://github.com/syngan/vim-vimlint /tmp/vim-vimlint + - git clone https://github.com/ynkdir/vim-vimlparser /tmp/vim-vimlparser + +script: + - sh /tmp/vim-vimlint/bin/vimlint.sh -l /tmp/vim-vimlint -p /tmp/vim-vimlparser -e EVL103=1 -e EVL102.l:_=1 autoload diff --git a/pack/acp/start/neocomplete.vim/CONTRIBUTING.md b/pack/acp/start/neocomplete.vim/CONTRIBUTING.md new file mode 100644 index 0000000..07cd3f0 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Problems summary + +## Expected + +## Environment Information + * OS: + * Vim version: + +## Minimal vimrc less than 50 lines + + " Your vimrc + set nocompatible + + set runtimepath+=~/path/to/neocomplete.vim/ + + set fo+=aw + let g:neocomplete#enable_at_startup = 1 + let g:neocomplete#enable_auto_select = 0 + set tw=10 " just for testing purposes + +## Reproducable ways from Vim starting + + 1. + 2. + 3. + +## Screen shot (if possible) diff --git a/pack/acp/start/neocomplete.vim/README.md b/pack/acp/start/neocomplete.vim/README.md new file mode 100644 index 0000000..93f6435 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/README.md @@ -0,0 +1,197 @@ +neocomplete +=========== + +neocomplete is the abbreviation of "neo-completion with cache". It provides +keyword completion system by maintaining a cache of keywords in the current +buffer. neocomplete can be customized easily and has many more features than +Vim's built-in completion. + +Note: If you use neovim, you should use deoplete instead. +https://github.com/Shougo/deoplete.nvim + +## Installation + +**Note:** neocomplete requires Vim 7.3.885+ with Lua enabled. +See [requirements](#requirements) if you aren't sure whether you have this. + +1. Extract the files and put them in your Vim directory + (usually `~/.vim/` or `Program Files/Vim/vimfiles` on Windows). +2. Execute the `:NeoCompleteEnable` command or set `let g:neocomplete#enable_at_startup = 1` + in your `.vimrc` (**not** in `.gvimrc` or `_gvimrc`!) + +## Requirements + +neocomplete requires Vim 7.3.885+ compiled with [if\_lua](http://vimdoc.sourceforge.net/htmldoc/if_lua.html). +If `:echo has("lua")` returns `1`, then you're done; otherwise, see below. + +### Vim builds for Windows + + [github release](https://github.com/vim/vim-win32-installer/releases) +* [Vim 32bit](http://files.kaoriya.net/goto/vim73w32) +* [Vim 64bit](http://files.kaoriya.net/goto/vim73w64) +* [Vim 32bit alternative](http://tuxproject.de/projects/vim/) +* [Another alternative](http://wyw.dcweb.cn/#download) + +**Note:** the Vim build may not include the Lua DLL. In that case, +[download Lua](http://lua-users.org/wiki/LuaBinaries) and put the `lua52.dll` +file in the same directory as `gvim.exe`. + +### Vim for Mac OS X: + +[MacVim with `if\_lua`](https://github.com/zhaocai/macvim) + +Or, you can install MacVim with homebrew: + + brew install macvim --with-cscope --with-lua + brew linkapps macvim + +To install Vim (as opposed to MacVim) with homebrew: + + brew install vim --with-lua + +### Vim for Linux: + +#### Debian (or Ubuntu) + +Make sure you have any of these packages: +* vim-nox +* vim-gtk +* vim-gnome +* vim-athena + +Which package depends on your graphical environment (except vim-nox which is for vim with no GUI). + +#### Fedora + +The latest version of vim includes lua. +As of 2014-04-16 you need to [download the rpm](http://koji.fedoraproject.org/koji/packageinfo?packageID=216). + +#### Misc + +Be aware, your distribution's package manager may have a fairly outdated +Vim build (for example, Ubuntu 12.04 ships Vim 7.3.429). +However, [building Vim](http://vim.wikia.com/wiki/Building_Vim) on Linux is not difficult. +Remember to specify `--with-lua` (or `--with-features=huge`). + +### Vim for Cygwin: + +In a cygwin environment, the Lua interface is supported by default. + +If you want to make manually, you also need gcc and make. + +When everything is prepared, execute these commands. + + cd /usr/src + tar jxf vim-7.4.tar.bz2 + tar xvfz lua-5.1.5.tar.gz + cd vim74/ + ./configure --enable-luainterp --enable-gui=no \ + --without-x --enable-multibyte --prefix=/usr + make && make install + +To check if everything was successfull enter the following `vim --version`. You should see ` +lua` in the list of features. + +## Snippets + +The Snippets feature of neocomplete was split into a +[separate plugin](https://github.com/Shougo/neosnippet). + +A migration guide for existing users of neocomplcache is available: +[Migration guide](https://github.com/Shougo/neocomplete.vim/wiki/neocomplete-migration-guide) + + +## Screenshots + +### Original filename completion + +![Original filename completion.](https://f.cloud.github.com/assets/41495/622454/f519f6b8-cf42-11e2-921e-6e34dba148a6.png) +![Include filename completion.](https://f.cloud.github.com/assets/214488/623151/284ad86e-cf5b-11e2-828e-257d31bf0572.png) + +### Omni completion + +![Omni completion.](https://f.cloud.github.com/assets/41495/622456/fb2cc0bc-cf42-11e2-94e8-403cdcf5427e.png) + +### Completion with [vimshell](http://github.com/Shougo/vimshell) + +![Completion with vimshell(http://github.com/Shougo/vimshell).](https://f.cloud.github.com/assets/41495/622458/01dbc660-cf43-11e2-85f1-326e7432b0a1.png) + +### Vim completion (provided by [neco-vim](https://github.com/Shougo/neco-vim)) + +![Vim completion.](https://f.cloud.github.com/assets/41495/622457/fe90ad5e-cf42-11e2-8e03-8f189b5e26e5.png) +![Vim completion with animation.](https://f.cloud.github.com/assets/214488/623496/94ed19a2-cf68-11e2-8d33-3aad8a39d7c1.gif) + + +## Configuration Examples + +```vim +"Note: This option must be set in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! +" Disable AutoComplPop. +let g:acp_enableAtStartup = 0 +" Use neocomplete. +let g:neocomplete#enable_at_startup = 1 +" Use smartcase. +let g:neocomplete#enable_smart_case = 1 +" Set minimum syntax keyword length. +let g:neocomplete#sources#syntax#min_keyword_length = 3 + +" Define dictionary. +let g:neocomplete#sources#dictionary#dictionaries = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + +" Define keyword. +if !exists('g:neocomplete#keyword_patterns') + let g:neocomplete#keyword_patterns = {} +endif +let g:neocomplete#keyword_patterns['default'] = '\h\w*' + +" Plugin key-mappings. +inoremap neocomplete#undo_completion() +inoremap neocomplete#complete_common_string() + +" Recommended key-mappings. +" : close popup and save indent. +inoremap =my_cr_function() +function! s:my_cr_function() + return (pumvisible() ? "\" : "" ) . "\" + " For no inserting key. + "return pumvisible() ? "\" : "\" +endfunction +" : completion. +inoremap pumvisible() ? "\" : "\" +" , : close popup and delete backword char. +inoremap neocomplete#smart_close_popup()."\" +inoremap neocomplete#smart_close_popup()."\" +" Close popup by . +"inoremap pumvisible() ? "\" : "\" + +" AutoComplPop like behavior. +"let g:neocomplete#enable_auto_select = 1 + +" Shell like behavior(not recommended). +"set completeopt+=longest +"let g:neocomplete#enable_auto_select = 1 +"let g:neocomplete#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:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} +endif +"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' +"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + +" For perlomni.vim setting. +" https://github.com/c9s/perlomni.vim +let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::' +``` diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete.vim new file mode 100644 index 0000000..3da1c8b --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete.vim @@ -0,0 +1,329 @@ +"============================================================================= +" FILE: neocomplete.vim +" AUTHOR: Shougo Matsushita +" 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_neocomplete') + runtime! plugin/neocomplete.vim +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +let g:neocomplete#max_list = + \ get(g:, 'neocomplete#max_list', 100) +let g:neocomplete#max_keyword_width = + \ get(g:, 'neocomplete#max_keyword_width', 80) +let g:neocomplete#auto_completion_start_length = + \ get(g:, 'neocomplete#auto_completion_start_length', 2) +let g:neocomplete#manual_completion_start_length = + \ get(g:, 'neocomplete#manual_completion_start_length', 0) +let g:neocomplete#min_keyword_length = + \ get(g:, 'neocomplete#min_keyword_length', 4) +let g:neocomplete#enable_ignore_case = + \ get(g:, 'neocomplete#enable_ignore_case', &ignorecase) +let g:neocomplete#enable_smart_case = + \ get(g:, 'neocomplete#enable_smart_case', &infercase) +let g:neocomplete#enable_camel_case = + \ get(g:, 'neocomplete#enable_camel_case', 0) +let g:neocomplete#disable_auto_complete = + \ get(g:, 'neocomplete#disable_auto_complete', 0) +let g:neocomplete#enable_fuzzy_completion = + \ get(g:, 'neocomplete#enable_fuzzy_completion', 1) +let g:neocomplete#auto_complete_delay = + \ get(g:, 'neocomplete#auto_complete_delay', 50) +let g:neocomplete#enable_auto_select = + \ get(g:, 'neocomplete#enable_auto_select', 0) +let g:neocomplete#enable_auto_delimiter = + \ get(g:, 'neocomplete#enable_auto_delimiter', 0) +let g:neocomplete#lock_buffer_name_pattern = + \ get(g:, 'neocomplete#lock_buffer_name_pattern', '') +let g:neocomplete#lock_iminsert = + \ get(g:, 'neocomplete#lock_iminsert', 0) +let g:neocomplete#enable_multibyte_completion = + \ get(g:, 'neocomplete#enable_multibyte_completion', 0) +let g:neocomplete#release_cache_time = + \ get(g:, 'neocomplete#release_cache_time', 900) +let g:neocomplete#skip_auto_completion_time = + \ get(g:, 'neocomplete#skip_auto_completion_time', '0.3') +let g:neocomplete#enable_auto_close_preview = + \ get(g:, 'neocomplete#enable_auto_close_preview', 0) +let g:neocomplete#enable_refresh_always = + \ get(g:, 'neocomplete#enable_refresh_always', 0) +let g:neocomplete#fallback_mappings = + \ get(g:, 'neocomplete#fallback_mappings', []) +let g:neocomplete#sources = + \ get(g:, 'neocomplete#sources', {}) +let g:neocomplete#keyword_patterns = + \ get(g:, 'neocomplete#keyword_patterns', {}) +let g:neocomplete#delimiter_patterns = + \ get(g:, 'neocomplete#delimiter_patterns', {}) +let g:neocomplete#text_mode_filetypes = + \ get(g:, 'neocomplete#text_mode_filetypes', {}) +let g:neocomplete#tags_filter_patterns = + \ get(g:, 'neocomplete#tags_filter_patterns', {}) +let g:neocomplete#force_omni_input_patterns = + \ get(g:, 'neocomplete#force_omni_input_patterns', {}) +let g:neocomplete#ignore_source_files = + \ get(g:, 'neocomplete#ignore_source_files', []) +"}}} + +function! neocomplete#initialize() abort "{{{ + return neocomplete#init#enable() +endfunction"}}} + +function! neocomplete#get_current_neocomplete() abort "{{{ + if !exists('b:neocomplete') + call neocomplete#init#_current_neocomplete() + endif + + return b:neocomplete +endfunction"}}} +function! neocomplete#get_context() abort "{{{ + return neocomplete#get_current_neocomplete().context +endfunction"}}} + +" Source helper. "{{{ +function! neocomplete#define_source(source) abort "{{{ + let sources = neocomplete#variables#get_sources() + for source in neocomplete#util#convert2list(a:source) + let source = neocomplete#init#_source(source) + if !source.disabled + let sources[source.name] = source + endif + endfor +endfunction"}}} +function! neocomplete#define_filter(filter) abort "{{{ + let filters = neocomplete#variables#get_filters() + for filter in neocomplete#util#convert2list(a:filter) + let filters[filter.name] = neocomplete#init#_filter(filter) + endfor +endfunction"}}} +function! neocomplete#available_sources() abort "{{{ + return copy(neocomplete#variables#get_sources()) +endfunction"}}} +function! neocomplete#custom_source(source_name, option_name, value) abort "{{{ + return neocomplete#custom#source(a:source_name, a:option_name, a:value) +endfunction"}}} + +function! neocomplete#dup_filter(list) abort "{{{ + return neocomplete#util#dup_filter(a:list) +endfunction"}}} + +function! neocomplete#system(...) abort "{{{ + return call('neocomplete#util#system', a:000) +endfunction"}}} +function! neocomplete#has_vimproc() abort "{{{ + return neocomplete#util#has_vimproc() +endfunction"}}} + +function! neocomplete#get_cur_text(...) abort "{{{ + " Return cached text. + let neocomplete = neocomplete#get_current_neocomplete() + return (a:0 == 0 && mode() ==# 'i' && + \ neocomplete.cur_text != '') ? + \ neocomplete.cur_text : neocomplete#helper#get_cur_text() +endfunction"}}} +function! neocomplete#get_keyword_pattern(...) abort "{{{ + let filetype = a:0 != 0? a:1 : neocomplete#get_context_filetype() + if a:0 < 2 + return neocomplete#helper#unite_patterns( + \ g:neocomplete#keyword_patterns, filetype) + endif + + let source = neocomplete#variables#get_source(a:2) + if !has_key(source, 'neocomplete__keyword_patterns') + let source.neocomplete__keyword_patterns = {} + endif + if !has_key(source.neocomplete__keyword_patterns, filetype) + let source.neocomplete__keyword_patterns[filetype] = + \ neocomplete#helper#unite_patterns( + \ source.keyword_patterns, filetype) + endif + + return source.neocomplete__keyword_patterns[filetype] +endfunction"}}} +function! neocomplete#get_keyword_pattern_end(...) abort "{{{ + return '\%('.call('neocomplete#get_keyword_pattern', a:000).'\m\)$' +endfunction"}}} +function! neocomplete#match_word(...) abort "{{{ + return call('neocomplete#helper#match_word', a:000) +endfunction"}}} +function! neocomplete#is_enabled() abort "{{{ + return neocomplete#init#is_enabled() +endfunction"}}} +function! neocomplete#is_locked(...) abort "{{{ + return neocomplete#is_cache_disabled() || &paste + \ || (&t_Co != '' && &t_Co < 8) + \ || g:neocomplete#disable_auto_complete +endfunction"}}} +function! neocomplete#is_cache_disabled() abort "{{{ + let ignore_filetypes = ['fuf', 'ku'] + let bufnr = a:0 > 0 ? a:1 : bufnr('%') + return !neocomplete#is_enabled() + \ || index(ignore_filetypes, &filetype) >= 0 + \ || neocomplete#get_current_neocomplete().lock + \ || (g:neocomplete#lock_buffer_name_pattern != '' && + \ bufname(bufnr) =~ g:neocomplete#lock_buffer_name_pattern) +endfunction"}}} +function! neocomplete#is_auto_select() abort "{{{ + return g:neocomplete#enable_auto_select +endfunction"}}} +function! neocomplete#is_auto_complete() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + return neocomplete.is_auto_complete +endfunction"}}} +function! neocomplete#is_eskk_enabled() abort "{{{ + return exists('*eskk#is_enabled') && eskk#is_enabled() +endfunction"}}} +function! neocomplete#is_multibyte_input(cur_text) abort "{{{ + return (exists('b:skk_on') && b:skk_on) + \ || (!g:neocomplete#enable_multibyte_completion + \ && char2nr(split(a:cur_text, '\zs')[-1]) > 0x80) +endfunction"}}} +function! neocomplete#is_text_mode() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let filetypes = g:neocomplete#text_mode_filetypes + return get(filetypes, neocomplete.context_filetype, 0) + \ || get(filetypes, '_', 0) +endfunction"}}} +function! neocomplete#is_windows() abort "{{{ + return neocomplete#util#is_windows() +endfunction"}}} +function! neocomplete#is_prefetch() abort "{{{ + return 1 +endfunction"}}} +function! neocomplete#exists_echodoc() abort "{{{ + return exists('g:loaded_echodoc') && g:loaded_echodoc +endfunction"}}} +function! neocomplete#within_comment() abort "{{{ + return neocomplete#get_current_neocomplete().within_comment +endfunction"}}} +function! neocomplete#print_error(string) abort "{{{ + echohl Error | echomsg '[neocomplete] ' . a:string | echohl None +endfunction"}}} +function! neocomplete#print_warning(string) abort "{{{ + echohl WarningMsg | echomsg '[neocomplete] ' . a:string | echohl None +endfunction"}}} +function! neocomplete#head_match(checkstr, headstr) abort "{{{ + let checkstr = &ignorecase ? + \ tolower(a:checkstr) : a:checkstr + let headstr = &ignorecase ? + \ tolower(a:headstr) : a:headstr + return stridx(checkstr, headstr) == 0 +endfunction"}}} +function! neocomplete#get_source_filetypes(filetype) abort "{{{ + return neocomplete#helper#get_source_filetypes(a:filetype) +endfunction"}}} +function! neocomplete#escape_match(str) abort "{{{ + return escape(a:str, '~"*\.^$[]') +endfunction"}}} +function! neocomplete#get_context_filetype(...) abort "{{{ + let neocomplete = exists('b:neocomplete') ? + \ b:neocomplete : neocomplete#get_current_neocomplete() + + if a:0 != 0 || mode() !=# 'i' || + \ neocomplete.context_filetype == '' + call neocomplete#context_filetype#set() + endif + + return neocomplete.context_filetype +endfunction"}}} +function! neocomplete#print_debug(expr) abort "{{{ + if g:neocomplete#enable_debug + echomsg string(a:expr) + endif +endfunction"}}} +function! neocomplete#get_data_directory() abort "{{{ + let g:neocomplete#data_directory = + \ get(g:, 'neocomplete#data_directory', + \ ($XDG_CACHE_HOME != '' ? + \ $XDG_CACHE_HOME . '/neocomplete' : '~/.cache/neocomplete')) + let directory = neocomplete#util#substitute_path_separator( + \ neocomplete#util#expand(g:neocomplete#data_directory)) + if !isdirectory(directory) + if neocomplete#util#is_sudo() + call neocomplete#print_error(printf( + \ 'Cannot create Directory "%s" in sudo session.', directory)) + else + call mkdir(directory, 'p') + endif + endif + + return directory +endfunction"}}} +function! neocomplete#complete_check() abort "{{{ + return neocomplete#helper#complete_check() +endfunction"}}} +function! neocomplete#skip_next_complete() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.skip_next_complete = 1 +endfunction"}}} +function! neocomplete#get_default_matchers() abort "{{{ + return map(copy(neocomplete#get_current_neocomplete().default_matchers), + \ 'v:val.name') +endfunction"}}} +function! neocomplete#set_default_matchers(matchers) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.default_matchers = neocomplete#init#_filters( + \ neocomplete#util#convert2list(a:matchers)) +endfunction"}}} + +function! neocomplete#set_dictionary_helper(variable, keys, value) abort "{{{ + return neocomplete#util#set_dictionary_helper( + \ a:variable, a:keys, a:value) +endfunction"}}} +function! neocomplete#disable_default_dictionary(variable) abort "{{{ + return neocomplete#util#disable_default_dictionary(a:variable) +endfunction"}}} +function! neocomplete#filetype_complete(arglead, cmdline, cursorpos) abort "{{{ + return neocomplete#helper#filetype_complete(a:arglead, a:cmdline, a:cursorpos) +endfunction"}}} +"}}} + +" Key mapping functions. "{{{ +function! neocomplete#smart_close_popup() abort + return neocomplete#mappings#smart_close_popup() +endfunction +function! neocomplete#close_popup() abort + return neocomplete#mappings#close_popup() +endfunction +function! neocomplete#cancel_popup() abort + return neocomplete#mappings#cancel_popup() +endfunction +function! neocomplete#undo_completion() abort + return neocomplete#mappings#undo_completion() +endfunction +function! neocomplete#complete_common_string() abort + return neocomplete#mappings#complete_common_string() +endfunction +function! neocomplete#start_manual_complete(...) abort + return call('neocomplete#mappings#start_manual_complete', a:000) +endfunction +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/async_cache.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/async_cache.vim new file mode 100644 index 0000000..5b4516e --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/async_cache.vim @@ -0,0 +1,276 @@ +"============================================================================= +" FILE: async_cache.vim +" AUTHOR: Shougo Matsushita +" 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) abort "{{{ + " args: funcname, outputname filename pattern_file_name mark minlen fileencoding + let [funcname, outputname, filename, pattern_file_name, mark, minlen, fileencoding] + \ = a:argv + + if funcname ==# 'load_from_file' + let keyword_list = s:load_from_file( + \ filename, pattern_file_name, mark, minlen, fileencoding, 1) + + let string = '{' . escape(string(keyword_list)[1 : -2], '\\') . '}' + else + let keyword_list = s:load_from_tags( + \ filename, pattern_file_name, mark, minlen, fileencoding) + let string = string(keyword_list) + endif + + if empty(keyword_list) + return + endif + + " For neocomplete. + " Output cache. + call writefile([string], outputname) +endfunction"}}} + +function! s:load_from_file(filename, pattern_file_name, mark, minlen, fileencoding, is_string) abort "{{{ + if !filereadable(a:filename) + " File not found. + return [] + endif + + let lines = readfile(a:filename) + if a:fileencoding !=# &encoding + let lines = map(lines, 's:iconv(v:val, a:fileencoding, &encoding)') + endif + + let pattern = get(readfile(a:pattern_file_name), 0, '\h\w*') + let pattern2 = '^\%('.pattern.'\m\)' + let keyword_list = [] + let dup_check = {} + + for line in lines "{{{ + let match = match(line, pattern) + while match >= 0 "{{{ + let match_str = matchstr(line, pattern2, match) + + if !has_key(dup_check, match_str) && len(match_str) >= a:minlen + " Append list. + call add(keyword_list, match_str) + let dup_check[match_str] = 1 + endif + + if match_str == '' + break + endif + + let match += len(match_str) + + let match = match(line, pattern, match) + endwhile"}}} + endfor"}}} + + if !a:is_string + call map(keyword_list, "{'word' : match_str}") + endif + + return keyword_list +endfunction"}}} + +function! s:load_from_tags(filename, pattern_file_name, mark, minlen, fileencoding) abort "{{{ + let keyword_lists = [] + let dup_check = {} + + let [tags_file_name, filter_pattern] = + \ readfile(a:pattern_file_name)[1 : 2] + 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) + return s:load_from_file(a:filename, a:pattern_file_name, + \ a:mark, a:minlen, 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') + " Substitute extends and implements. + let abbr = substitute(abbr, + \'\<\%(extends\|implements\)\s\+\S\+\>', '', '') + " Substitute marker. + let abbr = substitute(abbr, '"\s*{{{', '', '') + + let keyword = { + \ 'word' : tag[0], 'abbr' : abbr, 'menu' : '', + \ 'kind' : option['kind'], + \ } + 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) abort "{{{ + " 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 = strdisplaywidth(a:str) + if width > a:width + let ret = s:strwidthpart(ret, a:width) + let width = strdisplaywidth(ret) + endif + + if width < a:width + let ret .= repeat(' ', a:width - width) + endif + + return ret +endfunction"}}} + +function! s:strwidthpart(str, width) abort "{{{ + let ret = a:str + let width = strdisplaywidth(a:str) + while width > a:width + let char = matchstr(ret, '.$') + let ret = ret[: -1 - len(char)] + let width -= strwidth(char) + endwhile + + return ret +endfunction"}}} + +function! s:iconv(expr, from, to) abort + 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 argc() == 7 && + \ (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! neocomplete#async_cache#main(argv) abort "{{{ + call s:main(a:argv) + endfunction"}}} +endif + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/cache.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/cache.vim new file mode 100644 index 0000000..08e6c1b --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/cache.vim @@ -0,0 +1,298 @@ +"============================================================================= +" FILE: cache.vim +" AUTHOR: Shougo Matsushita +" 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 conditionneocomplete#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 = neocomplete#util#get_vital().import('System.Cache.Deprecated') + +" Cache loader. +function! neocomplete#cache#load_from_cache(cache_dir, filename, ...) abort "{{{ + let is_string = get(a:000, 0, 0) + + try + " Note: For neocomplete. + let list = [] + + if is_string + lua << EOF +do + local ret = vim.eval('list') + local list = {} + for line in io.lines(vim.eval( + 'neocomplete#cache#encode_name(a:cache_dir, a:filename)')) do + list = (loadstring) and loadstring('return ' .. line)() + or load('return ' .. line)() + end + + for i = 1, #list do + ret:add(list[i]) + end +end +EOF + else + let list = eval(get(neocomplete#cache#readfile( + \ a:cache_dir, a:filename), 0, '[]')) + endif + + if !empty(list) && is_string && type(list[0]) != type('') + " Type check. + throw 'Type error' + endif + + return list + catch + " echomsg string(v:errmsg) + " echomsg string(v:exception) + + " Delete old cache file. + let cache_name = + \ neocomplete#cache#encode_name(a:cache_dir, a:filename) + if filereadable(cache_name) + call delete(cache_name) + endif + + return [] + endtry +endfunction"}}} + +" New cache loader. +function! neocomplete#cache#check_cache(cache_dir, key, async_cache_dictionary, keyword_cache, is_string) abort "{{{ + if !has_key(a:async_cache_dictionary, a:key) + return + endif + + let cache_list = a:async_cache_dictionary[a:key] + + if !has_key(a:keyword_cache, a:key) + let a:keyword_cache[a:key] = [] + endif + for cache in filter(copy(cache_list), 'filereadable(v:val.cachename)') + let a:keyword_cache[a:key] += neocomplete#cache#load_from_cache( + \ a:cache_dir, cache.filename, a:is_string) + endfor + + call filter(cache_list, '!filereadable(v:val.cachename)') + + if empty(cache_list) + " Delete from dictionary. + call remove(a:async_cache_dictionary, a:key) + return + endif +endfunction"}}} + +" For buffer source cache loader. +function! neocomplete#cache#get_cache_list(cache_dir, async_cache_list) abort "{{{ + let cache_list = a:async_cache_list + + let loaded_keywords = [] + let loaded = 0 + for cache in filter(copy(cache_list), 'filereadable(v:val.cachename)') + let loaded = 1 + let loaded_keywords = neocomplete#cache#load_from_cache( + \ a:cache_dir, cache.filename, 1) + endfor + + call filter(cache_list, '!filereadable(v:val.cachename)') + + return [loaded, loaded_keywords] +endfunction"}}} + +function! neocomplete#cache#save_cache(cache_dir, filename, keyword_list) abort "{{{ + if neocomplete#util#is_sudo() + return + endif + + " Output cache. + let string = substitute(substitute(substitute( + \ string(a:keyword_list), '^[', '{', ''), + \ ']$', '}', ''), '\\', '\\\\', 'g') + call neocomplete#cache#writefile( + \ a:cache_dir, a:filename, [string]) +endfunction"}}} + +" Cache helper. +function! neocomplete#cache#getfilename(cache_dir, filename) abort "{{{ + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.getfilename(cache_dir, a:filename) +endfunction"}}} +function! neocomplete#cache#filereadable(cache_dir, filename) abort "{{{ + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.filereadable(cache_dir, a:filename) +endfunction"}}} +function! neocomplete#cache#readfile(cache_dir, filename) abort "{{{ + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.readfile(cache_dir, a:filename) +endfunction"}}} +function! neocomplete#cache#writefile(cache_dir, filename, list) abort "{{{ + if neocomplete#util#is_sudo() + return + endif + + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.writefile(cache_dir, a:filename, a:list) +endfunction"}}} +function! neocomplete#cache#encode_name(cache_dir, filename) abort + " Check cache directory. + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.getfilename(cache_dir, a:filename) +endfunction +function! neocomplete#cache#check_old_cache(cache_dir, filename) abort "{{{ + let cache_dir = neocomplete#get_data_directory() . '/' . a:cache_dir + return s:Cache.check_old_cache(cache_dir, a:filename) +endfunction"}}} +function! neocomplete#cache#make_directory(directory) abort "{{{ + let directory = + \ neocomplete#get_data_directory() .'/'.a:directory + if !isdirectory(directory) + if neocomplete#util#is_sudo() + call neocomplete#print_error(printf( + \ 'Cannot create Directory "%s" in sudo session.', directory)) + else + call mkdir(directory, 'p') + endif + endif +endfunction"}}} + +let s:sdir = neocomplete#util#substitute_path_separator( + \ fnamemodify(expand(''), ':p:h')) + +function! neocomplete#cache#async_load_from_file(cache_dir, filename, pattern, mark) abort "{{{ + if !neocomplete#cache#check_old_cache(a:cache_dir, a:filename) + \ || neocomplete#util#is_sudo() + return neocomplete#cache#encode_name(a:cache_dir, a:filename) + endif + + let pattern_file_name = + \ neocomplete#cache#encode_name('keyword_patterns', a:filename) + let cache_name = + \ neocomplete#cache#encode_name(a:cache_dir, a:filename) + + " Create pattern file. + call neocomplete#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:neocomplete#min_keyword_length, fileencoding + \ ] + return s:async_load(argv, a:cache_dir, a:filename) +endfunction"}}} +function! neocomplete#cache#async_load_from_tags(cache_dir, filename, filetype, pattern, mark) abort "{{{ + if !neocomplete#cache#check_old_cache(a:cache_dir, a:filename) + \ || neocomplete#util#is_sudo() + return neocomplete#cache#encode_name(a:cache_dir, a:filename) + endif + + let cache_name = + \ neocomplete#cache#encode_name(a:cache_dir, a:filename) + let pattern_file_name = + \ neocomplete#cache#encode_name('tags_patterns', a:filename) + + let tags_file_name = '$dummy$' + + let filter_pattern = + \ get(g:neocomplete#tags_filter_patterns, a:filetype, '') + call neocomplete#cache#writefile('tags_patterns', a:filename, + \ [a:pattern, tags_file_name, filter_pattern, a:filetype]) + + " args: funcname, outputname, filename + " pattern mark minlen encoding + let fileencoding = &fileencoding == '' ? &encoding : &fileencoding + let argv = [ + \ 'load_from_tags', cache_name, a:filename, pattern_file_name, a:mark, + \ g:neocomplete#min_keyword_length, fileencoding + \ ] + return s:async_load(argv, a:cache_dir, a:filename) +endfunction"}}} +function! s:async_load(argv, cache_dir, filename) abort "{{{ + let vim_path = s:search_vim_path() + + if vim_path == '' || !executable(vim_path) + call neocomplete#async_cache#main(a:argv) + else + 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)) + endif + + return neocomplete#cache#encode_name(a:cache_dir, a:filename) +endfunction"}}} +function! s:search_vim_path() abort "{{{ + if exists('s:vim_path') + return s:vim_path + endif + + if !neocomplete#has_vimproc() + return '' + endif + + 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 neocomplete#print_error( + \ 'You installed MacVim in not default directory!'. + \ ' You must add MacVim installed path in $PATH.') + let g:neocomplete#use_vimproc = 0 + return '' + endif + + let s:vim_path = '/Applications/MacVim.app/Contents/MacOS/Vim' + else + call neocomplete#print_error( + \ printf('Vim path : "%s" is not found.'. + \ ' You must add "%s" installed path in $PATH.', + \ v:progname, v:progname)) + let g:neocomplete#use_vimproc = 0 + return '' + endif + else + let base_path = neocomplete#util#substitute_path_separator( + \ fnamemodify(paths[0], ':p:h')) + + let s:vim_path = base_path . '/vim' + + if !executable(s:vim_path) && neocomplete#util#is_mac() + " Note: Search "Vim" instead of vim. + let s:vim_path = base_path. '/Vim' + endif + endif + + return s:vim_path +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/commands.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/commands.vim new file mode 100644 index 0000000..211794f --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/commands.vim @@ -0,0 +1,100 @@ +"============================================================================= +" FILE: commands.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#commands#_initialize() abort "{{{ + command! -nargs=1 NeoCompleteAutoCompletionLength + \ call s:set_auto_completion_length() +endfunction"}}} + +function! neocomplete#commands#_toggle_lock() abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#init#enable() + return + endif + + if neocomplete#get_current_neocomplete().lock + echo 'neocomplete is unlocked!' + call neocomplete#commands#_unlock() + else + echo 'neocomplete is locked!' + call neocomplete#commands#_lock() + endif +endfunction"}}} + +function! neocomplete#commands#_lock() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.lock = 1 +endfunction"}}} + +function! neocomplete#commands#_unlock() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.lock = 0 +endfunction"}}} + +function! neocomplete#commands#_clean() abort "{{{ + " Delete cache files. + let data_directory = neocomplete#get_data_directory() + for directory in filter(neocomplete#util#glob( + \ data_directory.'/*'), 'isdirectory(v:val)') + if has('patch-7.4.1120') + call delete(data_directory, 'rf') + else + for filename in filter(neocomplete#util#glob(directory.'/*'), + \ '!isdirectory(v:val)') + call delete(filename) + endfor + endif + endfor + + echo 'Cleaned cache files in: ' . data_directory +endfunction"}}} + +function! neocomplete#commands#_set_file_type(filetype) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.context_filetype = a:filetype +endfunction"}}} + +function! s:rand(max) abort "{{{ + 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) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.completion_length = a:len +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/complete.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/complete.vim new file mode 100644 index 0000000..ef3d130 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/complete.vim @@ -0,0 +1,348 @@ +"============================================================================= +" FILE: complete.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#complete#_get_results(cur_text, ...) abort "{{{ + call neocomplete#print_debug('start get_complete_sources') + + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.start_time = reltime() + + " Comment check. + let neocomplete.within_comment = + \ neocomplete#helper#get_syn_name(1) ==# 'Comment' + + let complete_sources = call( + \ 'neocomplete#complete#_set_results_pos', [a:cur_text] + a:000) + if empty(complete_sources) + call neocomplete#print_debug('Skipped.') + return [] + endif + + if neocomplete#is_auto_complete() + let complete_pos = + \ neocomplete#complete#_get_complete_pos(complete_sources) + call neocomplete#complete#_set_previous_position(a:cur_text, complete_pos) + endif + + call neocomplete#complete#_set_results_words(complete_sources) + + return filter(copy(complete_sources), + \ '!empty(v:val.neocomplete__context.candidates)') +endfunction"}}} + +function! neocomplete#complete#_get_complete_pos(sources) abort "{{{ + if empty(a:sources) + return -1 + endif + + return min([col('.')] + map(copy(a:sources), + \ 'v:val.neocomplete__context.complete_pos')) +endfunction"}}} + +function! neocomplete#complete#_get_words(sources, complete_pos, complete_str) abort "{{{ + let frequencies = neocomplete#variables#get_frequencies() + if exists('*neocomplete#sources#buffer#get_frequencies') + let frequencies = extend(copy( + \ neocomplete#sources#buffer#get_frequencies()), + \ frequencies) + endif + + " Append prefix. + let candidates = [] + let len_words = 0 + for source in sort(filter(deepcopy(a:sources), + \ '!empty(v:val.neocomplete__context.candidates)'), + \ 's:compare_source_rank') + let context = source.neocomplete__context + let words = type(context.candidates[0]) == type('') ? + \ map(copy(context.candidates), "{'word': v:val}") : + \ deepcopy(context.candidates) + let context.candidates = words + + call neocomplete#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] + + " Fix complete position. + let context.complete_pos = a:complete_pos + let context.complete_str = prefix + + for candidate in words + let candidate.word = prefix . candidate.word + endfor + endif + + lua << EOF + do + local frequencies = vim.eval('frequencies') + local candidates = vim.eval('words') + for i = 0, #candidates-1 do + if frequencies[candidates[i].word] ~= nil then + candidates[i].rank = frequencies[candidates[i].word] + end + end + end +EOF + + let words = neocomplete#helper#call_filters( + \ source.neocomplete__sorters, source, {}) + if empty(words) + continue + endif + + if source.max_candidates > 0 + let words = words[: len(source.max_candidates)-1] + endif + + let words = neocomplete#helper#call_filters( + \ source.neocomplete__converters, source, {}) + + if empty(words) + continue + endif + + " Set default menu. + if get(words[0], 'menu', '') !~ '^\[.*\' + call s:set_default_menu(words, source) + endif + + let candidates += words + let len_words += len(words) + + if g:neocomplete#max_list > 0 + \ && len_words > g:neocomplete#max_list + break + endif + + if neocomplete#complete_check() + return [] + endif + endfor + + call filter(candidates, 'v:val.word !=# a:complete_str') + + if g:neocomplete#max_list > 0 + let candidates = candidates[: g:neocomplete#max_list] + endif + + " Check dup and set icase. + let icase = g:neocomplete#enable_ignore_case && + \ !((g:neocomplete#enable_smart_case + \ || g:neocomplete#enable_camel_case) && a:complete_str =~ '\u') + if icase + for candidate in candidates + let candidate.icase = 1 + endfor + endif + + if neocomplete#complete_check() + return [] + endif + + return candidates +endfunction"}}} +function! neocomplete#complete#_set_results_pos(cur_text, ...) abort "{{{ + " Initialize sources. + let neocomplete = neocomplete#get_current_neocomplete() + + let filetype = neocomplete#get_context_filetype() + let sources = (a:0 > 0) ? a:1 : + \ (filetype ==# neocomplete.sources_filetype) ? + \ neocomplete.sources : neocomplete#helper#get_sources_list() + + let pos = winsaveview() + + " Try source completion. "{{{ + let complete_sources = [] + for source in filter(values(sources), + \ 'neocomplete#helper#is_enabled_source(v:val, filetype)') + if !source.loaded + call neocomplete#helper#call_hook(source, 'on_init', {}) + let source.loaded = 1 + endif + + let context = source.neocomplete__context + let context.input = a:cur_text + let context.filetype = filetype + let context.filetypes = neocomplete#context_filetype#filetypes() + + try + let complete_pos = s:use_previous_result(source, context) ? + \ context.prev_complete_pos : + \ has_key(source, 'get_complete_position') ? + \ source.get_complete_position(context) : + \ neocomplete#helper#match_word(context.input, + \ neocomplete#get_keyword_pattern_end(filetype, source.name))[0] + catch + call neocomplete#print_error(v:throwpoint) + call neocomplete#print_error(v:exception) + call neocomplete#print_error( + \ 'Error occurred in source''s get_complete_position()!') + call neocomplete#print_error( + \ 'Source name is ' . source.name) + return complete_sources + finally + if winsaveview() != pos + call winrestview(pos) + endif + endtry + + if complete_pos < 0 + let context.complete_pos = -1 + let context.complete_str = '' + continue + endif + + let complete_str = context.input[complete_pos :] + if neocomplete#is_auto_complete() && + \ (source.input_pattern == '' || + \ context.input !~# '\%(' . source.input_pattern.'\m\)$') && + \ len(complete_str) < source.min_pattern_length + " Skip. + let context.complete_pos = -1 + let context.complete_str = '' + 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! neocomplete#complete#_set_results_words(sources) abort "{{{ + " Try source completion. + + " Save options. + let ignorecase_save = &ignorecase + let pos = winsaveview() + + try + for source in a:sources + if neocomplete#complete_check() + return + endif + + let context = source.neocomplete__context + + let &ignorecase = (g:neocomplete#enable_smart_case + \ || g:neocomplete#enable_camel_case) ? + \ context.complete_str !~ '\u' + \ : g:neocomplete#enable_ignore_case + + if s:use_previous_result(source, context) + " Use previous candidates. + let context.candidates = deepcopy(context.prev_candidates) + else + try + let context.candidates = source.gather_candidates(context) + catch + call neocomplete#print_error(v:throwpoint) + call neocomplete#print_error(v:exception) + call neocomplete#print_error( + \ 'Source name is ' . source.name) + call neocomplete#print_error( + \ 'Error occurred in source''s gather_candidates()!') + + return + finally + if winsaveview() != pos + call winrestview(pos) + endif + endtry + + let context.prev_line = context.input + let context.prev_candidates = copy(context.candidates) + let context.prev_complete_pos = context.complete_pos + endif + + if !empty(context.candidates) + let matchers = empty(source.neocomplete__matchers) ? + \ neocomplete#get_current_neocomplete().default_matchers + \ : source.neocomplete__matchers + let context.candidates = neocomplete#helper#call_filters( + \ matchers, source, {}) + endif + + call neocomplete#print_debug(source.name) + endfor + finally + let &ignorecase = ignorecase_save + endtry +endfunction"}}} + +function! neocomplete#complete#_check_previous_position(cur_text, complete_pos) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + return a:complete_pos == neocomplete.old_complete_pos + \ && line('.') == neocomplete.old_linenr + \ && a:cur_text ==# neocomplete.old_cur_text +endfunction"}}} +function! neocomplete#complete#_set_previous_position(cur_text, complete_pos) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.old_complete_pos = a:complete_pos + let neocomplete.old_linenr = line('.') + let neocomplete.old_cur_text = a:cur_text +endfunction"}}} + +" Source rank order. "{{{ +function! s:compare_source_rank(i1, i2) abort + return a:i2.rank - a:i1.rank +endfunction"}}} + +function! s:set_default_menu(words, source) abort "{{{ + lua << EOF + do + local candidates = vim.eval('a:words') + local mark = vim.eval('a:source.mark') .. ' ' + for i = 0, #candidates-1 do + candidates[i].menu = mark .. (candidates[i].menu ~= nil and + candidates[i].menu or '') + end + end +EOF +endfunction"}}} + +function! s:use_previous_result(source, context) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + return !a:source.is_volatile + \ && substitute(a:context.input, '\k\+$', '', '') + \ ==# substitute(a:context.prev_line, '\k\+$', '', '') + \ && stridx(a:context.input, a:context.prev_line) == 0 + \ && !empty(a:context.prev_candidates) + \ && line('.') == neocomplete.old_linenr +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/context_filetype.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/context_filetype.vim new file mode 100644 index 0000000..4cb7487 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/context_filetype.vim @@ -0,0 +1,67 @@ +"============================================================================= +" FILE: context_filetype.vim +" AUTHOR: Shougo Matsushita +" 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 + +" context_filetype.vim installation check. +if !exists('s:exists_context_filetype') + silent! call context_filetype#version() + let s:exists_context_filetype = exists('*context_filetype#version') +endif + +function! neocomplete#context_filetype#set() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let context_filetype = + \ s:exists_context_filetype ? + \ context_filetype#get_filetype() : &filetype + if context_filetype == '' + let context_filetype = 'nothing' + endif + let neocomplete.context_filetype = context_filetype + let neocomplete.context_filetypes = s:exists_context_filetype ? + \ context_filetype#get_filetypes(context_filetype) : + \ [context_filetype] + split(context_filetype, '\.') + + return neocomplete.context_filetype +endfunction"}}} +function! neocomplete#context_filetype#get(filetype) abort "{{{ + let context_filetype = + \ s:exists_context_filetype ? + \ context_filetype#get_filetype(a:filetype) : a:filetype + if context_filetype == '' + let context_filetype = 'nothing' + endif + + return context_filetype +endfunction"}}} +function! neocomplete#context_filetype#filetypes() abort "{{{ + return copy(neocomplete#get_current_neocomplete().context_filetypes) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/custom.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/custom.vim new file mode 100644 index 0000000..f642563 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/custom.vim @@ -0,0 +1,54 @@ +"============================================================================= +" FILE: custom.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#custom#get() abort "{{{ + if !exists('s:custom') + let s:custom = {} + let s:custom.sources = {} + let s:custom.sources._ = {} + endif + + return s:custom +endfunction"}}} + +function! neocomplete#custom#source(source_name, option_name, value) abort "{{{ + let custom_sources = neocomplete#custom#get().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"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters.vim new file mode 100644 index 0000000..4b68fd5 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters.vim @@ -0,0 +1,48 @@ +"============================================================================= +" FILE: filters.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#fuzzy_escape(string) abort "{{{ + " Escape string for lua regexp. + let string = substitute(neocomplete#filters#escape(a:string), + \ '\w', '\0.*', 'g') + if g:neocomplete#enable_camel_case && string =~ '\u' + let string = substitute(string, '\l', '[\0\u\0\E]', 'g') + endif + return string +endfunction"}}} + +function! neocomplete#filters#escape(string) abort "{{{ + " Escape string for lua regexp. + return substitute(a:string, + \ '[%\[\]().*+?^$-]', '%\0', 'g') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_abbr.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_abbr.vim new file mode 100644 index 0000000..39a2b67 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_abbr.vim @@ -0,0 +1,66 @@ +"============================================================================= +" FILE: converter_abbr.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_abbr#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_abbr', + \ 'description' : 'abbreviate abbr converter', + \} + +function! s:converter.filter(context) abort "{{{ + if g:neocomplete#max_keyword_width < 0 + return a:context.candidates + endif + + lua << EOF +do + local candidates = vim.eval('a:context.candidates') + local max = vim.eval('g:neocomplete#max_keyword_width') + for i = 0, #candidates-1 do + local abbr = candidates[i].abbr == nil and + candidates[i].word or candidates[i].abbr + if string.len(abbr) > max then + vim.command("let a:context.candidates[".. i .."].abbr = neocomplete#util#truncate_smart(".. + "get(a:context.candidates[".. i .."], 'abbr', " .. + "a:context.candidates[".. i .."].word), g:neocomplete#max_keyword_width," .. + "g:neocomplete#max_keyword_width/2, '..')") + end + end +end +EOF + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_add_paren.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_add_paren.vim new file mode 100644 index 0000000..d635ed0 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_add_paren.vim @@ -0,0 +1,53 @@ +"============================================================================= +" FILE: converter_add_paren.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_add_paren#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_add_paren', + \ 'description' : 'add parenthesis if needed', + \} + +function! s:converter.filter(context) abort "{{{ + for candidate in filter(copy(a:context.candidates), " + \ v:val.word !~ '()\\?$' && + \ (get(v:val, 'abbr', '') =~ '(.*)' + \ || get(v:val, 'info', '') =~ '(.*)') + \ ") + let candidate.word .= '(' + endfor + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_case.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_case.vim new file mode 100644 index 0000000..9bcbe23 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_case.vim @@ -0,0 +1,80 @@ +"============================================================================= +" FILE: converter_case.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_case#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_case', + \ 'description' : 'case converter', + \} + +function! s:converter.filter(context) abort "{{{ + if !neocomplete#is_text_mode() && !neocomplete#within_comment() + return a:context.candidates + endif + + if a:context.complete_str =~ '^\l\{3}$' + for candidate in s:get_convert_candidates(a:context.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\{3}$' + for candidate in s:get_convert_candidates(a:context.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 s:get_convert_candidates(a:context.candidates) + let candidate.word = toupper(candidate.word[0]). + \ 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"}}} + +function! s:get_convert_candidates(candidates) abort + return filter(copy(a:candidates), + \ "get(v:val, 'neocomplete__convertable', 1) + \ && v:val.word =~ '^[a-zA-Z0-9_''-]\\+$'") +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_delimiter.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_delimiter.vim new file mode 100644 index 0000000..1fd8b90 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_delimiter.vim @@ -0,0 +1,114 @@ +"============================================================================= +" FILE: converter_delimiter.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_delimiter#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_delimiter', + \ 'description' : 'delimiter converter', + \} + +" @vimlint(EVL102, 1, l:delim_cnt) +function! s:converter.filter(context) abort "{{{ + if g:neocomplete#max_keyword_width < 0 + return a:context.candidates + endif + + " Delimiter check. + for delimiter in get(g:neocomplete#delimiter_patterns, + \ a:context.filetype, []) + " Count match. + let delim_cnt = 0 + let delimiter_vim = neocomplete#util#escape_pattern(delimiter) + let matchend = matchend(a:context.complete_str, delimiter_vim) + while matchend >= 0 + let matchend = matchend(a:context.complete_str, + \ delimiter_vim, matchend) + let delim_cnt += 1 + endwhile + + lua << EOF + do + local candidates = vim.eval('a:context.candidates') + local pattern = vim.eval('neocomplete#filters#escape(delimiter)')..'.' + for i = 0, #candidates-1 do + if string.find(candidates[i].word, pattern, 1) ~= nil and ( + not candidates[i].abbr or + string.gsub(candidates[i].word, '%([^)]*%)?', '()') + == string.gsub(candidates[i].abbr, '%([^)]*%)?', '()')) then + vim.command('call s:process_delimiter(a:context, '.. + 'a:context.candidates['.. i .. + '], delimiter_vim, delim_cnt)') + end + end + end +EOF + endfor + + return a:context.candidates +endfunction"}}} +" @vimlint(EVL102, 0, l:delim_cnt) + +function! s:process_delimiter(context, candidate, delimiter, delim_cnt) abort + let candidate = a:candidate + + let split_list = split(candidate.word, a:delimiter.'\ze.', 1) + let delimiter_sub = substitute( + \ a:delimiter, '\\\(.\)', '\1', 'g') + let candidate.abbr = join( + \ split(get(candidate, 'abbr', candidate.word), + \ a:delimiter.'\ze.', 1)[ : a:delim_cnt], + \ delimiter_sub) + let candidate.word = join(split_list[ : a:delim_cnt], delimiter_sub) + + if g:neocomplete#max_keyword_width >= 0 + \ && len(candidate.abbr) > g:neocomplete#max_keyword_width + let candidate.abbr = substitute(candidate.abbr, + \ '\(\h\)\w*'.a:delimiter, '\1'.delimiter_sub, 'g') + endif + if a:delim_cnt+1 < len(split_list) + let candidate.abbr .= delimiter_sub . '~' + let candidate.dup = 0 + + if g:neocomplete#enable_auto_delimiter + let candidate.word .= delimiter_sub + endif + endif + + " Clear previous result. + let a:context.prev_candidates = [] + let a:context.prev_complete_pos = -1 + let a:context.prev_line = '' +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_disable_abbr.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_disable_abbr.vim new file mode 100644 index 0000000..4c1eab3 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_disable_abbr.vim @@ -0,0 +1,49 @@ +"============================================================================= +" FILE: converter_disable_abbr.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_disable_abbr#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_disable_abbr', + \ 'description' : 'disable abbr converter', + \} + +function! s:converter.filter(context) abort "{{{ + for candidate in a:context.candidates + let candidate.abbr = candidate.word + endfor + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_last_paren.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_last_paren.vim new file mode 100644 index 0000000..b53cbde --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_last_paren.vim @@ -0,0 +1,50 @@ +"============================================================================= +" FILE: converter_remove_last_paren.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_remove_last_paren#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_remove_last_paren', + \ 'description' : 'remove last parenthesis', + \} + +function! s:converter.filter(context) abort "{{{ + for candidate in a:context.candidates + let candidate.word = + \ substitute(candidate.word, '[\[<({]$', '', '') + endfor + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_overlap.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_overlap.vim new file mode 100644 index 0000000..7c42a4d --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/converter_remove_overlap.vim @@ -0,0 +1,122 @@ +"============================================================================= +" FILE: converter_overlap.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#converter_remove_overlap#define() abort "{{{ + return s:converter +endfunction"}}} + +let s:converter = { + \ 'name' : 'converter_remove_overlap', + \ 'description' : 'remove overlapped characters', + \} + +function! s:converter.filter(context) abort "{{{ + let next = matchstr(getline('.')[ + \ len(neocomplete#helper#get_cur_text()) :], '^\S\+') + if next == '' + return a:context.candidates + endif + + let candidates = [] + for candidate in a:context.candidates + let overlapped_len = neocomplete#filters# + \converter_remove_overlap#length(candidate.word, next) + + if overlapped_len > 0 + if !has_key(candidate, 'abbr') + let candidate.abbr = candidate.word + endif + + let candidate.word = candidate.word[: -overlapped_len-1] + call add(candidates, candidate) + elseif !neocomplete#is_auto_complete() + call add(candidates, candidate) + endif + endfor + + if empty(candidates) + return a:context.candidates + endif + + let candidates = filter(candidates, + \ 'v:val.word !=# a:context.complete_str') + + return candidates +endfunction"}}} + +function! neocomplete#filters#converter_remove_overlap#length(left, right) abort "{{{ + if a:left == '' || a:right == '' + return 0 + endif + + let ret = 0 + + lua << EOF +do + local ret = vim.eval('ret') + local left = vim.eval('a:left') + local right = vim.eval('a:right') + local left_len = string.len(left) + local right_len = string.len(right) + + if left_len > right_len then + left = string.sub(left, left_len-right_len, left_len) + elseif left_len < right_len then + right = string.sub(right, 0, left_len) + end + + if left == right then + ret = math.min(left_len, right_len) + else + local length = 1 + left_len = string.len(left) + while 1 do + local pattern = string.sub(left, left_len-length+1, left_len) + local pos = string.find(right, pattern, 1, 1) + if pos == nil then + break + end + length = length + pos - 1 + if string.sub(left, left_len-length+1, left_len) == + string.sub(right, 1, length) then + ret = length + length = length + 1 + end + end + end + vim.command('let ret = ' .. ret) +end +EOF + + return ret +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_fuzzy.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_fuzzy.vim new file mode 100644 index 0000000..635d363 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_fuzzy.vim @@ -0,0 +1,89 @@ +"============================================================================= +" FILE: matcher_fuzzy.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#matcher_fuzzy#define() abort "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_fuzzy', + \ 'description' : 'fuzzy matcher', + \} + +function! s:matcher.filter(context) abort "{{{ + if len(a:context.complete_str) > 10 + " Mix fuzzy mode. + let len = len(a:context.complete_str) + let fuzzy_len = len - len/(1 + len/10) + let pattern = + \ neocomplete#filters#escape( + \ a:context.complete_str[: fuzzy_len-1]) . + \ neocomplete#filters#fuzzy_escape( + \ a:context.complete_str[fuzzy_len :]) + else + let pattern = neocomplete#filters#fuzzy_escape( + \ a:context.complete_str) + endif + + " The first letter must be matched. + let pattern = '^' . pattern + + lua << EOF +do + local pattern = vim.eval('pattern') + local input = vim.eval('a:context.complete_str') + local candidates = vim.eval('a:context.candidates') + if vim.eval('&ignorecase') ~= 0 then + pattern = string.lower(pattern) + input = string.lower(input) + for i = #candidates-1, 0, -1 do + local word = vim.type(candidates[i]) == 'dict' and + string.lower(candidates[i].word) or string.lower(candidates[i]) + if string.find(word, pattern, 1) == nil then + candidates[i] = nil + end + end + else + for i = #candidates-1, 0, -1 do + local word = vim.type(candidates[i]) == 'dict' and + candidates[i].word or candidates[i] + if string.find(word, pattern, 1) == nil then + candidates[i] = nil + end + end + end +end +EOF + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_head.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_head.vim new file mode 100644 index 0000000..01af9be --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_head.vim @@ -0,0 +1,72 @@ +"============================================================================= +" FILE: matcher_head.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#matcher_head#define() abort "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_head', + \ 'description' : 'head matcher', + \} + +function! s:matcher.filter(context) abort "{{{ + lua << EOF +do + local pattern = vim.eval( + "'^' . neocomplete#filters#escape(a:context.complete_str)") + local input = vim.eval('a:context.complete_str') + local candidates = vim.eval('a:context.candidates') + if vim.eval('&ignorecase') ~= 0 then + pattern = string.lower(pattern) + for i = #candidates-1, 0, -1 do + local word = vim.type(candidates[i]) == 'dict' and + string.lower(candidates[i].word) or string.lower(candidates[i]) + if string.find(word, pattern, 1) == nil then + candidates[i] = nil + end + end + else + for i = #candidates-1, 0, -1 do + local word = vim.type(candidates[i]) == 'dict' and + candidates[i].word or candidates[i] + if string.find(word, pattern, 1) == nil then + candidates[i] = nil + end + end + end +end +EOF + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_length.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_length.vim new file mode 100644 index 0000000..4a68d21 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_length.vim @@ -0,0 +1,63 @@ +"============================================================================= +" FILE: matcher_length.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#matcher_length#define() abort "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_length', + \ 'description' : 'input length matcher', + \} + +function! s:matcher.filter(context) abort "{{{ + if empty(a:context.candidates) + return [] + endif + + lua << EOF +do + local candidates = vim.eval('a:context.candidates') + local len = string.len(vim.eval('a:context.complete_str')) + for i = #candidates-1, 0, -1 do + local word = vim.type(candidates[i]) == 'dict' and + candidates[i].word or candidates[i] + if string.len(word) <= len then + candidates[i] = nil + end + end +end +EOF + + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_nothing.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_nothing.vim new file mode 100644 index 0000000..6e663fc --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/matcher_nothing.vim @@ -0,0 +1,45 @@ +"============================================================================= +" FILE: matcher_nothing.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#matcher_nothing#define() abort "{{{ + return s:matcher +endfunction"}}} + +let s:matcher = { + \ 'name' : 'matcher_nothing', + \ 'description' : 'input nothing matcher', + \} + +function! s:matcher.filter(context) abort "{{{ + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_filename.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_filename.vim new file mode 100644 index 0000000..e1efaf9 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_filename.vim @@ -0,0 +1,50 @@ +"============================================================================= +" FILE: sorter_filename.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#sorter_filename#define() abort "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_filename', + \ 'description' : 'sort by filename order', + \} + +function! s:sorter.filter(context) abort "{{{ + let dir_list = filter(copy(a:context.candidates), + \ 'v:val.action__is_directory') + let file_list = filter(copy(a:context.candidates), + \ '!v:val.action__is_directory') + return neocomplete#helper#sort_human(dir_list) + \ + neocomplete#helper#sort_human(file_list) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_length.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_length.vim new file mode 100644 index 0000000..4875c99 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_length.vim @@ -0,0 +1,53 @@ +"============================================================================= +" FILE: sorter_length.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#sorter_length#define() abort "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_length', + \ 'description' : 'sort by length order', + \} + +function! s:sorter.filter(context) abort "{{{ + return sort(a:context.candidates, 's:compare') +endfunction"}}} + +function! s:compare(i1, i2) abort + 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/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_rank.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_rank.vim new file mode 100644 index 0000000..def4a8f --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_rank.vim @@ -0,0 +1,74 @@ +"============================================================================= +" FILE: sorter_rank.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#sorter_rank#define() abort "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_rank', + \ 'description' : 'sort by matched rank order', + \} + +function! s:sorter.filter(context) abort "{{{ + lua << EOF +do + local candidates = vim.eval('a:context.candidates') + local t = {} + local input = string.lower(vim.eval('a:context.input')) + for i = 1, #candidates do + t[i] = candidates[i-1] + local ti = t[i] + + -- Match position. + ti.neocomplete__match = select(1, string.find( + string.lower(ti.word), input, 1, true)) + if ti.neocomplete__match == nil then + ti.neocomplete__match = string.len(ti.word) + end + + if ti.rank == nil then + ti.rank = 0 + end + end + table.sort(t, function(a, b) + return (a.rank == b.rank) and (a.neocomplete__match + < b.neocomplete__match) or (a.rank > b.rank) + end) + for i = 0, #candidates-1 do + candidates[i] = t[i+1] + end +end +EOF + return a:context.candidates +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_word.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_word.vim new file mode 100644 index 0000000..ffe399b --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/filters/sorter_word.vim @@ -0,0 +1,49 @@ +"============================================================================= +" FILE: sorter_word.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#filters#sorter_word#define() abort "{{{ + return s:sorter +endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_word', + \ 'description' : 'sort by word order', + \} + +function! s:sorter.filter(context) abort "{{{ + return sort(a:context.candidates, 's:compare') +endfunction"}}} + +function! s:compare(i1, i2) abort + return a:i1.word ># a:i2.word +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/handler.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/handler.vim new file mode 100644 index 0000000..2a71736 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/handler.vim @@ -0,0 +1,367 @@ +"============================================================================= +" FILE: handler.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#handler#_on_moved_i() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + if neocomplete.linenr != line('.') + call neocomplete#helper#clear_result() + endif + let neocomplete.linenr = line('.') + + call s:close_preview_window() +endfunction"}}} +function! neocomplete#handler#_on_insert_enter() abort "{{{ + if !neocomplete#is_enabled() + return + endif + + let neocomplete = neocomplete#get_current_neocomplete() + if neocomplete.linenr != line('.') + call neocomplete#helper#clear_result() + endif + let neocomplete.linenr = line('.') + + if &l:foldmethod ==# 'expr' && foldlevel('.') != 0 + foldopen + endif +endfunction"}}} +function! neocomplete#handler#_on_insert_leave() abort "{{{ + call neocomplete#helper#clear_result() + + call s:close_preview_window() + call s:make_cache_current_line() + + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.cur_text = '' +endfunction"}}} +function! neocomplete#handler#_on_complete_done() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + + if neocomplete.event !=# 'mapping' + \ && !s:is_delimiter() && !get(neocomplete, 'refresh', 0) + call neocomplete#mappings#close_popup() + endif + + " Use v:completed_item feature. + if !exists('v:completed_item') || empty(v:completed_item) + return + endif + + let complete_str = v:completed_item.word + if complete_str == '' + return + endif + + let frequencies = neocomplete#variables#get_frequencies() + if !has_key(frequencies, complete_str) + let frequencies[complete_str] = 20 + else + let frequencies[complete_str] += 20 + endif +endfunction"}}} +function! neocomplete#handler#_on_insert_char_pre() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.skip_next_complete = 0 + + if pumvisible() && g:neocomplete#enable_refresh_always + " Auto refresh + call feedkeys("\(neocomplete_auto_refresh)") + endif + + if neocomplete#is_cache_disabled() + return + endif + + if neocomplete.old_char != ' ' && v:char == ' ' && v:count == 0 + call s:make_cache_current_line() + endif + + let neocomplete.old_char = v:char +endfunction"}}} +function! neocomplete#handler#_on_text_changed() abort "{{{ + if neocomplete#is_cache_disabled() + return + endif + + if getline('.') == '' + call s:make_cache_current_line() + endif + + if !neocomplete#util#is_text_changed() + call s:indent_current_line() + endif +endfunction"}}} + +function! s:complete_delay(timer) abort "{{{ + let event = s:timer.event + unlet! s:timer + return s:do_auto_complete(event) +endfunction"}}} + +function! neocomplete#handler#_do_auto_complete(event) abort "{{{ + if s:check_in_do_auto_complete(a:event) + return + endif + + if g:neocomplete#auto_complete_delay > 0 && has('timers') + \ && (!has('gui_macvim') || has('patch-8.0.95')) + if exists('s:timer') + call timer_stop(s:timer.id) + endif + if a:event !=# 'Manual' + let s:timer = { 'event': a:event } + let s:timer.id = timer_start( + \ g:neocomplete#auto_complete_delay, + \ function('s:complete_delay')) + return + endif + endif + + return s:do_auto_complete(a:event) +endfunction"}}} + +function! s:do_auto_complete(event) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + + if s:check_in_do_auto_complete(a:event) + return + endif + + let neocomplete.skipped = 0 + let neocomplete.event = a:event + call neocomplete#helper#clear_result() + + " Set context filetype. + call neocomplete#context_filetype#set() + + let cur_text = neocomplete#get_cur_text(1) + let complete_pos = -1 + + call neocomplete#print_debug('cur_text = ' . cur_text) + + try + " Prevent infinity loop. + if s:is_skip_auto_complete(cur_text) + call neocomplete#print_debug('Skipped.') + return + endif + + let complete_pos = s:check_force_omni(cur_text) + if complete_pos >= 0 + return + endif + + " Check multibyte input or eskk or spaces. + if cur_text =~ '^\s*$' + \ || (!neocomplete#is_eskk_enabled() + \ && neocomplete#is_multibyte_input(cur_text)) + call neocomplete#print_debug('Skipped.') + return + endif + + try + let neocomplete.is_auto_complete = 1 + + " Do prefetch. + let neocomplete.complete_sources = + \ neocomplete#complete#_get_results(cur_text) + finally + let neocomplete.is_auto_complete = 0 + endtry + + if empty(neocomplete.complete_sources) + call s:check_fallback(cur_text) + return + endif + + " Start auto complete. + call s:complete_key( + \ "\(neocomplete_start_auto_complete)") + finally + call neocomplete#complete#_set_previous_position(cur_text, complete_pos) + endtry +endfunction"}}} + +function! s:check_in_do_auto_complete(event) abort "{{{ + if neocomplete#is_locked() + \ || (a:event !=# 'InsertEnter' && mode() !=# 'i') + return 1 + endif + + " Detect completefunc. + if &l:completefunc != '' && &l:buftype =~ 'nofile' + return 1 + endif + + let neocomplete = neocomplete#get_current_neocomplete() + " Detect foldmethod. + if (&l:foldmethod ==# 'expr' || &l:foldmethod ==# 'syntax') + \ && !neocomplete.detected_foldmethod + \ && a:event !=# 'InsertEnter' + \ && line('.') > 1000 + let neocomplete.detected_foldmethod = 1 + call neocomplete#print_error( + \ printf('foldmethod = "%s" is detected.', &foldmethod)) + redir => foldmethod + verbose setlocal foldmethod? + redir END + for msg in split(substitute(foldmethod, '\t', '', 'g'), "\n") + call neocomplete#print_error(msg) + endfor + call neocomplete#print_error( + \ 'You should disable it or install FastFold plugin.') + endif +endfunction"}}} +function! s:is_skip_auto_complete(cur_text) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + + if (g:neocomplete#lock_iminsert && &l:iminsert) + \ || (&l:formatoptions =~# '[tca]' && &l:textwidth > 0 + \ && strdisplaywidth(a:cur_text) >= &l:textwidth) + let neocomplete.skip_next_complete = 0 + return 1 + endif + + let skip = neocomplete.skip_next_complete + + if !skip || s:is_delimiter() + return 0 + endif + + let neocomplete.skip_next_complete = 0 + return skip +endfunction"}}} +function! s:close_preview_window() abort "{{{ + if g:neocomplete#enable_auto_close_preview + \ && bufname('%') !=# '[Command Line]' + \ && winnr('$') != 1 && !&l:previewwindow + \ && !neocomplete#is_cache_disabled() + " Close preview window. + pclose! + endif +endfunction"}}} +function! s:make_cache_current_line() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + if neocomplete#helper#is_enabled_source('buffer', + \ neocomplete.context_filetype) + " Caching current cache line. + call neocomplete#sources#buffer#make_cache_current_line() + endif + if neocomplete#helper#is_enabled_source('member', + \ neocomplete.context_filetype) + " Caching current cache line. + call neocomplete#sources#member#make_cache_current_line() + endif +endfunction"}}} +function! s:check_force_omni(cur_text) abort "{{{ + let cur_text = a:cur_text + let complete_pos = neocomplete#helper#get_force_omni_complete_pos(cur_text) + + if complete_pos >= 0 + \ && !neocomplete#complete#_check_previous_position( + \ cur_text, complete_pos) + call s:complete_key("\(neocomplete_start_omni_complete)") + endif + + return complete_pos +endfunction"}}} +function! s:check_fallback(cur_text) abort "{{{ + let cur_text = a:cur_text + let complete_pos = match(cur_text, '\h\w*$') + let neocomplete = neocomplete#get_current_neocomplete() + if empty(g:neocomplete#fallback_mappings) + \ || len(matchstr(cur_text, '\h\w*$')) + \ < g:neocomplete#auto_completion_start_length + \ || neocomplete.skip_next_complete + \ || neocomplete#complete#_check_previous_position( + \ cur_text, complete_pos) + return + endif + + let key = '' + for i in range(0, len(g:neocomplete#fallback_mappings)-1) + let key .= '=neocomplete#mappings#fallback(' . i . ')' + endfor + execute 'inoremap (neocomplete_fallback)' key + + " Fallback + call s:complete_key("\(neocomplete_fallback)") +endfunction"}}} + +function! s:complete_key(key) abort "{{{ + call neocomplete#helper#complete_configure() + + call feedkeys(a:key) +endfunction"}}} + +function! s:indent_current_line() abort "{{{ + " indent line matched by indentkeys + let neocomplete = neocomplete#get_current_neocomplete() + + let cur_text = matchstr(getline('.'), '^.*\%'.col('.').'c') + if neocomplete.indent_text == matchstr(getline('.'), '\S.*$') + return + endif + + for word in filter(map(split(&l:indentkeys, ','), + \ "v:val =~ '^<.*>$' ? matchstr(v:val, '^<\\zs.*\\ze>$') + \ : matchstr(v:val, ':\\|e\\|=\\zs.*')"), + \ "v:val != ''") + + if word ==# 'e' + let word = 'else' + endif + + let lastpos = len(cur_text)-len(word) + if lastpos >= 0 && strridx(cur_text, word) == lastpos + call neocomplete#helper#indent_current_line() + let neocomplete.indent_text = matchstr(getline('.'), '\S.*$') + break + endif + endfor +endfunction"}}} +function! s:is_delimiter() abort "{{{ + " Check delimiter pattern. + let is_delimiter = 0 + let cur_text = neocomplete#get_cur_text(1) + + for delimiter in ['/'] + if stridx(cur_text, delimiter, + \ len(cur_text) - len(delimiter)) >= 0 + let is_delimiter = 1 + break + endif + endfor + + return is_delimiter +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/helper.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/helper.vim new file mode 100644 index 0000000..2bf0fff --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/helper.vim @@ -0,0 +1,357 @@ +"============================================================================= +" FILE: helper.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#helper#get_cur_text(...) abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let is_skip_char = get(a:000, 0, 0) + let mode = mode() + if neocomplete.event ==# 'InsertEnter' + let mode = 'i' + endif + + let cur_text = + \ (mode ==# 'i' ? + \ (col('.')-1) : col('.')) >= len(getline('.')) ? + \ getline('.') : + \ matchstr(getline('.'), + \ '^.*\%' . (mode ==# 'i' && !is_skip_char ? + \ col('.') : col('.') - 1) + \ . '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 + + if neocomplete.event ==# 'InsertCharPre' + let complete_str .= v:char + endif + + let neocomplete.cur_text = cur_text . complete_str + + " Save cur_text. + return neocomplete.cur_text +endfunction"}}} + +function! neocomplete#helper#get_force_omni_complete_pos(cur_text) abort "{{{ + let filetype = neocomplete#get_context_filetype() + let omnifunc = &l:omnifunc + + if neocomplete#helper#check_invalid_omnifunc(omnifunc) + return -1 + endif + + let pattern = '' + + if has_key(g:neocomplete#force_omni_input_patterns, omnifunc) + let pattern = g:neocomplete#force_omni_input_patterns[omnifunc] + elseif filetype != '' && + \ get(g:neocomplete#force_omni_input_patterns, filetype, '') != '' + let pattern = g:neocomplete#force_omni_input_patterns[filetype] + endif + + if pattern == '' + return -1 + endif + + return match(a:cur_text, '\%(' . pattern . '\m\)$') +endfunction"}}} + +function! neocomplete#helper#is_enabled_source(source, filetype) abort "{{{ + let source = type(a:source) == type('') ? + \ get(neocomplete#variables#get_sources(), a:source, {}) + \ : a:source + + return !empty(source) && (empty(source.filetypes) || + \ neocomplete#helper#check_filetype(source.filetypes)) + \ && (!get(source.disabled_filetypes, '_', 0) && + \ !neocomplete#helper#check_filetype(source.disabled_filetypes)) +endfunction"}}} + +function! neocomplete#helper#get_source_filetypes(filetype) abort "{{{ + return neocomplete#context_filetype#filetypes() +endfunction"}}} + +function! neocomplete#helper#complete_check() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + if g:neocomplete#enable_debug + echomsg split(reltimestr(reltime(neocomplete.start_time)))[0] + endif + let ret = + \ neocomplete#is_auto_complete() + \ && g:neocomplete#skip_auto_completion_time != '' + \ && split(reltimestr(reltime(neocomplete.start_time)))[0] > + \ g:neocomplete#skip_auto_completion_time + if ret + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.skipped = 1 + + call neocomplete#print_debug('Skipped.') + endif + + return ret +endfunction"}}} + +function! neocomplete#helper#get_syn_name(is_trans) abort "{{{ + return len(getline('.')) < 200 ? + \ synIDattr(synIDtrans(synID(line('.'), mode() ==# 'i' ? + \ col('.')-1 : col('.'), a:is_trans)), 'name') : '' +endfunction"}}} + +function! neocomplete#helper#match_word(cur_text, ...) abort "{{{ + let pattern = a:0 >= 1 ? a:1 : neocomplete#get_keyword_pattern_end() + + " Check wildcard. + let complete_pos = match(a:cur_text, pattern) + + let complete_str = (complete_pos >=0) ? + \ a:cur_text[complete_pos :] : '' + + return [complete_pos, complete_str] +endfunction"}}} + +function! neocomplete#helper#filetype_complete(arglead, cmdline, cursorpos) abort "{{{ + " 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! neocomplete#helper#unite_patterns(pattern_var, filetype) abort "{{{ + let keyword_patterns = [] + + lua << EOF +do + local patterns = vim.eval('keyword_patterns') + local filetypes = vim.eval("split(a:filetype, '\\.')") + local pattern_var = vim.eval('a:pattern_var') + + local dup_check = {} + for i = 0, #filetypes-1 do + local ft = filetypes[i] + + -- Composite filetype. + if pattern_var[ft] ~= nil and dup_check[ft] == nil then + dup_check[ft] = 1 + patterns:add(pattern_var[ft]) + end + end + + if #patterns == 0 then + local default = pattern_var['_'] + if default == nil then + default = pattern_var['default'] + end + if default ~= nil and default ~= '' then + patterns:add(default) + end + end +end +EOF + + return join(keyword_patterns, '\m\|') +endfunction"}}} + +function! neocomplete#helper#check_filetype(dictionary) abort "{{{ + return !empty(filter(neocomplete#context_filetype#filetypes(), + \ 'get(a:dictionary, v:val, 0)')) +endfunction"}}} + +function! neocomplete#helper#get_sources_list(...) abort "{{{ + let filetype = neocomplete#get_context_filetype() + + let source_names = exists('b:neocomplete_sources') ? + \ b:neocomplete_sources : + \ get(a:000, 0, + \ get(g:neocomplete#sources, filetype, + \ get(g:neocomplete#sources, '_', ['_']))) + call neocomplete#init#_sources(source_names) + + let all_sources = neocomplete#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 neocomplete#print_warning(printf( + \ 'Invalid source name "%s" is given.', source_name)) + continue + endif + + let sources[source_name] = all_sources[source_name] + endfor + + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.sources = filter(sources, " + \ empty(v:val.filetypes) || + \ neocomplete#helper#check_filetype(v:val.filetypes)") + let neocomplete.sources_filetype = neocomplete.context_filetype + + return neocomplete.sources +endfunction"}}} + +function! neocomplete#helper#clear_result() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + + let neocomplete.complete_str = '' + let neocomplete.candidates = [] + let neocomplete.complete_sources = [] + let neocomplete.complete_pos = -1 + + " Restore completeopt. + if neocomplete.completeopt !=# &completeopt + " Restore completeopt. + let &completeopt = neocomplete.completeopt + endif +endfunction"}}} + +function! neocomplete#helper#call_hook(sources, hook_name, context) abort "{{{ + for source in neocomplete#util#convert2list(a:sources) + try + if has_key(source.hooks, a:hook_name) + call call(source.hooks[a:hook_name], + \ [extend(source.neocomplete__context, a:context)], + \ source.hooks) + endif + catch + call neocomplete#print_error(v:throwpoint) + call neocomplete#print_error(v:exception) + call neocomplete#print_error( + \ 'Error occurred in calling hook "' . a:hook_name . '"!') + call neocomplete#print_error( + \ 'Source name is ' . source.name) + endtry + endfor +endfunction"}}} + +function! neocomplete#helper#call_filters(filters, source, context) abort "{{{ + let context = extend(a:source.neocomplete__context, a:context) + for filter in a:filters + try + let context.candidates = call(filter.filter, [context], filter) + catch + call neocomplete#print_error(v:throwpoint) + call neocomplete#print_error(v:exception) + call neocomplete#print_error( + \ 'Error occurred in calling filter ' + \ . filter.name . '!') + call neocomplete#print_error( + \ 'Source name is ' . a:source.name) + endtry + endfor + + return context.candidates +endfunction"}}} + +function! neocomplete#helper#sort_human(candidates) abort "{{{ + " Use lua interface. + lua << EOF +do + local candidates = vim.eval('a:candidates') + local t = {} + for i = 1, #candidates do + t[i] = candidates[i-1] + end + table.sort(t, function(a, b) return a.word < b.word end) + for i = 0, #candidates-1 do + candidates[i] = t[i+1] + end +end +EOF + return a:candidates +endfunction"}}} + +function! neocomplete#helper#check_invalid_omnifunc(omnifunc) abort "{{{ + return a:omnifunc == '' || (a:omnifunc !~ '#' && !exists('*' . a:omnifunc)) +endfunction"}}} + +function! neocomplete#helper#indent_current_line() abort "{{{ + let pos = getpos('.') + let len = len(getline('.')) + let equalprg = &l:equalprg + try + setlocal equalprg= + silent normal! == + finally + let &l:equalprg = equalprg + let pos[2] += len(getline('.')) - len + call setpos('.', pos) + endtry +endfunction"}}} + +function! neocomplete#helper#complete_configure() abort "{{{ + set completeopt-=menu + set completeopt-=longest + set completeopt+=menuone + + " Set options. + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.completeopt = &completeopt + + if neocomplete#util#is_complete_select() + \ && &completeopt !~# 'noinsert\|noselect' + if g:neocomplete#enable_auto_select + set completeopt-=noselect + set completeopt+=noinsert + else + set completeopt-=noinsert + set completeopt+=noselect + endif + endif +endfunction"}}} + +function! neocomplete#helper#clean(directory) abort "{{{ + let directory = neocomplete#get_data_directory() .'/'.a:directory + for file in split(glob(directory . '/*'), '\n') + let orig = substitute(substitute(fnamemodify(file, ':t'), + \ '=-', ':', 'g'), '=+', '/', 'g') + if !filereadable(orig) + call delete(file) + endif + endfor +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/init.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/init.vim new file mode 100644 index 0000000..dd15fcc --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/init.vim @@ -0,0 +1,659 @@ +"============================================================================= +" FILE: init.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#init#enable() abort "{{{ + if neocomplete#is_enabled() + return + endif + + if !(has('lua') && (v:version > 703 || v:version == 703 && has('patch885'))) + echomsg 'neocomplete does not work with this version of Vim.' + echomsg 'neocomplete requires Vim 7.3.885 or later with Lua support ("+lua").' + return + endif + + if !exists('b:neocomplete') + call neocomplete#init#_current_neocomplete() + endif + call neocomplete#init#_autocmds() + call neocomplete#init#_others() + + call neocomplete#init#_sources(get(g:neocomplete#sources, + \ neocomplete#get_context_filetype(), ['_'])) + + let s:is_enabled = 1 + + doautocmd neocomplete InsertEnter +endfunction"}}} + +function! neocomplete#init#disable() abort "{{{ + if !neocomplete#is_enabled() + return + endif + + let s:is_enabled = 0 + + augroup neocomplete + autocmd! + augroup END + + silent! delcommand NeoCompleteDisable + + call neocomplete#helper#call_hook(filter(values( + \ neocomplete#variables#get_sources()), 'v:val.loaded'), + \ 'on_final', {}) +endfunction"}}} + +function! neocomplete#init#is_enabled() abort "{{{ + return s:is_enabled +endfunction"}}} + +function! neocomplete#init#_autocmds() abort "{{{ + augroup neocomplete + autocmd! + autocmd InsertEnter * + \ call neocomplete#handler#_on_insert_enter() + autocmd InsertLeave * + \ call neocomplete#handler#_on_insert_leave() + autocmd CursorMovedI * + \ call neocomplete#handler#_on_moved_i() + autocmd InsertCharPre * + \ call neocomplete#handler#_on_insert_char_pre() + autocmd TextChangedI * + \ call neocomplete#handler#_on_text_changed() + autocmd CompleteDone * + \ call neocomplete#handler#_on_complete_done() + augroup END + + let event = neocomplete#util#is_text_changed() ? + \ 'TextChangedI' : 'CursorMovedI' + execute 'autocmd neocomplete' event '*' + \ 'call neocomplete#handler#_do_auto_complete("'.event.'")' + + autocmd neocomplete InsertEnter * + \ call neocomplete#handler#_do_auto_complete('InsertEnter') +endfunction"}}} + +function! neocomplete#init#_others() abort "{{{ + call neocomplete#init#_variables() + + call neocomplete#commands#_initialize() + + " For auto complete keymappings. + call neocomplete#mappings#define_default_mappings() + + " Detect set paste. + if &paste + redir => output + 99verbose set paste + redir END + call neocomplete#print_error(output) + call neocomplete#print_error( + \ 'Detected set paste! Disabled neocomplete.') + endif + + " Detect poor color + if &t_Co != '' && &t_Co < 8 + call neocomplete#print_error( + \ 'Your terminal color is very limited. Disabled neocomplete.') + endif + + command! -nargs=0 -bar NeoCompleteDisable + \ call neocomplete#init#disable() +endfunction"}}} + +function! neocomplete#init#_variables() abort "{{{ + " Initialize keyword patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'_', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#keyword_patterns', + \'filename', + \ neocomplete#util#is_windows() ? + \'\%(\a\+:/\)\?\%([/[:alnum:]()$+_~.{}\x80-\xff-]\|[^[:print:]]\|\\.\)\+' : + \'\%([/\[\][:alnum:]()$+_~.{}-]\|[^[:print:]]\|\\.\)\+') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'lisp,scheme,clojure,int-gosh,int-clisp,int-clj', + \'[[:alpha:]!$%&*+/:<=>?@\^_~\-][[:alnum:]!$%&*./:<=>?@\^_~\-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'ruby,int-irb', + \'^=\%(b\%[egin]\|e\%[nd]\)\|\%(@@\|[$@]\)\h\w*\|\h\w*\%(::\w*\)*[!?]\?') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'php,int-php', + \'\)\?'. + \'\|\$\h\w*\|\h\w*\%(\%(\\\|::\)\w*\)*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'perl,int-perlsh', + \'<\h\w*>\?\|[$@%&*]\h\w*\|\h\w*\%(::\w*\)*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'perl6,int-perl6', + \'<\h\w*>\?\|[$@%&][!.*?]\?\h[[:alnum:]_-]*'. + \'\|\h[[:alnum:]_-]*\%(::[[:alnum:]_-]*\)*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'pir', + \'[$@%.=]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'pasm', + \'[=]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'vim,help', + \'-\h[[:alnum:]-]*=\?\|\c\[:\%(\h\w*:\]\)\?\|&\h[[:alnum:]_:]*\|'. + \'\%(\h\w*\)\?\|([^)]*)\?'. + \'\|<\h[[:alnum:]_-]*>\?\|\h[[:alnum:]_:#]*[!(]\?\|$\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'tex', + \'\\\a{\a\{1,2}}\|\\[[:alpha:]@][[:alnum:]@]*'. + \'\%({\%([[:alnum:]:_]\+\*\?}\?\)\?\)\?\|\a[[:alnum:]:_]*\*\?') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'sh,zsh,int-zsh,int-bash,int-sh', + \'[[:alpha:]_.-][[:alnum:]_.-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'vimshell', + \'\$\$\?\w*\|[[:alpha:]_.\\/~-][[:alnum:]_.\\/~-]*\|\d\+\%(\.\d\+\)\+') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'ps1,int-powershell', + \'\[\h\%([[:alnum:]_.]*\]::\)\?\|[$%@.]\?[[:alpha:]_.:-][[:alnum:]_.:-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'c', + \'^\s*#\s*\h\w*\|\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'cpp', + \'^\s*#\s*\h\w*\|\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'objc', + \'^\s*#\s*\h\w*\|\h\w*\|@\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'objcpp', + \'^\s*#\s*\h\w*\|\h\w*\|@\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'objj', + \'\h\w*\|@\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'d', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'python,int-python,int-ipython', + \'[@]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'cs', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'java', + \'[@]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'javascript,actionscript,int-js,int-kjs,int-rhino', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'coffee,int-coffee', + \'[@]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'awk', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'haskell,int-ghci', + \'\%(\u\w*\.\)\+[[:alnum:]_'']*\|[[:alpha:]_''][[:alnum:]_'']*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'ml,ocaml,int-ocaml,int-sml,int-smlsharp', + \'[''`#.]\?\h[[:alnum:]_'']*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'erlang,int-erl', + \'^\s*-\h\w*\|\%(\h\w*:\)*\h\w*\|\h[[:alnum:]_@]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'html,xhtml,xml,markdown,mkd,eruby', + \'\)\?\|&\h\%(\w*;\)\?'. + \'\|\h[[:alnum:]_-]*="\%([^"]*"\?\)\?\|\h[[:alnum:]_:-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'css,stylus,scss,less', + \'[@#.]\?[[:alpha:]_:-][[:alnum:]_:-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'tags', + \'^[^!][^/[:blank:]]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'pic', + \'^\s*#\h\w*\|\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'arm', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'asmh8300', + \'[[:alpha:]_.][[:alnum:]_.]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'masm', + \'\.\h\w*\|[[:alpha:]_@?$][[:alnum:]_@?$]*\|\h\w*:\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'nasm', + \'^\s*\[\h\w*\|[%.]\?\h\w*\|\%(\.\.@\?\|%[%$!]\)\%(\h\w*\)\?\|\h\w*:\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'asm', + \'[%$.]\?\h\w*\%(\$\h\w*\)\?') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'gas', + \'[$.]\?\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'gdb,int-gdb', + \'$\h\w*\|[[:alnum:]:._-]\+') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'make', + \'[[:alpha:]_.-][[:alnum:]_.-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'scala,int-scala', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'int-termtter', + \'\h[[:alnum:]_/-]*\|\$\a\+\|#\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'int-earthquake', + \'[:#$]\h\w*\|\h[[:alnum:]_/-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'dosbatch,int-cmdproxy', + \'\$\w+\|[[:alpha:]_./-][[:alnum:]_.-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'vb', + \'\h\w*\|#\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'lua', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \ 'zimbu', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'konoha', + \'[*$@%]\h\w*\|\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'cobol', + \'\a[[:alnum:]-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'coq', + \'\h[[:alnum:]_'']*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'tcl', + \'[.-]\h\w*\|\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'nyaos,int-nyaos', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'go', + \'\h\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#keyword_patterns', + \'toml', + \'\h[[:alnum:]_.-]*') + "}}} + + " Initialize delimiter patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'vim,help', ['#']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'erlang,lisp,int-clisp', [':']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'lisp,int-clisp', ['/', ':']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'clojure,int-clj', ['/', '.']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'perl,cpp', ['::']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'php', ['\', '::']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'java,d,javascript,actionscript,'. + \ 'ruby,eruby,haskell,int-ghci,coffee,zimbu,konoha', + \ ['.']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'lua', ['.', ':']) + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#delimiter_patterns', + \ 'perl6', ['.', '::']) + "}}} + + " Initialize text mode filetypes. "{{{ + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#text_mode_filetypes', + \ join(['hybrid', 'text', 'help', 'tex', 'gitcommit', 'gitrebase', + \ 'vcs-commit', 'markdown', 'mkd', 'textile', 'creole', + \ 'org', 'rdoc', 'mediawiki', 'rst', 'asciidoc', 'pod', + \ 'gita-commit', 'J6uil_say', + \ ], ','), 1) + "}}} + + " Initialize tags filter patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#tags_filter_patterns', 'c,cpp', + \'v:val.word !~ ''^[~_]''') + "}}} + + " Initialize force omni completion patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#force_omni_input_patterns', 'objc', + \'\h\w\+\|[^.[:digit:] *\t]\%(\.\|->\)') + "}}} + + " Must g:neocomplete#auto_completion_start_length > 1. + if g:neocomplete#auto_completion_start_length < 1 + let g:neocomplete#auto_completion_start_length = 1 + endif + + " Must g:neocomplete#min_keyword_length > 1. + if g:neocomplete#min_keyword_length < 1 + let g:neocomplete#min_keyword_length = 1 + endif +endfunction"}}} + +function! neocomplete#init#_current_neocomplete() abort "{{{ + let b:neocomplete = { + \ 'context' : { + \ 'input' : '', + \ 'complete_pos' : -1, + \ 'complete_str' : '', + \ 'candidates' : [], + \ }, + \ 'lock' : 0, + \ 'skip_next_complete' : 0, + \ 'filetype' : '', + \ 'context_filetype' : '', + \ 'context_filetypes' : [], + \ 'completion_length' : -1, + \ 'foldinfo' : [], + \ 'skipped' : 0, + \ 'event' : '', + \ 'cur_text' : '', + \ 'old_cur_text' : '', + \ 'old_linenr' : line('.'), + \ 'old_complete_pos' : -1, + \ 'old_char' : '', + \ 'complete_str' : '', + \ 'complete_pos' : -1, + \ 'candidates' : [], + \ 'complete_sources' : [], + \ 'manual_sources' : [], + \ 'start_time' : reltime(), + \ 'linenr' : 0, + \ 'completeopt' : &completeopt, + \ 'sources' : [], + \ 'sources_filetype' : '', + \ 'within_comment' : 0, + \ 'is_auto_complete' : 0, + \ 'indent_text' : '', + \ 'detected_foldmethod' : 0, + \ 'default_matchers' : neocomplete#init#_filters( + \ (g:neocomplete#enable_fuzzy_completion ? + \ ['matcher_fuzzy'] : ['matcher_head']) + \ + ['matcher_length']), + \} +endfunction"}}} + +function! neocomplete#init#_sources(names) abort "{{{ + 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 = neocomplete#util#split_rtp(s:runtimepath_save) + let runtimepath = neocomplete#util#join_rtp( + \ filter(neocomplete#util#split_rtp(), + \ 'index(runtimepath_save, v:val) < 0')) + let sources = neocomplete#variables#get_sources() + + for name in filter(copy(a:names), '!has_key(sources, v:val)') + " Search autoload. + for source_name in map(filter(split(globpath(runtimepath, + \ 'autoload/neocomplete/sources/*.vim'), '\n'), + \ "index(g:neocomplete#ignore_source_files, + \ fnamemodify(v:val, ':t')) < 0"), + \ "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 = neocomplete#sources#{source_name}#define() + if empty(source) + " Ignore. + continue + endif + + call neocomplete#define_source(source) + endfor + + if name == '_' + let s:loaded_all_sources = 1 + let s:runtimepath_save = &runtimepath + endif + endfor +endfunction"}}} + +function! neocomplete#init#_source(source) abort "{{{ + let default = { + \ 'is_volatile' : 0, + \ 'max_candidates' : 0, + \ 'filetypes' : {}, + \ 'disabled' : 0, + \ 'disabled_filetypes' : {}, + \ 'hooks' : {}, + \ 'matchers' : [], + \ 'sorters' : ['sorter_rank'], + \ 'converters' : [ + \ 'converter_remove_overlap', + \ 'converter_delimiter', + \ 'converter_abbr', + \ ], + \ 'keyword_patterns' : g:neocomplete#keyword_patterns, + \ 'min_pattern_length' : g:neocomplete#auto_completion_start_length, + \ 'input_pattern' : '', + \ 'neocomplete__context' : neocomplete#init#_context({}), + \ } + + let source = extend(copy(default), a:source) + + " Overwritten by user custom. + let custom = neocomplete#custom#get().sources + let source = extend(source, get(custom, source.name, + \ get(custom, '_', {}))) + + let source.loaded = 0 + " Source kind convertion. + if !has_key(source, 'kind') + let source.kind = 'manual' + elseif source.kind ==# 'plugin' + let source.kind = 'keyword' + elseif source.kind ==# 'ftplugin' || source.kind ==# 'complfunc' + " For compatibility. + 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, 'mark') + " Set default mark. + let source.mark = '[' . source.name . ']' + endif + + if !has_key(source.keyword_patterns, '_') + " Set default keyword pattern. + let source.keyword_patterns['_'] = + \ get(g:neocomplete#keyword_patterns, '_', '\h\w*') + endif + + let source.neocomplete__matchers = neocomplete#init#_filters( + \ neocomplete#util#convert2list(source.matchers)) + let source.neocomplete__sorters = neocomplete#init#_filters( + \ neocomplete#util#convert2list(source.sorters)) + let source.neocomplete__converters = neocomplete#init#_filters( + \ neocomplete#util#convert2list(source.converters)) + + let source.neocomplete__context.source_name = source.name + + return source +endfunction"}}} + +function! neocomplete#init#_filters(names) abort "{{{ + let _ = [] + let filters = neocomplete#variables#get_filters() + + for name in a:names + if !has_key(filters, name) + " Search autoload. + for filter_name in map(split(globpath(&runtimepath, + \ 'autoload/neocomplete/filters/'. + \ substitute(name, + \'^\%(matcher\|sorter\|converter\)_[^/_-]\+\zs[/_-].*$', '', '') + \ .'*.vim'), '\n'), "fnamemodify(v:val, ':t:r')") + let filter = neocomplete#filters#{filter_name}#define() + if empty(filter) + " Ignore. + continue + endif + + call neocomplete#define_filter(filter) + endfor + + if !has_key(filters, name) + " Not found. + call neocomplete#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! neocomplete#init#_filter(filter) abort "{{{ + 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! neocomplete#init#_context(context) abort "{{{ + let filetype = neocomplete#get_context_filetype() + return extend(a:context, { + \ 'input' : '', + \ 'prev_complete_pos' : -1, + \ 'prev_candidates' : [], + \ 'prev_line' : '', + \ 'complete_pos' : -1, + \ 'complete_str' : '', + \ 'candidates' : [], + \ 'filetype' : filetype, + \ 'filetypes' : neocomplete#context_filetype#filetypes(), + \ }) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/mappings.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/mappings.vim new file mode 100644 index 0000000..4c8bcb7 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/mappings.vim @@ -0,0 +1,269 @@ +"============================================================================= +" FILE: mappings.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#mappings#define_default_mappings() abort "{{{ + inoremap (neocomplete_start_unite_complete) + \ unite#sources#neocomplete#start_complete() + inoremap (neocomplete_start_unite_quick_match) + \ unite#sources#neocomplete#start_quick_match() + if neocomplete#util#is_complete_select() + inoremap (neocomplete_start_omni_complete) + \ + else + inoremap (neocomplete_start_omni_complete) + \ + endif + if neocomplete#util#is_complete_select() + inoremap (neocomplete_start_auto_complete) + \ =neocomplete#mappings#auto_complete() + inoremap (neocomplete_start_manual_complete) + \ =neocomplete#mappings#manual_complete() + else + inoremap (neocomplete_start_auto_complete) + \ =neocomplete#mappings#auto_complete()= + \neocomplete#mappings#popup_post() + inoremap (neocomplete_start_manual_complete) + \ =neocomplete#mappings#manual_complete()= + \neocomplete#mappings#popup_post() + endif + + if !has('patch-7.4.653') + " To prevent Vim's complete() bug. + if mapcheck('', 'i') ==# '' + inoremap neocomplete#smart_close_popup()."\" + endif + if mapcheck('', 'i') ==# '' + inoremap neocomplete#smart_close_popup()."\" + endif + endif + + inoremap (neocomplete_auto_refresh) + \ =neocomplete#mappings#refresh() +endfunction"}}} + +function! neocomplete#mappings#auto_complete() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let cur_text = neocomplete#get_cur_text(1) + let complete_pos = + \ neocomplete#complete#_get_complete_pos( + \ neocomplete.complete_sources) + let base = cur_text[complete_pos :] + + let neocomplete.candidates = neocomplete#complete#_get_words( + \ neocomplete.complete_sources, complete_pos, base) + let neocomplete.complete_str = base + let neocomplete.refresh = 0 + if empty(neocomplete.candidates) + return '' + endif + + " Start auto complete. + call complete(complete_pos+1, neocomplete.candidates) + return '' +endfunction"}}} + +function! neocomplete#mappings#manual_complete() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let cur_text = neocomplete#get_cur_text(1) + let complete_sources = neocomplete#complete#_get_results( + \ cur_text, neocomplete.manual_sources) + let complete_pos = + \ neocomplete#complete#_get_complete_pos( + \ complete_sources) + let base = cur_text[complete_pos :] + + let neocomplete.complete_pos = complete_pos + let neocomplete.candidates = neocomplete#complete#_get_words( + \ complete_sources, complete_pos, base) + let neocomplete.complete_str = base + if empty(neocomplete.candidates) + return '' + endif + + " Start auto complete. + call complete(complete_pos+1, neocomplete.candidates) + return '' +endfunction"}}} + +function! neocomplete#mappings#smart_close_popup() abort "{{{ + return neocomplete#mappings#cancel_popup() +endfunction +"}}} +function! neocomplete#mappings#close_popup() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.complete_str = '' + let neocomplete.old_cur_text = neocomplete#get_cur_text(1) + let neocomplete.skip_next_complete = 1 + + return pumvisible() ? "\" : '' +endfunction +"}}} +function! neocomplete#mappings#cancel_popup() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.complete_str = '' + let neocomplete.old_cur_text = neocomplete#get_cur_text(1) + let neocomplete.old_complete_pos = col('.') + if mode() !=# 'i' + let neocomplete.old_complete_pos += 1 + endif + let neocomplete.old_linenr = line('.') + let neocomplete.skip_next_complete = 1 + + return pumvisible() ? "\" : '' +endfunction +"}}} + +function! neocomplete#mappings#popup_post() abort "{{{ + return !pumvisible() ? "" : + \ g:neocomplete#enable_auto_select ? "\\" : "\" +endfunction"}}} + +function! neocomplete#mappings#undo_completion() abort "{{{ + if !neocomplete#is_enabled() + return '' + endif + + let neocomplete = neocomplete#get_current_neocomplete() + + " Get cursor word. + let complete_str = + \ (!exists('v:completed_item') || empty(v:completed_item)) ? + \ neocomplete#helper#match_word(neocomplete#get_cur_text(1))[1] : + \ v:completed_item.word + + let old_keyword_str = neocomplete.complete_str + let neocomplete.complete_str = complete_str + + return (!pumvisible() ? '' : + \ complete_str ==# old_keyword_str ? "\" : "\") + \. repeat("\", strchars(complete_str)) . old_keyword_str +endfunction"}}} + +function! neocomplete#mappings#complete_common_string() abort "{{{ + if !neocomplete#is_enabled() + return '' + endif + + " Get cursor word. + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.event = 'mapping' + let complete_str = + \ neocomplete#helper#match_word(neocomplete#get_cur_text(1))[1] + + if complete_str == '' + return '' + endif + + " Save options. + let ignorecase_save = &ignorecase + + try + if neocomplete#is_text_mode() + let &ignorecase = 1 + elseif g:neocomplete#enable_smart_case + \ || g:neocomplete#enable_camel_case + let &ignorecase = complete_str !~ '\u' + else + let &ignorecase = g:neocomplete#enable_ignore_case + endif + + let candidates = neocomplete#filters#matcher_head#define().filter( + \ { 'candidates' : copy(neocomplete.candidates), + \ 'complete_str' : complete_str}) + + if empty(candidates) + return '' + endif + + let common_str = candidates[0].word + for keyword in candidates[1:] + while !neocomplete#head_match(keyword.word, common_str) + let common_str = common_str[: -2] + endwhile + endfor + finally + let &ignorecase = ignorecase_save + endtry + + if common_str == '' + \ || complete_str ==? common_str + return '' + endif + + return (pumvisible() ? "\" : '') + \ . repeat("\", strchars(complete_str)) . common_str +endfunction"}}} + +function! neocomplete#mappings#fallback(i) abort "{{{ + let mapping = g:neocomplete#fallback_mappings[a:i] + return (pumvisible() || (mapping ==? "\\" + \ && &l:omnifunc == '')) ? "" : + \ (mapping . (neocomplete#util#is_complete_select() ? + \ "" : "\")) +endfunction"}}} + +function! neocomplete#mappings#refresh() abort "{{{ + let neocomplete = neocomplete#get_current_neocomplete() + let neocomplete.refresh = 1 + return pumvisible() ? "\" : '' +endfunction"}}} + +" Manual complete wrapper. +function! neocomplete#mappings#start_manual_complete(...) abort "{{{ + if !neocomplete#is_enabled() + return '' + endif + + if neocomplete#helper#get_force_omni_complete_pos( + \ neocomplete#get_cur_text(1)) >= 0 + return "\\" + endif + + " Set context filetype. + call neocomplete#context_filetype#set() + + let neocomplete = neocomplete#get_current_neocomplete() + + let sources = get(a:000, 0, + \ keys(neocomplete#available_sources())) + let neocomplete.manual_sources = neocomplete#helper#get_sources_list( + \ neocomplete#util#convert2list(sources)) + let neocomplete.sources_filetype = '' + + call neocomplete#helper#complete_configure() + + " Start complete. + return "\=neocomplete#mappings#manual_complete()\" + \ . (neocomplete#util#is_complete_select() ? + \ "" : "\=neocomplete#mappings#popup_post()\") +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/buffer.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/buffer.vim new file mode 100644 index 0000000..d685206 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/buffer.vim @@ -0,0 +1,400 @@ +"============================================================================= +" FILE: buffer.vim +" AUTHOR: Shougo Matsushita +" 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. "{{{ +let g:neocomplete#sources#buffer#cache_limit_size = + \ get(g:, 'neocomplete#sources#buffer#cache_limit_size', 500000) +let g:neocomplete#sources#buffer#disabled_pattern = + \ get(g:, 'neocomplete#sources#buffer#disabled_pattern', '') +let g:neocomplete#sources#buffer#max_keyword_width = + \ get(g:, 'neocomplete#sources#buffer#max_keyword_width', 80) +"}}} + +" Important variables. +if !exists('s:buffer_sources') + let s:buffer_sources = {} + let s:async_dictionary_list = {} +endif + +let s:source = { + \ 'name' : 'buffer', + \ 'kind' : 'manual', + \ 'mark' : '[B]', + \ 'rank' : 5, + \ 'min_pattern_length' : + \ g:neocomplete#auto_completion_start_length, + \ 'hooks' : {}, + \ 'is_volatile' : 1, + \} + +function! s:source.hooks.on_init(context) abort "{{{ + let s:buffer_sources = {} + + augroup neocomplete "{{{ + autocmd BufEnter,BufRead,BufWinEnter,BufWritePost * + \ call s:check_source() + autocmd InsertEnter,InsertLeave * + \ call neocomplete#sources#buffer#make_cache_current_line() + autocmd VimLeavePre * call s:clean() + augroup END"}}} + + " Create cache directory. + call neocomplete#cache#make_directory('buffer_cache') + call neocomplete#cache#make_directory('buffer_temp') + + " Initialize script variables. "{{{ + let s:buffer_sources = {} + let s:async_dictionary_list = {} + "}}} + + call s:make_cache_buffer(bufnr('%')) + call s:check_source() +endfunction +"}}} + +function! s:source.hooks.on_final(context) abort "{{{ + silent! delcommand NeoCompleteBufferMakeCache + + let s:buffer_sources = {} +endfunction"}}} + +function! s:source.hooks.on_post_filter(context) abort "{{{ + " Filters too long word. + call filter(a:context.candidates, + \ 'len(v:val.word) < g:neocomplete#sources#buffer#max_keyword_width') +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + call s:check_async_cache(a:context) + + let keyword_list = [] + for source in s:get_sources_list(a:context) + let keyword_list += source.words + endfor + return keyword_list +endfunction"}}} + +function! neocomplete#sources#buffer#define() abort "{{{ + return s:source +endfunction"}}} + +function! neocomplete#sources#buffer#get_frequencies() abort "{{{ + return get(get(s:buffer_sources, bufnr('%'), {}), 'frequencies', {}) +endfunction"}}} + +function! neocomplete#sources#buffer#make_cache_current_line() abort "{{{ + if neocomplete#is_locked() + return + endif + + " let start = reltime() + call s:make_cache_current_buffer( + \ max([1, line('.') - winline()]), + \ min([line('$'), line('.') + winheight(0) - winline()])) + " echomsg reltimestr(reltime(start)) +endfunction"}}} + +function! s:should_create_cache(bufnr) " {{{ + let filepath = fnamemodify(bufname(a:bufnr), ':p') + return getfsize(filepath) < g:neocomplete#sources#buffer#cache_limit_size + \ && getbufvar(a:bufnr, '&modifiable') + \ && !getwinvar(bufwinnr(a:bufnr), '&previewwindow') + \ && (g:neocomplete#sources#buffer#disabled_pattern == '' + \ || filepath !~# g:neocomplete#sources#buffer#disabled_pattern) +endfunction"}}} + +function! s:get_sources_list(context) abort "{{{ + let filetypes_dict = {} + for filetype in a:context.filetypes + let filetypes_dict[filetype] = 1 + endfor + + return values(filter(copy(s:buffer_sources), + \ "has_key(filetypes_dict, v:val.filetype) + \ || has_key(filetypes_dict, '_') + \ || bufnr('%') == v:key + \ || (bufname('%') ==# '[Command Line]' && bufwinnr('#') == v:key)")) +endfunction"}}} + +function! s:initialize_source(srcname) abort "{{{ + 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 keyword_pattern = neocomplete#get_keyword_pattern(ft, s:source.name) + + let s:buffer_sources[a:srcname] = { + \ 'words' : [], + \ 'frequencies' : {}, + \ 'name' : filename, 'filetype' : ft, + \ 'keyword_pattern' : keyword_pattern, + \ 'cached_time' : 0, + \ 'path' : path, + \ 'cache_name' : neocomplete#cache#encode_name('buffer_cache', path), + \} +endfunction"}}} + +function! s:make_cache_file(srcname) abort "{{{ + " Initialize source. + if !has_key(s:buffer_sources, a:srcname) + call s:initialize_source(a:srcname) + endif + + let source = s:buffer_sources[a:srcname] + + if !filereadable(source.path) + \ || getbufvar(a:srcname, '&modified') + \ || getbufvar(a:srcname, '&buftype') =~ 'nofile\|acwrite' + call s:make_cache_buffer(a:srcname) + return + endif + + call neocomplete#print_debug('make_cache_buffer: ' . source.path) + + let source.cache_name = + \ neocomplete#cache#async_load_from_file( + \ 'buffer_cache', source.path, + \ source.keyword_pattern, 'B') + let source.cached_time = localtime() + let source.filetype = getbufvar(a:srcname, '&filetype') + let s:async_dictionary_list[source.path] = [{ + \ 'filename' : source.path, + \ 'cachename' : source.cache_name, + \ }] +endfunction"}}} + +function! s:make_cache_buffer(srcname) abort "{{{ + if !s:should_create_cache(a:srcname) + return + endif + + call neocomplete#print_debug('make_cache_buffer: ' . a:srcname) + + if !s:exists_current_source() + call s:initialize_source(a:srcname) + + if a:srcname ==# bufnr('%') + " Force sync cache + call s:make_cache_current_buffer(1, 1000) + return + endif + endif + + let source = s:buffer_sources[a:srcname] + let temp = neocomplete#cache#getfilename( + \ 'buffer_temp', getpid() . '_' . a:srcname) + let lines = getbufline(a:srcname, 1, '$') + call writefile(lines, temp) + + " Create temporary file + let source.cache_name = + \ neocomplete#cache#async_load_from_file( + \ 'buffer_cache', temp, + \ source.keyword_pattern, 'B') + let source.cached_time = localtime() + let source.filetype = getbufvar(a:srcname, '&filetype') + if source.filetype == '' + let source.filetype = 'nothing' + endif + let s:async_dictionary_list[source.path] = [{ + \ 'filename' : temp, + \ 'cachename' : source.cache_name, + \ }] +endfunction"}}} + +function! s:check_changed_buffer(bufnr) abort "{{{ + let source = s:buffer_sources[a:bufnr] + + let ft = getbufvar(a:bufnr, '&filetype') + if ft == '' + let ft = 'nothing' + endif + + let filename = fnamemodify(bufname(a:bufnr), ':t') + if filename == '' + let filename = '[No Name]' + endif + + return source.name != filename || source.filetype != ft +endfunction"}}} + +function! s:check_source() abort "{{{ + " Check new buffer. + call map(filter(range(1, bufnr('$')), " + \ (v:val != bufnr('%') || neocomplete#has_vimproc()) + \ && (!has_key(s:buffer_sources, v:val) && buflisted(v:val) + \ || (has_key(s:buffer_sources, v:val) && + \ s:buffer_sources[v:val].cached_time + \ < getftime(s:buffer_sources[v:val].path))) + \ && (!neocomplete#is_locked(v:val) || + \ g:neocomplete#disable_auto_complete) + \ && s:should_create_cache(v:val) + \ "), 's:make_cache_file(v:val)') + + " Remove unlisted buffers. + call filter(s:buffer_sources, + \ "v:key == bufnr('%') || buflisted(str2nr(v:key))") +endfunction"}}} + +function! s:exists_current_source() abort "{{{ + return has_key(s:buffer_sources, bufnr('%')) && + \ !s:check_changed_buffer(bufnr('%')) +endfunction"}}} + +function! s:make_cache_current_buffer(start, end) abort "{{{ + let srcname = bufnr('%') + + " Make cache from current buffer. + if !s:should_create_cache(srcname) + return + endif + + if !s:exists_current_source() + call s:initialize_source(srcname) + endif + + let source = s:buffer_sources[srcname] + let keyword_pattern = source.keyword_pattern + if keyword_pattern == '' + return + endif + + let words = [] + + lua << EOF +do + local words = vim.eval('words') + local dup = {} + local min_length = vim.eval('g:neocomplete#min_keyword_length') + for linenr = vim.eval('a:start'), vim.eval('a:end') do + local match = 0 + while 1 do + local match_str = vim.eval('matchstr(getline('..linenr.. + '), keyword_pattern, ' .. match .. ')') + if match_str == '' then + break + end + if dup[match_str] == nil + and string.len(match_str) >= min_length then + dup[match_str] = 1 + words:add(match_str) + end + + -- Next match. + match = vim.eval('matchend(getline(' .. linenr .. + '), keyword_pattern, ' .. match .. ')') + end + end +end +EOF + + let source.words = neocomplete#util#uniq(source.words + words) +endfunction"}}} + +function! s:check_async_cache(context) abort "{{{ + for source in s:get_sources_list(a:context) + if !has_key(s:async_dictionary_list, source.path) + continue + endif + + " Load from cache. + let [loaded, file_cache] = neocomplete#cache#get_cache_list( + \ 'buffer_cache', s:async_dictionary_list[source.path]) + if loaded + let source.words = file_cache + endif + + if empty(s:async_dictionary_list[source.path]) + call remove(s:async_dictionary_list, source.path) + endif + endfor +endfunction"}}} + +function! s:clean() abort "{{{ + " Remove temporary files + for file in glob(printf('%s/%d_*', + \ neocomplete#get_data_directory() . '/buffer_temp', + \ getpid()), 1, 1) + call delete(file) + + let cachefile = neocomplete#get_data_directory() . '/buffer_cache/' + \ . substitute(substitute(file, ':', '=-', 'g'), '[/\\]', '=+', 'g') + if filereadable(cachefile) + call delete(cachefile) + endif + endfor +endfunction"}}} + +" Command functions. "{{{ +function! neocomplete#sources#buffer#make_cache(name) abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + 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 + + call s:make_cache_file(number) +endfunction"}}} +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/dictionary.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/dictionary.vim new file mode 100644 index 0000000..1bcb93a --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/dictionary.vim @@ -0,0 +1,150 @@ +"============================================================================= +" FILE: dictionary.vim +" AUTHOR: Shougo Matsushita +" 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. "{{{ +let g:neocomplete#sources#dictionary#dictionaries = + \ get(g:, 'neocomplete#sources#dictionary#dictionaries', {}) +"}}} + +" Important variables. +if !exists('s:dictionary_cache') + let s:dictionary_cache = {} + let s:async_dictionary_list = {} +endif + +function! neocomplete#sources#dictionary#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'dictionary', + \ 'kind' : 'keyword', + \ 'mark' : '[D]', + \ 'rank' : 4, + \ 'hooks' : {}, + \} + +function! s:source.hooks.on_init(context) abort "{{{ + augroup neocomplete "{{{ + autocmd FileType * call s:make_cache(&l:filetype) + augroup END"}}} + + " Create cache directory. + call neocomplete#cache#make_directory('dictionary_cache') + + " Initialize check. + call s:make_cache(&l:filetype) +endfunction"}}} + +function! s:source.hooks.on_final(context) abort "{{{ + silent! delcommand NeoCompleteDictionaryMakeCache +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + let list = [] + + for ft in a:context.filetypes + if !has_key(s:dictionary_cache, ft) + call s:make_cache(ft) + endif + call neocomplete#cache#check_cache( + \ 'dictionary_cache', ft, + \ s:async_dictionary_list, s:dictionary_cache, 1) + + let list += get(s:dictionary_cache, ft, []) + endfor + + return list +endfunction"}}} + +function! s:make_cache(filetype) abort "{{{ + if !has_key(s:dictionary_cache, a:filetype) + \ && !has_key(s:async_dictionary_list, a:filetype) + call neocomplete#sources#dictionary#remake_cache(a:filetype) + endif +endfunction"}}} + +function! neocomplete#sources#dictionary#remake_cache(filetype) abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + let filetype = a:filetype + if filetype == '' + let filetype = neocomplete#get_context_filetype(1) + endif + + if !has_key(s:async_dictionary_list, filetype) + let s:async_dictionary_list[filetype] = [] + endif + + let pattern = neocomplete#get_keyword_pattern(filetype, s:source.name) + for dictionary in neocomplete#sources#dictionary#get_dictionaries(filetype) + let dictionary = neocomplete#util#substitute_path_separator( + \ fnamemodify(dictionary, ':p')) + if filereadable(dictionary) + call neocomplete#print_debug('Make cache dictionary: ' . dictionary) + call add(s:async_dictionary_list[filetype], { + \ 'filename' : dictionary, + \ 'cachename' : neocomplete#cache#async_load_from_file( + \ 'dictionary_cache', dictionary, pattern, 'D') + \ }) + endif + endfor +endfunction"}}} + +function! neocomplete#sources#dictionary#get_dictionaries(filetype) abort "{{{ + let filetype = a:filetype + if filetype == '' + let filetype = neocomplete#get_context_filetype(1) + endif + + " Make cache. + let dictionaries = get( + \ g:neocomplete#sources#dictionary#dictionaries, filetype, '') + if has_key(g:neocomplete#sources#dictionary#dictionaries, '_') + " Load global dictionaries. + let dictionaries .= ',' . + \ g:neocomplete#sources#dictionary#dictionaries['_'] + endif + + if dictionaries == '' && &l:dictionary != '' + if ((filetype ==# 'nothing' && &filetype == '') + \ || filetype ==# &filetype) + \ && &l:dictionary !=# &g:dictionary + let dictionaries = &l:dictionary + endif + endif + + return split(dictionaries, ',') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/file.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/file.vim new file mode 100644 index 0000000..b2e144a --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/file.vim @@ -0,0 +1,159 @@ +"============================================================================= +" FILE: file.vim +" AUTHOR: Shougo Matsushita +" 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' : 'file', + \ 'kind' : 'manual', + \ 'mark' : '[F]', + \ 'rank' : 10, + \ 'sorters' : 'sorter_filename', + \ 'converters' : ['converter_remove_overlap', 'converter_abbr'], + \ 'is_volatile' : 1, + \ 'input_pattern': '/', + \} + +function! s:source.get_complete_position(context) abort "{{{ + let filetype = a:context.filetype + if filetype ==# 'vimshell' || filetype ==# 'unite' || filetype ==# 'int-ssh' + return -1 + endif + + " Filename pattern. + let pattern = neocomplete#get_keyword_pattern_end('filename', self.name) + let [complete_pos, complete_str] = + \ neocomplete#helper#match_word(a:context.input, pattern) + + if complete_str =~ '//' || complete_str == '/' || + \ (neocomplete#is_auto_complete() && + \ complete_str !~ '/' || + \ complete_str =~# + \ '\\[^ ;*?[]"={}'']\|\.\.\+$\|/c\%[ygdrive/]$\|\${') + " Not filename pattern. + return -1 + endif + + if complete_str =~ '/' + let complete_pos += strridx(complete_str, '/') + 1 + endif + + return complete_pos +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + let pattern = neocomplete#get_keyword_pattern_end('filename', self.name) + let complete_str = + \ neocomplete#helper#match_word(a:context.input, pattern)[1] + if neocomplete#is_windows() && complete_str =~ '^[\\/]' + return [] + endif + + let cwd = getcwd() + try + let buffer_dir = fnamemodify(bufname('%'), ':h') + if isdirectory(buffer_dir) + " cd to buffer directory. + execute 'lcd' fnameescape(buffer_dir) + endif + + let files = s:get_glob_files(complete_str, '') + finally + execute 'lcd' fnameescape(cwd) + endtry + + return files +endfunction"}}} + +let s:cached_files = {} + +function! s:get_glob_files(complete_str, path) abort "{{{ + let path = ',,' . substitute(a:path, '\.\%(,\|$\)\|,,', '', 'g') + + let complete_str = neocomplete#util#substitute_path_separator( + \ substitute(a:complete_str, '\\\(.\)', '\1', 'g')) + let complete_str = substitute(complete_str, '[^/.]\+$', '', '') + + " Note: Support ${env} + let complete_str = substitute(complete_str, '\${\(\w\+\)}', '$\1', 'g') + + let glob = (complete_str !~ '\*$')? + \ complete_str . '*' : complete_str + + let ftype = getftype(glob) + if ftype != '' && ftype !=# 'dir' + " Note: If glob() device files, Vim may freeze! + return [] + endif + + if a:path == '' + let files = neocomplete#util#glob(glob) + else + try + let globs = globpath(path, glob) + catch + return [] + endtry + let files = split(substitute(globs, '\\', '/', 'g'), '\n') + endif + + call filter(files, 'v:val !~ "/\\.\\.\\?$"') + + let files = map( + \ files, "{ + \ 'word' : fnamemodify(v:val, ':t'), + \ 'action__is_directory' : isdirectory(v:val), + \ 'kind' : (isdirectory(v:val) ? 'dir' : 'file'), + \ }") + + let candidates = [] + for dict in files + let abbr = dict.word + if dict.action__is_directory && dict.word !~ '/$' + let abbr .= '/' + if g:neocomplete#enable_auto_delimiter + let dict.word .= '/' + endif + endif + let dict.abbr = abbr + + " Escape word. + let dict.word = escape(dict.word, ' ;*?[]"={}''') + + call add(candidates, dict) + endfor + + return candidates +endfunction"}}} + +function! neocomplete#sources#file#define() abort "{{{ + return s:source +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/member.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/member.vim new file mode 100644 index 0000000..2745727 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/member.vim @@ -0,0 +1,277 @@ +"============================================================================= +" FILE: member.vim +" AUTHOR: Shougo Matsushita +" 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. "{{{ +let g:neocomplete#sources#member#prefix_patterns = + \ get(g:, 'neocomplete#sources#member#prefix_patterns', {}) +let g:neocomplete#sources#member#input_patterns = + \ get(g:, 'neocomplete#sources#member#input_patterns', {}) +"}}} + +" Important variables. +if !exists('s:member_sources') + let s:member_sources = {} +endif + +let s:source = { + \ 'name' : 'member', + \ 'kind' : 'manual', + \ 'mark' : '[M]', + \ 'rank' : 5, + \ 'min_pattern_length' : 0, + \ 'hooks' : {}, + \ 'is_volatile' : 1, + \} + +function! s:source.hooks.on_init(context) abort "{{{ + augroup neocomplete "{{{ + " Make cache events + autocmd CursorHold * call s:make_cache_current_buffer( + \ line('.')-10, line('.')+10) + autocmd InsertEnter,InsertLeave * + \ call neocomplete#sources#member#make_cache_current_line() + autocmd FileType * + \ call neocomplete#sources#member#remake_cache(&l:filetype) + augroup END"}}} + + " Initialize member prefix patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ '_', '\.') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ 'c,objc', '\.\|->') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ 'cpp,objcpp', '\.\|->\|::') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ 'perl,php', '->') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ 'ruby', '\.\|::') + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#prefix_patterns', + \ 'lua', '\.\|:') + "}}} + + " Initialize member patterns. "{{{ + call neocomplete#util#set_default_dictionary( + \ 'g:neocomplete#sources#member#input_patterns', + \ '_', '\h\w*\%(()\?\|\[\h\w*\]\)\?') + "}}} + + " Initialize script variables. "{{{ + let s:member_sources = {} + "}}} +endfunction +"}}} + +function! s:source.get_complete_position(context) abort "{{{ + " Check member prefix pattern. + let filetype = a:context.filetype + let prefix = get(g:neocomplete#sources#member#prefix_patterns, filetype, + \ get(g:neocomplete#sources#member#prefix_patterns, '_', '')) + if prefix == '' + return -1 + endif + + let member = s:get_member_pattern(filetype) + let complete_pos = matchend(a:context.input, + \ member . '\m\%(' . prefix . '\m\)\ze\w*$') + return complete_pos +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + " Check member prefix pattern. + let filetype = a:context.filetype + let prefix = get(g:neocomplete#sources#member#prefix_patterns, filetype, + \ get(g:neocomplete#sources#member#prefix_patterns, '_', '')) + if prefix == '' + return [] + endif + + call neocomplete#sources#member#remake_cache(filetype) + + let var_name = matchstr(a:context.input, + \ s:get_member_pattern(filetype) . '\m\%(' . + \ prefix . '\m\)\ze\w*$') + if var_name == '' + return [] + endif + + return s:get_member_list(a:context, a:context.input, var_name) +endfunction"}}} + +function! neocomplete#sources#member#define() abort "{{{ + return s:source +endfunction"}}} + +function! neocomplete#sources#member#make_cache_current_line() abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + " Make cache from current line. + return s:make_cache_current_buffer(line('.')-1, line('.')+1) +endfunction"}}} +function! neocomplete#sources#member#make_cache_current_buffer() abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + " Make cache from current buffer. + return s:make_cache_current_buffer(1, line('$')) +endfunction"}}} +function! s:make_cache_current_buffer(start, end) abort "{{{ + let filetype = neocomplete#get_context_filetype(1) + + if !has_key(s:member_sources, bufnr('%')) + call s:initialize_source(bufnr('%'), filetype) + endif + + call s:make_cache_lines(bufnr('%'), filetype, getline(a:start, a:end)) +endfunction"}}} +function! s:make_cache_lines(srcname, filetype, lines) abort "{{{ + let filetype = a:filetype + if !has_key(s:member_sources, a:srcname) + call s:initialize_source(a:srcname, filetype) + endif + + let prefix = get(g:neocomplete#sources#member#prefix_patterns, filetype, + \ get(g:neocomplete#sources#member#prefix_patterns, '_', '')) + if prefix == '' + return + endif + let source = s:member_sources[a:srcname] + let member_pattern = s:get_member_pattern(filetype) + let prefix_pattern = member_pattern . '\m\%(' . prefix . '\m\)' + let keyword_pattern = + \ prefix_pattern . member_pattern + + " Cache member pattern. + for line in a:lines + let match = match(line, keyword_pattern) + + while match >= 0 "{{{ + let match_str = matchstr(line, '^'.keyword_pattern, match) + + " Next match. + let match = matchend(line, prefix_pattern, match) + + let member_name = matchstr(match_str, member_pattern . '$') + if member_name == '' + continue + 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] = 1 + endif + + let match_str = matchstr(var_name, '^'.keyword_pattern) + endwhile"}}} + endfor +endfunction"}}} + +function! s:get_member_list(context, cur_text, var_name) abort "{{{ + let keyword_list = [] + for source in filter(s:get_sources_list(a:context), + \ 'has_key(v:val.member_cache, a:var_name)') + let keyword_list += + \ keys(source.member_cache[a:var_name]) + endfor + + return keyword_list +endfunction"}}} + +function! s:get_sources_list(context) abort "{{{ + let filetypes_dict = {} + for filetype in a:context.filetypes + let filetypes_dict[filetype] = 1 + endfor + + return values(filter(copy(s:member_sources), + \ "has_key(filetypes_dict, v:val.filetype) + \ || has_key(filetypes_dict, '_') + \ || bufnr('%') == v:key + \ || (bufname('%') ==# '[Command Line]' && bufwinnr('#') == v:key)")) +endfunction"}}} + +function! s:initialize_source(srcname, filetype) abort "{{{ + let path = (a:srcname=~ '^\d\+$') ? + \ fnamemodify(bufname(a:srcname), ':p') : a:srcname + let filename = fnamemodify(path, ':t') + if filename == '' + let filename = '[No Name]' + let path .= '/[No Name]' + endif + + let ft = a:filetype + if ft == '' + let ft = 'nothing' + endif + + let s:member_sources[a:srcname] = { + \ 'member_cache' : {}, 'filetype' : ft, + \ 'time' : getftime(path), + \ 'keyword_pattern' : neocomplete#get_keyword_pattern(ft, s:source.name), + \} +endfunction"}}} + +function! s:get_member_pattern(filetype) abort "{{{ + return get(g:neocomplete#sources#member#input_patterns, a:filetype, + \ get(g:neocomplete#sources#member#input_patterns, '_', '')) +endfunction"}}} + +function! neocomplete#sources#member#remake_cache(filetype) abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + if get(g:neocomplete#sources#member#prefix_patterns, a:filetype, '') == '' + return + endif + + for dictionary in + \ filter(map(neocomplete#sources#dictionary#get_dictionaries(a:filetype), + \ "neocomplete#util#substitute_path_separator( + \ fnamemodify(v:val, ':p'))"), + \ "filereadable(v:val) && (!has_key(s:member_sources, v:val) + \ || getftime(v:val) > s:member_sources[v:val].time)") + call s:make_cache_lines(dictionary, a:filetype, readfile(dictionary)) + endfor +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/omni.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/omni.vim new file mode 100644 index 0000000..b7df649 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/omni.vim @@ -0,0 +1,294 @@ +"============================================================================= +" FILE: omni.vim +" AUTHOR: Shougo Matsushita +" 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. "{{{ +let g:neocomplete#sources#omni#functions = + \ get(g:, 'neocomplete#sources#omni#functions', {}) +let g:neocomplete#sources#omni#input_patterns = + \ get(g:, 'neocomplete#sources#omni#input_patterns', {}) +"}}} + +let s:source = { + \ 'name' : 'omni', + \ 'kind' : 'manual', + \ 'mark' : '[O]', + \ 'rank' : 50, + \ 'min_pattern_length' : 0, + \ 'hooks' : {}, + \} + +let s:List = neocomplete#util#get_vital().import('Data.List') + +function! s:source.hooks.on_init(context) abort "{{{ + " Initialize omni completion pattern. "{{{ + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'html,xhtml,xml,markdown,mkd', + \'<\|\s[[:alnum:]-]*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'css,scss,sass', + \'\w\+\|\w\+[):;]\?\s\+\w*\|[@!]') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'javascript', + \'[^. \t]\.\%(\h\w*\)\?') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'actionscript', + \'[^. \t][.:]\h\w*') + "call neocomplete#util#set_default_dictionary( + "\'g:neocomplete#sources#omni#input_patterns', + "\'php', + "\'[^. \t]->\h\w*\|\h\w*::\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'java', + \'\%(\h\w*\|)\)\.\w*') + "call neocomplete#util#set_default_dictionary( + "\'g:neocomplete#sources#omni#input_patterns', + "\'perl', + "\'\h\w*->\h\w*\|\h\w*::\w*') + "call neocomplete#util#set_default_dictionary( + "\'g:neocomplete#sources#omni#input_patterns', + "\'c', + "\'[^.[:digit:] *\t]\%(\.\|->\)\w*' + "call neocomplete#util#set_default_dictionary( + "\'g:neocomplete#sources#omni#input_patterns', + "\'cpp', + "\'[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'objc', + \'[^.[:digit:] *\t]\%(\.\|->\)\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'objj', + \'[\[ \.]\w\+$\|:\w*$') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'go', + \'[^.[:digit:] *\t]\.\w*') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'clojure', + \'\%(([^)]\+\)\|\*[[:alnum:]_-]\+') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'rust', + \'[^.[:digit:] *\t]\%(\.\|\::\)\%(\h\w*\)\?') + + " External language interface check. + if has('ruby') + " call neocomplete#util#set_default_dictionary( + "\'g:neocomplete#sources#omni#input_patterns', 'ruby', + "\'[^. *\t]\.\h\w*\|\h\w*::\w*') + endif + if has('python') || has('python3') + call neocomplete#util#set_default_dictionary( + \'g:neocomplete#sources#omni#input_patterns', + \'python', '[^. \t]\.\w*') + endif + "}}} +endfunction"}}} + +function! s:source.get_complete_position(context) abort "{{{ + let a:context.source__complete_results = + \ s:set_complete_results_pos( + \ s:get_omni_funcs(a:context.filetype), a:context.input) + + return s:get_complete_pos(a:context.source__complete_results) +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + return s:get_candidates( + \ s:set_complete_results_words( + \ a:context.source__complete_results), + \ a:context.complete_pos, a:context.complete_str) +endfunction"}}} + +function! neocomplete#sources#omni#define() abort "{{{ + return s:source +endfunction"}}} + +function! s:get_omni_funcs(filetype) abort "{{{ + let funcs = [] + for ft in insert(split(a:filetype, '\.'), '_') + let omnifuncs = neocomplete#util#convert2list( + \ get(g:neocomplete#sources#omni#functions, ft, &l:omnifunc)) + + for omnifunc in omnifuncs + if neocomplete#helper#check_invalid_omnifunc(omnifunc) + " omnifunc is irregal. + continue + endif + + if get(g:neocomplete#sources#omni#input_patterns, omnifunc, '') != '' + let pattern = g:neocomplete#sources#omni#input_patterns[omnifunc] + elseif get(g:neocomplete#sources#omni#input_patterns, ft, '') != '' + let pattern = g:neocomplete#sources#omni#input_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) abort "{{{ + let omni_list = [] + + " Convert string list. + for val in deepcopy(a:list) + let dict = (type(val) == type('') ? + \ { 'word' : val } : val) + call add(omni_list, dict) + + unlet val + endfor + + return omni_list +endfunction"}}} + +function! s:set_complete_results_pos(funcs, cur_text) abort "{{{ + " Try omnifunc completion. "{{{ + let complete_results = {} + for [omnifunc, pattern] in a:funcs + if neocomplete#is_auto_complete() + \ && (pattern == '' + \ || a:cur_text !~# '\%(' . pattern . '\m\)$') + continue + endif + + " Save pos. + let pos = getpos('.') + + try + let complete_pos = call(omnifunc, [1, '']) + catch + call neocomplete#print_error( + \ 'Error occurred calling omnifunction: ' . omnifunc) + call neocomplete#print_error(v:throwpoint) + call neocomplete#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) abort "{{{ + " Try source completion. + for [omnifunc, result] in items(a:complete_results) + if neocomplete#complete_check() + return a:complete_results + endif + + let pos = getpos('.') + + try + let ret = call(omnifunc, [0, result.complete_str]) + let list = type(ret) == type(0) ? [] : + \ type(ret) == type([]) ? ret : ret.words + catch + call neocomplete#print_error( + \ 'Error occurred calling omnifunction: ' . omnifunc) + call neocomplete#print_error(v:throwpoint) + call neocomplete#print_error(v:exception) + let list = [] + finally + call setpos('.', pos) + endtry + + let list = s:get_omni_list(list) + + let result.candidates = list + endfor + + return a:complete_results +endfunction"}}} +function! s:get_complete_pos(complete_results) abort "{{{ + 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) abort "{{{ + " Append prefix. + let candidates = [] + for result in values(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/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/tag.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/tag.vim new file mode 100644 index 0000000..28d3a79 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/sources/tag.vim @@ -0,0 +1,120 @@ +"============================================================================= +" FILE: tag.vim +" AUTHOR: Shougo Matsushita +" 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' : 'tag', + \ 'kind' : 'keyword', + \ 'mark' : '[T]', + \ 'hooks' : {}, + \} + +function! s:source.hooks.on_init(context) abort "{{{ + let g:neocomplete#sources#tags#cache_limit_size = + \ get(g:, 'neocomplete#sources#tags#cache_limit_size', 500000) + + augroup neocomplete "{{{ + autocmd BufWritePost * call neocomplete#sources#tag#make_cache(0) + augroup END"}}} + + " Create cache directory. + call neocomplete#cache#make_directory('tags_cache') +endfunction"}}} + +function! s:source.hooks.on_final(context) abort "{{{ + silent! delcommand NeoCompleteTagMakeCache +endfunction"}}} + +function! neocomplete#sources#tag#define() abort "{{{ + return s:source +endfunction"}}} + +function! s:source.gather_candidates(context) abort "{{{ + if !has_key(s:async_tags_list, bufnr('%')) + \ && !has_key(s:tags_list, bufnr('%')) + call neocomplete#sources#tag#make_cache(0) + endif + + if neocomplete#within_comment() + return [] + endif + + call neocomplete#cache#check_cache( + \ 'tags_cache', bufnr('%'), s:async_tags_list, s:tags_list, 0) + + return copy(get(s:tags_list, bufnr('%'), [])) +endfunction"}}} + +function! s:initialize_tags(filename) abort "{{{ + " Initialize tags list. + let ft = &filetype + if ft == '' + let ft = 'nothing' + endif + + return { + \ 'filename' : a:filename, + \ 'cachename' : neocomplete#cache#async_load_from_tags( + \ 'tags_cache', a:filename, + \ neocomplete#get_keyword_pattern(ft, s:source.name), + \ ft, s:source.mark) + \ } +endfunction"}}} +function! neocomplete#sources#tag#make_cache(force) abort "{{{ + if !neocomplete#is_enabled() + call neocomplete#initialize() + endif + + let bufnumber = bufnr('%') + + let s:async_tags_list[bufnumber] = [] + let tagfiles = tagfiles() + if get(g:, 'loaded_neoinclude', 0) + let tagfiles += neoinclude#include#get_tag_files() + endif + for tags in map(filter(tagfiles, 'getfsize(v:val) > 0'), + \ "neocomplete#util#substitute_path_separator( + \ fnamemodify(v:val, ':p'))") + if tags !~? '/doc/tags\%(-\w\+\)\?$' && + \ (a:force || getfsize(tags) + \ < g:neocomplete#sources#tags#cache_limit_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/pack/acp/start/neocomplete.vim/autoload/neocomplete/util.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/util.vim new file mode 100644 index 0000000..d772740 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/util.vim @@ -0,0 +1,264 @@ +"============================================================================= +" FILE: util.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#util#get_vital() abort "{{{ + if !exists('s:V') + let s:V = vital#neocomplete#new() + endif + return s:V +endfunction"}}} +function! s:get_prelude() abort "{{{ + if !exists('s:Prelude') + let s:Prelude = neocomplete#util#get_vital().import('Prelude') + endif + return s:Prelude +endfunction"}}} +function! s:get_list() abort "{{{ + if !exists('s:List') + let s:List = neocomplete#util#get_vital().import('Data.List') + endif + return s:List +endfunction"}}} +function! s:get_string() abort "{{{ + if !exists('s:String') + let s:String = neocomplete#util#get_vital().import('Data.String') + endif + return s:String +endfunction"}}} +function! s:get_process() abort "{{{ + if !exists('s:Process') + let s:Process = neocomplete#util#get_vital().import('Process') + endif + return s:Process +endfunction"}}} + +function! neocomplete#util#truncate_smart(...) abort "{{{ + return call(s:get_string().truncate_skipping, a:000) +endfunction"}}} +function! neocomplete#util#truncate(...) abort "{{{ + return call(s:get_string().truncate, a:000) +endfunction"}}} +function! neocomplete#util#strchars(...) abort "{{{ + return call(s:get_string().strchars, a:000) +endfunction"}}} +function! neocomplete#util#wcswidth(string) abort "{{{ + return strwidth(a:string) +endfunction"}}} +function! neocomplete#util#strwidthpart(...) abort "{{{ + return call(s:get_string().strwidthpart, a:000) +endfunction"}}} +function! neocomplete#util#strwidthpart_reverse(...) abort "{{{ + return call(s:get_string().strwidthpart_reverse, a:000) +endfunction"}}} + +function! neocomplete#util#substitute_path_separator(...) abort "{{{ + return call(s:get_prelude().substitute_path_separator, a:000) +endfunction"}}} +function! neocomplete#util#mb_strlen(...) abort "{{{ + return call(s:get_string().strchars, a:000) +endfunction"}}} +function! neocomplete#util#uniq(list) abort "{{{ + let dict = {} + for item in a:list + if !has_key(dict, item) + let dict[item] = item + endif + endfor + + return values(dict) +endfunction"}}} +function! neocomplete#util#system(...) abort "{{{ + return call(s:get_process().system, a:000) +endfunction"}}} +function! neocomplete#util#is_windows(...) abort "{{{ + return call(s:get_prelude().is_windows, a:000) +endfunction"}}} +function! neocomplete#util#is_mac(...) abort "{{{ + return call(s:get_prelude().is_mac, a:000) +endfunction"}}} +function! neocomplete#util#is_complete_select() abort "{{{ + return has('patch-7.4.775') +endfunction"}}} +function! neocomplete#util#get_last_status(...) abort "{{{ + return call(s:get_process().get_last_status, a:000) +endfunction"}}} +function! neocomplete#util#escape_pattern(...) abort "{{{ + return call(s:get_string().escape_pattern, a:000) +endfunction"}}} +function! neocomplete#util#iconv(...) abort "{{{ + return call(s:get_process().iconv, a:000) +endfunction"}}} +function! neocomplete#util#uniq(...) abort "{{{ + return call(s:get_list().uniq, a:000) +endfunction"}}} +function! neocomplete#util#sort_by(...) abort "{{{ + return call(s:get_list().sort_by, a:000) +endfunction"}}} + +" Sudo check. +function! neocomplete#util#is_sudo() abort "{{{ + return $SUDO_USER != '' && $USER !=# $SUDO_USER + \ && $HOME !=# expand('~'.$USER) + \ && $HOME ==# expand('~'.$SUDO_USER) +endfunction"}}} + +function! neocomplete#util#glob(pattern, ...) abort "{{{ + if a:pattern =~ "'" + " Use glob('*'). + let cwd = getcwd() + let base = neocomplete#util#substitute_path_separator( + \ fnamemodify(a:pattern, ':h')) + execute 'lcd' fnameescape(base) + + let files = map(split(neocomplete#util#substitute_path_separator( + \ glob('*')), '\n'), "base . '/' . v:val") + + execute 'lcd' fnameescape(cwd) + + return files + endif + + " let is_force_glob = get(a:000, 0, 0) + let is_force_glob = get(a:000, 0, 1) + + if !is_force_glob && a:pattern =~ '^[^\\*]\+/\*' + \ && neocomplete#util#has_vimproc() && exists('*vimproc#readdir') + return filter(vimproc#readdir(a:pattern[: -2]), 'v:val !~ "/\\.\\.\\?$"') + else + " Escape [. + if neocomplete#util#is_windows() + let glob = substitute(a:pattern, '\[', '\\[[]', 'g') + else + let glob = escape(a:pattern, '[') + endif + + return split(neocomplete#util#substitute_path_separator(glob(glob)), '\n') + endif +endfunction"}}} +function! neocomplete#util#expand(path) abort "{{{ + return expand(escape(a:path, '*?[]"={}'), 1) +endfunction"}}} + +function! neocomplete#util#set_default(var, val, ...) abort "{{{ + if !exists(a:var) || type({a:var}) != type(a:val) + let alternate_var = get(a:000, 0, '') + + let {a:var} = exists(alternate_var) ? + \ {alternate_var} : a:val + endif +endfunction"}}} +function! neocomplete#util#set_dictionary_helper(variable, keys, pattern) abort "{{{ + for key in split(a:keys, '\s*,\s*') + if !has_key(a:variable, key) + let a:variable[key] = a:pattern + endif + endfor +endfunction"}}} + +function! neocomplete#util#set_default_dictionary(variable, keys, value) abort "{{{ + if !exists('s:disable_dictionaries') + let s:disable_dictionaries = {} + endif + + if has_key(s:disable_dictionaries, a:variable) + return + endif + + call neocomplete#util#set_dictionary_helper({a:variable}, a:keys, a:value) +endfunction"}}} +function! neocomplete#util#disable_default_dictionary(variable) abort "{{{ + if !exists('s:disable_dictionaries') + let s:disable_dictionaries = {} + endif + + let s:disable_dictionaries[a:variable] = 1 +endfunction"}}} + +function! neocomplete#util#split_rtp(...) abort "{{{ + let rtp = a:0 ? a:1 : &runtimepath + if type(rtp) == type([]) + return rtp + endif + + if rtp !~ '\\' + return split(rtp, ',') + endif + + let split = split(rtp, '\\\@ 704 || v:version == 704 && has('patch143') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/neocomplete/variables.vim b/pack/acp/start/neocomplete.vim/autoload/neocomplete/variables.vim new file mode 100644 index 0000000..c82dc70 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/neocomplete/variables.vim @@ -0,0 +1,67 @@ +"============================================================================= +" FILE: variables.vim +" AUTHOR: Shougo Matsushita +" 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! neocomplete#variables#get_frequencies() abort "{{{ + if !exists('s:filetype_frequencies') + let s:filetype_frequencies = {} + endif + let filetype = neocomplete#get_context_filetype() + if !has_key(s:filetype_frequencies, filetype) + let s:filetype_frequencies[filetype] = {} + endif + + let frequencies = s:filetype_frequencies[filetype] + + return frequencies +endfunction"}}} + +function! neocomplete#variables#get_sources() abort "{{{ + if !exists('s:sources') + let s:sources = {} + endif + return s:sources +endfunction"}}} + +function! neocomplete#variables#get_source(name) abort "{{{ + if !exists('s:sources') + let s:sources = {} + endif + return get(s:sources, a:name, {}) +endfunction"}}} + +function! neocomplete#variables#get_filters() abort "{{{ + if !exists('s:filters') + let s:filters = {} + endif + return s:filters +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/unite/sources/neocomplete.vim b/pack/acp/start/neocomplete.vim/autoload/unite/sources/neocomplete.vim new file mode 100644 index 0000000..38d338e --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/unite/sources/neocomplete.vim @@ -0,0 +1,144 @@ +"============================================================================= +" FILE: neocomplete.vim +" AUTHOR: Shougo Matsushita +" 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! unite#sources#neocomplete#define() abort "{{{ + return s:neocomplete_source +endfunction "}}} + +" neocomplete unite source. +let s:neocomplete_source = { + \ 'name': 'neocomplete', + \ 'hooks' : {}, + \ } + +function! s:neocomplete_source.hooks.on_init(args, context) abort "{{{ + if !neocomplete#is_enabled() + let a:context.source__complete_pos = -1 + let a:context.source__candidates = [] + return + endif + + " Save options. + let max_list_save = g:neocomplete#max_list + let max_keyword_width_save = g:neocomplete#max_keyword_width + let manual_start_length = g:neocomplete#manual_completion_start_length + let neocomplete = neocomplete#get_current_neocomplete() + let sources_save = get(neocomplete, 'sources', {}) + + try + let g:neocomplete#max_list = -1 + let g:neocomplete#max_keyword_width = -1 + let g:neocomplete#manual_completion_start_length = 0 + + let cur_text = neocomplete#get_cur_text(1) + let sources = get(a:context, 'source__sources', []) + let args = [cur_text] + if !empty(sources) + call add(args, neocomplete#helper#get_sources_list(sources)) + endif + let complete_sources = call('neocomplete#complete#_get_results', args) + let a:context.source__complete_pos = + \ neocomplete#complete#_get_complete_pos(complete_sources) + let a:context.source__candidates = neocomplete#complete#_get_words( + \ complete_sources, a:context.source__complete_pos, + \ cur_text[a:context.source__complete_pos :]) + finally + " Restore options. + let g:neocomplete#max_list = max_list_save + let g:neocomplete#max_keyword_width = max_keyword_width_save + let g:neocomplete#manual_completion_start_length = manual_start_length + let neocomplete.sources = empty(sources_save) ? + \ neocomplete#helper#get_sources_list() : sources_save + endtry +endfunction"}}} + +function! s:neocomplete_source.gather_candidates(args, context) abort "{{{ + let keyword_pos = a:context.source__complete_pos + let candidates = [] + for keyword in a:context.source__candidates + let dict = { + \ 'word' : keyword.word, + \ 'abbr' : printf('%-50s', get(keyword, 'abbr', keyword.word)), + \ 'kind': 'completion', + \ 'action__complete_word' : keyword.word, + \ 'action__complete_pos' : keyword_pos, + \ } + if has_key(keyword, 'kind') + let dict.abbr .= ' ' . keyword.kind + endif + if has_key(keyword, 'menu') + let dict.abbr .= ' ' . keyword.menu + endif + if has_key(keyword, 'description') + if type(keyword.description) ==# type(function('tr')) + let dict.action__complete_info_lazy = keyword.description + else + let dict.action__complete_info = keyword.description + endif + endif + + call add(candidates, dict) + endfor + + return candidates +endfunction "}}} + +function! unite#sources#neocomplete#start_complete() abort "{{{ + return s:start_complete(0) +endfunction "}}} + +function! unite#sources#neocomplete#start_quick_match() abort "{{{ + return s:start_complete(1) +endfunction "}}} + +function! s:start_complete(is_quick_match) abort "{{{ + if !neocomplete#is_enabled() + return '' + endif + if !exists(':Unite') + echoerr 'unite.vim is not installed.' + return '' + endif + + let cur_text = neocomplete#get_cur_text(1) + let complete_sources = neocomplete#complete#_set_results_pos(cur_text) + if empty(complete_sources) + return '' + endif + + return unite#start_complete(['neocomplete'], { + \ 'auto_preview' : 1, 'quick_match' : a:is_quick_match, + \ 'input' : cur_text[neocomplete#complete#_get_complete_pos( + \ complete_sources) :], + \ }) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/autoload/vital.vim b/pack/acp/start/neocomplete.vim/autoload/vital.vim new file mode 100644 index 0000000..f1ba849 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital.vim @@ -0,0 +1,12 @@ +function! vital#of(name) abort + let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital', 1) + let file = split(files, "\n") + if empty(file) + throw 'vital: version file not found: ' . a:name + endif + let ver = readfile(file[0], 'b') + if empty(ver) + throw 'vital: invalid version file: ' . a:name + endif + return vital#_{substitute(ver[0], '\W', '', 'g')}#new() +endfunction diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete.vim new file mode 100644 index 0000000..9eba177 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete.vim @@ -0,0 +1,5 @@ +let s:_plugin_name = expand(':t:r') + +function! vital#{s:_plugin_name}#new() abort + return vital#{s:_plugin_name[1:]}#new() +endfunction diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/List.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/List.vim new file mode 100644 index 0000000..335504f --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/List.vim @@ -0,0 +1,457 @@ +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +if v:version > 703 || v:version == 703 && has('patch1170') + function! vital#_neocomplete#Data#List#import() abort + return map({'combinations': '', 'and': '', 'sort_by': '', 'foldr1': '', 'sort': '', 'flatten': '', 'has_index': '', 'find_indices': '', 'any': '', 'unshift': '', 'span': '', 'pop': '', 'binary_search': '', 'uniq_by': '', 'or': '', 'all': '', 'zip': '', 'find_last_index': '', 'find': '', 'partition': '', 'map_accum': '', 'permutations': '', 'break': '', 'max_by': '', 'foldl': '', 'foldr': '', 'find_index': '', 'group_by': '', 'take_while': '', 'conj': '', 'push': '', 'char_range': '', 'cons': '', 'foldl1': '', 'intersect': '', 'concat': '', 'shift': '', 'clear': '', 'has_common_items': '', 'product': '', 'zip_fill': '', 'uniq': '', 'has': '', 'min_by': '', 'with_index': ''}, 'function("s:" . v:key)') + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + execute join(['function! vital#_neocomplete#Data#List#import() abort', printf("return map({'combinations': '', 'and': '', 'sort_by': '', 'foldr1': '', 'sort': '', 'flatten': '', 'has_index': '', 'find_indices': '', 'any': '', 'unshift': '', 'span': '', 'pop': '', 'binary_search': '', 'uniq_by': '', 'or': '', 'all': '', 'zip': '', 'find_last_index': '', 'find': '', 'partition': '', 'map_accum': '', 'permutations': '', 'break': '', 'max_by': '', 'foldl': '', 'foldr': '', 'find_index': '', 'group_by': '', 'take_while': '', 'conj': '', 'push': '', 'char_range': '', 'cons': '', 'foldl1': '', 'intersect': '', 'concat': '', 'shift': '', 'clear': '', 'has_common_items': '', 'product': '', 'zip_fill': '', 'uniq': '', 'has': '', 'min_by': '', 'with_index': ''}, \"function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") + delfunction s:_SID +endif +" ___vital___ +" Utilities for list. + +let s:save_cpo = &cpo +set cpo&vim + +function! s:pop(list) abort + return remove(a:list, -1) +endfunction + +function! s:push(list, val) abort + call add(a:list, a:val) + return a:list +endfunction + +function! s:shift(list) abort + return remove(a:list, 0) +endfunction + +function! s:unshift(list, val) abort + return insert(a:list, a:val) +endfunction + +function! s:cons(x, xs) abort + return [a:x] + a:xs +endfunction + +function! s:conj(xs, x) abort + return a:xs + [a:x] +endfunction + +" Removes duplicates from a list. +function! s:uniq(list) abort + return s:uniq_by(a:list, 'v:val') +endfunction + +" Removes duplicates from a list. +function! s:uniq_by(list, f) abort + let list = map(copy(a:list), printf('[v:val, %s]', a:f)) + let i = 0 + let seen = {} + while i < len(list) + let key = string(list[i][1]) + if has_key(seen, key) + call remove(list, i) + else + let seen[key] = 1 + let i += 1 + endif + endwhile + return map(list, 'v:val[0]') +endfunction + +function! s:clear(list) abort + if !empty(a:list) + unlet! a:list[0 : len(a:list) - 1] + endif + return a:list +endfunction + +" Concatenates a list of lists. +" XXX: Should we verify the input? +function! s:concat(list) abort + let memo = [] + for Value in a:list + let memo += Value + endfor + return memo +endfunction + +" Take each elements from lists to a new list. +function! s:flatten(list, ...) abort + let limit = a:0 > 0 ? a:1 : -1 + let memo = [] + if limit == 0 + return a:list + endif + let limit -= 1 + for Value in a:list + let memo += + \ type(Value) == type([]) ? + \ s:flatten(Value, limit) : + \ [Value] + unlet! Value + endfor + return memo +endfunction + +" Sorts a list with expression to compare each two values. +" a:a and a:b can be used in {expr}. +function! s:sort(list, expr) abort + if type(a:expr) == type(function('function')) + return sort(a:list, a:expr) + endif + let s:expr = a:expr + return sort(a:list, 's:_compare') +endfunction + +function! s:_compare(a, b) abort + return eval(s:expr) +endfunction + +" Sorts a list using a set of keys generated by mapping the values in the list +" through the given expr. +" v:val is used in {expr} +function! s:sort_by(list, expr) abort + let pairs = map(a:list, printf('[v:val, %s]', a:expr)) + return map(s:sort(pairs, + \ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'), 'v:val[0]') +endfunction + +" Returns a maximum value in {list} through given {expr}. +" Returns 0 if {list} is empty. +" v:val is used in {expr} +function! s:max_by(list, expr) abort + if empty(a:list) + return 0 + endif + let list = map(copy(a:list), a:expr) + return a:list[index(list, max(list))] +endfunction + +" Returns a minimum value in {list} through given {expr}. +" Returns 0 if {list} is empty. +" v:val is used in {expr} +" FIXME: -0x80000000 == 0x80000000 +function! s:min_by(list, expr) abort + return s:max_by(a:list, '-(' . a:expr . ')') +endfunction + +" Returns List of character sequence between [a:from, a:to] +" e.g.: s:char_range('a', 'c') returns ['a', 'b', 'c'] +function! s:char_range(from, to) abort + return map( + \ range(char2nr(a:from), char2nr(a:to)), + \ 'nr2char(v:val)' + \) +endfunction + +" Returns true if a:list has a:value. +" Returns false otherwise. +function! s:has(list, value) abort + return index(a:list, a:value) isnot -1 +endfunction + +" Returns true if a:list[a:index] exists. +" Returns false otherwise. +" NOTE: Returns false when a:index is negative number. +function! s:has_index(list, index) abort + " Return true when negative index? + " let index = a:index >= 0 ? a:index : len(a:list) + a:index + return 0 <= a:index && a:index < len(a:list) +endfunction + +" similar to Haskell's Data.List.span +function! s:span(f, xs) abort + let border = len(a:xs) + for i in range(len(a:xs)) + if !eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g')) + let border = i + break + endif + endfor + return border == 0 ? [[], copy(a:xs)] : [a:xs[: border - 1], a:xs[border :]] +endfunction + +" similar to Haskell's Data.List.break +function! s:break(f, xs) abort + return s:span(printf('!(%s)', a:f), a:xs) +endfunction + +" similar to Haskell's Data.List.takeWhile +function! s:take_while(f, xs) abort + return s:span(a:f, a:xs)[0] +endfunction + +" similar to Haskell's Data.List.partition +function! s:partition(f, xs) abort + return [filter(copy(a:xs), a:f), filter(copy(a:xs), '!(' . a:f . ')')] +endfunction + +" similar to Haskell's Prelude.all +function! s:all(f, xs) abort + return !s:any(printf('!(%s)', a:f), a:xs) +endfunction + +" similar to Haskell's Prelude.any +function! s:any(f, xs) abort + return !empty(filter(map(copy(a:xs), a:f), 'v:val')) +endfunction + +" similar to Haskell's Prelude.and +function! s:and(xs) abort + return s:all('v:val', a:xs) +endfunction + +" similar to Haskell's Prelude.or +function! s:or(xs) abort + return s:any('v:val', a:xs) +endfunction + +function! s:map_accum(expr, xs, init) abort + let memo = [] + let init = a:init + for x in a:xs + let expr = substitute(a:expr, 'v:memo', init, 'g') + let expr = substitute(expr, 'v:val', x, 'g') + let [tmp, init] = eval(expr) + call add(memo, tmp) + endfor + return memo +endfunction + +" similar to Haskell's Prelude.foldl +function! s:foldl(f, init, xs) abort + let memo = a:init + for x in a:xs + let expr = substitute(a:f, 'v:val', string(x), 'g') + let expr = substitute(expr, 'v:memo', string(memo), 'g') + unlet memo + let memo = eval(expr) + endfor + return memo +endfunction + +" similar to Haskell's Prelude.foldl1 +function! s:foldl1(f, xs) abort + if len(a:xs) == 0 + throw 'vital: Data.List: foldl1' + endif + return s:foldl(a:f, a:xs[0], a:xs[1:]) +endfunction + +" similar to Haskell's Prelude.foldr +function! s:foldr(f, init, xs) abort + return s:foldl(a:f, a:init, reverse(copy(a:xs))) +endfunction + +" similar to Haskell's Prelude.fold11 +function! s:foldr1(f, xs) abort + if len(a:xs) == 0 + throw 'vital: Data.List: foldr1' + endif + return s:foldr(a:f, a:xs[-1], a:xs[0:-2]) +endfunction + +" similar to python's zip() +function! s:zip(...) abort + return map(range(min(map(copy(a:000), 'len(v:val)'))), "map(copy(a:000), 'v:val['.v:val.']')") +endfunction + +" similar to zip(), but goes until the longer one. +function! s:zip_fill(xs, ys, filler) abort + if empty(a:xs) && empty(a:ys) + return [] + elseif empty(a:ys) + return s:cons([a:xs[0], a:filler], s:zip_fill(a:xs[1 :], [], a:filler)) + elseif empty(a:xs) + return s:cons([a:filler, a:ys[0]], s:zip_fill([], a:ys[1 :], a:filler)) + else + return s:cons([a:xs[0], a:ys[0]], s:zip_fill(a:xs[1 :], a:ys[1: ], a:filler)) + endif +endfunction + +" Inspired by Ruby's with_index method. +function! s:with_index(list, ...) abort + let base = a:0 > 0 ? a:1 : 0 + return map(copy(a:list), '[v:val, v:key + base]') +endfunction + +" similar to Ruby's detect or Haskell's find. +function! s:find(list, default, f) abort + for x in a:list + if eval(substitute(a:f, 'v:val', string(x), 'g')) + return x + endif + endfor + return a:default +endfunction + +" Returns the index of the first element which satisfies the given expr. +function! s:find_index(xs, f, ...) abort + let len = len(a:xs) + let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : 0 + let default = a:0 > 1 ? a:2 : -1 + if start >=# len || start < 0 + return default + endif + for i in range(start, len - 1) + if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g')) + return i + endif + endfor + return default +endfunction + +" Returns the index of the last element which satisfies the given expr. +function! s:find_last_index(xs, f, ...) abort + let len = len(a:xs) + let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : len - 1 + let default = a:0 > 1 ? a:2 : -1 + if start >=# len || start < 0 + return default + endif + for i in range(start, 0, -1) + if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g')) + return i + endif + endfor + return default +endfunction + +" Similar to find_index but returns the list of indices satisfying the given expr. +function! s:find_indices(xs, f, ...) abort + let len = len(a:xs) + let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : 0 + let result = [] + if start >=# len || start < 0 + return result + endif + for i in range(start, len - 1) + if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g')) + call add(result, i) + endif + endfor + return result +endfunction + +" Return non-zero if a:list1 and a:list2 have any common item(s). +" Return zero otherwise. +function! s:has_common_items(list1, list2) abort + return !empty(filter(copy(a:list1), 'index(a:list2, v:val) isnot -1')) +endfunction + +function! s:intersect(list1, list2) abort + let items = [] + " for funcref + for X in a:list1 + if index(a:list2, X) != -1 && index(items, X) == -1 + let items += [X] + endif + endfor + return items +endfunction + +" similar to Ruby's group_by. +function! s:group_by(xs, f) abort + let result = {} + let list = map(copy(a:xs), printf('[v:val, %s]', a:f)) + for x in list + let Val = x[0] + let key = type(x[1]) !=# type('') ? string(x[1]) : x[1] + if has_key(result, key) + call add(result[key], Val) + else + let result[key] = [Val] + endif + unlet Val + endfor + return result +endfunction + +function! s:_default_compare(a, b) abort + return a:a <# a:b ? -1 : a:a ># a:b ? 1 : 0 +endfunction + +function! s:binary_search(list, value, ...) abort + let Predicate = a:0 >= 1 ? a:1 : 's:_default_compare' + let dic = a:0 >= 2 ? a:2 : {} + let start = 0 + let end = len(a:list) - 1 + + while 1 + if start > end + return -1 + endif + + let middle = (start + end) / 2 + + let compared = call(Predicate, [a:value, a:list[middle]], dic) + + if compared < 0 + let end = middle - 1 + elseif compared > 0 + let start = middle + 1 + else + return middle + endif + endwhile +endfunction + +function! s:product(lists) abort + let result = [[]] + for pool in a:lists + let tmp = [] + for x in result + let tmp += map(copy(pool), 'x + [v:val]') + endfor + let result = tmp + endfor + return result +endfunction + +function! s:permutations(list, ...) abort + if a:0 > 1 + throw 'vital: Data.List: too many arguments' + endif + let r = a:0 == 1 ? a:1 : len(a:list) + if r > len(a:list) + return [] + elseif r < 0 + throw 'vital: Data.List: {r} must be non-negative integer' + endif + let n = len(a:list) + let result = [] + for indices in s:product(map(range(r), 'range(n)')) + if len(s:uniq(indices)) == r + call add(result, map(indices, 'a:list[v:val]')) + endif + endfor + return result +endfunction + +function! s:combinations(list, r) abort + if a:r > len(a:list) + return [] + elseif a:r < 0 + throw 'vital: Data:List: {r} must be non-negative integer' + endif + let n = len(a:list) + let result = [] + for indices in s:permutations(range(n), a:r) + if s:sort(copy(indices), 'a:a - a:b') == indices + call add(result, map(indices, 'a:list[v:val]')) + endif + endfor + return result +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/String.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/String.vim new file mode 100644 index 0000000..7a6bd4e --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Data/String.vim @@ -0,0 +1,633 @@ +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +if v:version > 703 || v:version == 703 && has('patch1170') + function! vital#_neocomplete#Data#String#import() abort + return map({'starts_with': '', 'split3': '', 'replace_first': '', 'chop': '', 'unescape': '', 'split_posix_text': '', 'replace': '', 'scan': '', 'strwidthpart': '', 'common_head': '', 'reverse': '', 'escape_pattern': '', 'trim_end': '', '_vital_depends': '', 'wrap': '', 'join_posix_lines': '', 'contains_multibyte': '', 'truncate_skipping': '', 'split_leftright': '', 'ends_with': '', 'nsplit': '', 'strwidthpart_reverse': '', 'unescape_pattern': '', 'levenshtein_distance': '', 'trim_start': '', 'justify_equal_spacing': '', 'nr2hex': '', 'iconv': '', 'pad_left': '', 'nr2enc_char': '', 'lines': '', 'repair_posix_text': '', 'nr2byte': '', 'trim': '', 'diffidx': '', 'truncate': '', 'split_by_displaywidth': '', '_vital_created': '', 'padding_by_displaywidth': '', 'hash': '', 'chomp': '', 'pad_between_letters': '', 'dstring': '', 'pad_both_sides': '', 'substitute_last': '', 'pad_right': '', 'remove_ansi_sequences': '', '_vital_loaded': ''}, 'function("s:" . v:key)') + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + execute join(['function! vital#_neocomplete#Data#String#import() abort', printf("return map({'starts_with': '', 'split3': '', 'replace_first': '', 'chop': '', 'unescape': '', 'split_posix_text': '', 'replace': '', 'scan': '', 'strwidthpart': '', 'common_head': '', 'reverse': '', 'escape_pattern': '', 'trim_end': '', '_vital_depends': '', 'wrap': '', 'join_posix_lines': '', 'contains_multibyte': '', 'truncate_skipping': '', 'split_leftright': '', 'ends_with': '', 'nsplit': '', 'strwidthpart_reverse': '', 'unescape_pattern': '', 'levenshtein_distance': '', 'trim_start': '', 'justify_equal_spacing': '', 'nr2hex': '', 'iconv': '', 'pad_left': '', 'nr2enc_char': '', 'lines': '', 'repair_posix_text': '', 'nr2byte': '', 'trim': '', 'diffidx': '', 'truncate': '', 'split_by_displaywidth': '', '_vital_created': '', 'padding_by_displaywidth': '', 'hash': '', 'chomp': '', 'pad_between_letters': '', 'dstring': '', 'pad_both_sides': '', 'substitute_last': '', 'pad_right': '', 'remove_ansi_sequences': '', '_vital_loaded': ''}, \"function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") + delfunction s:_SID +endif +" ___vital___ +" Utilities for string. + +let s:save_cpo = &cpo +set cpo&vim + +function! s:_vital_loaded(V) abort + let s:V = a:V + let s:L = s:V.import('Data.List') +endfunction + +function! s:_vital_depends() abort + return ['Data.List'] +endfunction + +function! s:_vital_created(module) abort + " Expose script-local funcref + if exists('s:strchars') + let a:module.strchars = s:strchars + endif + if exists('s:wcswidth') + let a:module.wcswidth = s:wcswidth + endif +endfunction + +" Substitute a:from => a:to by string. +" To substitute by pattern, use substitute() instead. +function! s:replace(str, from, to) abort + return s:_replace(a:str, a:from, a:to, 'g') +endfunction + +" Substitute a:from => a:to only once. +" cf. s:replace() +function! s:replace_first(str, from, to) abort + return s:_replace(a:str, a:from, a:to, '') +endfunction + +" implement of replace() and replace_first() +function! s:_replace(str, from, to, flags) abort + return substitute(a:str, '\V'.escape(a:from, '\'), escape(a:to, '\'), a:flags) +endfunction + +function! s:scan(str, pattern) abort + let list = [] + call substitute(a:str, a:pattern, '\=add(list, submatch(0)) == [] ? "" : ""', 'g') + return list +endfunction + +function! s:reverse(str) abort + return join(reverse(split(a:str, '.\zs')), '') +endfunction + +function! s:starts_with(str, prefix) abort + return stridx(a:str, a:prefix) == 0 +endfunction + +function! s:ends_with(str, suffix) abort + let idx = strridx(a:str, a:suffix) + return 0 <= idx && idx + len(a:suffix) == len(a:str) +endfunction + +function! s:common_head(strs) abort + if empty(a:strs) + return '' + endif + let len = len(a:strs) + if len == 1 + return a:strs[0] + endif + let strs = len == 2 ? a:strs : sort(copy(a:strs)) + let pat = substitute(strs[0], '.', '\="[" . escape(submatch(0), "^\\") . "]"', 'g') + return pat ==# '' ? '' : matchstr(strs[-1], '\C^\%[' . pat . ']') +endfunction + +" Split to two elements of List. ([left, right]) +" e.g.: s:split3('neocomplcache', 'compl') returns ['neo', 'compl', 'cache'] +function! s:split_leftright(expr, pattern) abort + let [left, _, right] = s:split3(a:expr, a:pattern) + return [left, right] +endfunction + +function! s:split3(expr, pattern) abort + let ERROR = ['', '', ''] + if a:expr ==# '' || a:pattern ==# '' + return ERROR + endif + let begin = match(a:expr, a:pattern) + if begin is -1 + return ERROR + endif + let end = matchend(a:expr, a:pattern) + let left = begin <=# 0 ? '' : a:expr[: begin - 1] + let right = a:expr[end :] + return [left, a:expr[begin : end-1], right] +endfunction + +" Slices into strings determines the number of substrings. +" e.g.: s:nsplit("neo compl cache", 2, '\s') returns ['neo', 'compl cache'] +function! s:nsplit(expr, n, ...) abort + let pattern = get(a:000, 0, '\s') + let keepempty = get(a:000, 1, 1) + let ret = [] + let expr = a:expr + if a:n <= 1 + return [expr] + endif + while 1 + let pos = match(expr, pattern) + if pos == -1 + if expr !~ pattern || keepempty + call add(ret, expr) + endif + break + elseif pos >= 0 + let left = pos > 0 ? expr[:pos-1] : '' + if pos > 0 || keepempty + call add(ret, left) + endif + let ml = len(matchstr(expr, pattern)) + if pos == 0 && ml == 0 + let pos = 1 + endif + let expr = expr[pos+ml :] + endif + if len(expr) == 0 + break + endif + if len(ret) == a:n - 1 + call add(ret, expr) + break + endif + endwhile + return ret +endfunction + +" Returns the number of character in a:str. +" NOTE: This returns proper value +" even if a:str contains multibyte character(s). +" s:strchars(str) {{{ +if exists('*strchars') + let s:strchars = function('strchars') +else + function! s:strchars(str) abort + return strlen(substitute(copy(a:str), '.', 'x', 'g')) + endfunction +endif "}}} + +" Returns the bool of contains any multibyte character in s:str +function! s:contains_multibyte(str) abort "{{{ + return strlen(a:str) != s:strchars(a:str) +endfunction "}}} + +" Remove last character from a:str. +" NOTE: This returns proper value +" even if a:str contains multibyte character(s). +function! s:chop(str) abort "{{{ + return substitute(a:str, '.$', '', '') +endfunction "}}} + +" Remove last \r,\n,\r\n from a:str. +function! s:chomp(str) abort "{{{ + return substitute(a:str, '\%(\r\n\|[\r\n]\)$', '', '') +endfunction "}}} + +" wrap() and its internal functions +" * _split_by_wcswidth_once() +" * _split_by_wcswidth() +" * _concat() +" * wrap() +" +" NOTE _concat() is just a copy of Data.List.concat(). +" FIXME don't repeat yourself +function! s:_split_by_wcswidth_once(body, x) abort + let fst = s:strwidthpart(a:body, a:x) + let snd = s:strwidthpart_reverse(a:body, s:wcswidth(a:body) - s:wcswidth(fst)) + return [fst, snd] +endfunction + +function! s:_split_by_wcswidth(body, x) abort + let memo = [] + let body = a:body + while s:wcswidth(body) > a:x + let [tmp, body] = s:_split_by_wcswidth_once(body, a:x) + call add(memo, tmp) + endwhile + call add(memo, body) + return memo +endfunction + +function! s:trim(str) abort + return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') +endfunction + +function! s:trim_start(str) abort + return matchstr(a:str,'^\s*\zs.\{-}$') +endfunction + +function! s:trim_end(str) abort + return matchstr(a:str,'^.\{-}\ze\s*$') +endfunction + +function! s:wrap(str,...) abort + let _columns = a:0 > 0 ? a:1 : &columns + return s:L.concat( + \ map(split(a:str, '\r\n\|[\r\n]'), 's:_split_by_wcswidth(v:val, _columns - 1)')) +endfunction + +function! s:nr2byte(nr) abort + if a:nr < 0x80 + return nr2char(a:nr) + elseif a:nr < 0x800 + return nr2char(a:nr/64+192).nr2char(a:nr%64+128) + else + return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128) + endif +endfunction + +function! s:nr2enc_char(charcode) abort + if &encoding ==# 'utf-8' + return nr2char(a:charcode) + endif + let char = s:nr2byte(a:charcode) + if strlen(char) > 1 + let char = strtrans(iconv(char, 'utf-8', &encoding)) + endif + return char +endfunction + +function! s:nr2hex(nr) abort + let n = a:nr + let r = '' + while n + let r = '0123456789ABCDEF'[n % 16] . r + let n = n / 16 + endwhile + return r +endfunction + +" If a ==# b, returns -1. +" If a !=# b, returns first index of different character. +function! s:diffidx(a, b) abort + return a:a ==# a:b ? -1 : strlen(s:common_head([a:a, a:b])) +endfunction + +function! s:substitute_last(expr, pat, sub) abort + return substitute(a:expr, printf('.*\zs%s', a:pat), a:sub, '') +endfunction + +function! s:dstring(expr) abort + let x = substitute(string(a:expr), "^'\\|'$", '', 'g') + let x = substitute(x, "''", "'", 'g') + return printf('"%s"', escape(x, '"')) +endfunction + +function! s:lines(str) abort + return split(a:str, '\r\?\n') +endfunction + +function! s:_pad_with_char(str, left, right, char) abort + return repeat(a:char, a:left). a:str. repeat(a:char, a:right) +endfunction + +function! s:pad_left(str, width, ...) abort + let char = get(a:, 1, ' ') + if strdisplaywidth(char) != 1 + throw "vital: Data.String: Can't use non-half-width characters for padding." + endif + let left = max([0, a:width - strdisplaywidth(a:str)]) + return s:_pad_with_char(a:str, left, 0, char) +endfunction + +function! s:pad_right(str, width, ...) abort + let char = get(a:, 1, ' ') + if strdisplaywidth(char) != 1 + throw "vital: Data.String: Can't use non-half-width characters for padding." + endif + let right = max([0, a:width - strdisplaywidth(a:str)]) + return s:_pad_with_char(a:str, 0, right, char) +endfunction + +function! s:pad_both_sides(str, width, ...) abort + let char = get(a:, 1, ' ') + if strdisplaywidth(char) != 1 + throw "vital: Data.String: Can't use non-half-width characters for padding." + endif + let space = max([0, a:width - strdisplaywidth(a:str)]) + let left = space / 2 + let right = space - left + return s:_pad_with_char(a:str, left, right, char) +endfunction + +function! s:pad_between_letters(str, width, ...) abort + let char = get(a:, 1, ' ') + if strdisplaywidth(char) != 1 + throw "vital: Data.String: Can't use non-half-width characters for padding." + endif + let letters = split(a:str, '\zs') + let each_width = a:width / len(letters) + let str = join(map(letters, 's:pad_both_sides(v:val, each_width, char)'), '') + if a:width - strdisplaywidth(str) > 0 + return char. s:pad_both_sides(str, a:width - 1, char) + endif + return str +endfunction + +function! s:justify_equal_spacing(str, width, ...) abort + let char = get(a:, 1, ' ') + if strdisplaywidth(char) != 1 + throw "vital: Data.String: Can't use non-half-width characters for padding." + endif + let letters = split(a:str, '\zs') + let first_letter = letters[0] + " {width w/o the first letter} / {length w/o the first letter} + let each_width = (a:width - strdisplaywidth(first_letter)) / (len(letters) - 1) + let remainder = (a:width - strdisplaywidth(first_letter)) % (len(letters) - 1) + return first_letter. join(s:L.concat([ +\ map(letters[1:remainder], 's:pad_left(v:val, each_width + 1, char)'), +\ map(letters[remainder + 1:], 's:pad_left(v:val, each_width, char)') +\ ]), '') +endfunction + +function! s:levenshtein_distance(str1, str2) abort + let letters1 = split(a:str1, '\zs') + let letters2 = split(a:str2, '\zs') + let length1 = len(letters1) + let length2 = len(letters2) + let distances = map(range(1, length1 + 1), 'map(range(1, length2 + 1), ''0'')') + + for i1 in range(0, length1) + let distances[i1][0] = i1 + endfor + for i2 in range(0, length2) + let distances[0][i2] = i2 + endfor + + for i1 in range(1, length1) + for i2 in range(1, length2) + let cost = (letters1[i1 - 1] ==# letters2[i2 - 1]) ? 0 : 1 + + let distances[i1][i2] = min([ + \ distances[i1 - 1][i2 ] + 1, + \ distances[i1 ][i2 - 1] + 1, + \ distances[i1 - 1][i2 - 1] + cost, + \]) + endfor + endfor + + return distances[length1][length2] +endfunction + +function! s:padding_by_displaywidth(expr, width, float) abort + let padding_char = ' ' + let n = a:width - strdisplaywidth(a:expr) + if n <= 0 + let n = 0 + endif + if a:float < 0 + return a:expr . repeat(padding_char, n) + elseif 0 < a:float + return repeat(padding_char, n) . a:expr + else + if n % 2 is 0 + return repeat(padding_char, n / 2) . a:expr . repeat(padding_char, n / 2) + else + return repeat(padding_char, (n - 1) / 2) . a:expr . repeat(padding_char, (n - 1) / 2) . padding_char + endif + endif +endfunction + +function! s:split_by_displaywidth(expr, width, float, is_wrap) abort + if a:width is 0 + return [''] + endif + + let lines = [] + + let cs = split(a:expr, '\zs') + let cs_index = 0 + + let text = '' + while cs_index < len(cs) + if cs[cs_index] is# "\n" + let text = s:padding_by_displaywidth(text, a:width, a:float) + let lines += [text] + let text = '' + else + let w = strdisplaywidth(text . cs[cs_index]) + + if w < a:width + let text .= cs[cs_index] + elseif a:width < w + let text = s:padding_by_displaywidth(text, a:width, a:float) + else + let text .= cs[cs_index] + endif + + if a:width <= w + let lines += [text] + let text = '' + if a:is_wrap + if a:width < w + if a:width < strdisplaywidth(cs[cs_index]) + while get(cs, cs_index, "\n") isnot# "\n" + let cs_index += 1 + endwhile + continue + else + let text = cs[cs_index] + endif + endif + else + while get(cs, cs_index, "\n") isnot# "\n" + let cs_index += 1 + endwhile + continue + endif + endif + + endif + let cs_index += 1 + endwhile + + if !empty(text) + let lines += [ s:padding_by_displaywidth(text, a:width, a:float) ] + endif + + return lines +endfunction + +function! s:hash(str) abort + if exists('*sha256') + return sha256(a:str) + else + " This gives up sha256ing but just adds up char with index. + let sum = 0 + for i in range(len(a:str)) + let sum += char2nr(a:str[i]) * (i + 1) + endfor + + return printf('%x', sum) + endif +endfunction + +function! s:truncate(str, width) abort + " 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:truncate_skipping(str, max, footer_width, separator) abort + let width = s:wcswidth(a:str) + if width <= a:max + let ret = a:str + else + let header_width = a:max - s:wcswidth(a:separator) - a:footer_width + let ret = s:strwidthpart(a:str, header_width) . a:separator + \ . s:strwidthpart_reverse(a:str, a:footer_width) + endif + return s:truncate(ret, a:max) +endfunction + +function! s:strwidthpart(str, width) abort + let str = tr(a:str, "\t", ' ') + let vcol = a:width + 2 + return matchstr(str, '.*\%<' . (vcol < 0 ? 0 : vcol) . 'v') +endfunction + +function! s:strwidthpart_reverse(str, width) abort + let str = tr(a:str, "\t", ' ') + let vcol = s:wcswidth(str) - a:width + return matchstr(str, '\%>' . (vcol < 0 ? 0 : vcol) . 'v.*') +endfunction + +if v:version >= 703 + " Use builtin function. + let s:wcswidth = function('strwidth') +else + function! s:wcswidth(str) abort + if a:str =~# '^[\x00-\x7f]*$' + return strlen(a:str) + endif + 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) abort + 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 + +function! s:remove_ansi_sequences(text) abort + return substitute(a:text, '\e\[\%(\%(\d\+;\)*\d\+\)\?[mK]', '', 'g') +endfunction + +function! s:escape_pattern(str) abort + " escape characters for no-magic + return escape(a:str, '^$~.*[]\') +endfunction + +function! s:unescape_pattern(str) abort + " unescape characters for no-magic + return s:unescape(a:str, '^$~.*[]\') +endfunction + +function! s:unescape(str, chars) abort + let chars = map(split(a:chars, '\zs'), 'escape(v:val, ''^$~.*[]\'')') + return substitute(a:str, '\\\(' . join(chars, '\|') . '\)', '\1', 'g') +endfunction + +function! s:iconv(expr, from, to) abort + if a:from ==# '' || a:to ==# '' || a:from ==? a:to + return a:expr + endif + let result = iconv(a:expr, a:from, a:to) + return empty(result) ? a:expr : result +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- s +" plus a terminating " +" That's why {stdin} always ends with ideally. However, there are +" some programs which does not follow the POSIX rule and a Vim's way to join +" List into TEXT; join({text}, "\n"); does not add to the end of +" the last line. +" That's why add a trailing if it does not exist. +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +" :help split() +" NOTE: +" it does nothing if the text is a correct POSIX text +function! s:repair_posix_text(text, ...) abort + let newline = get(a:000, 0, "\n") + return a:text =~# '\n$' ? a:text : a:text . newline +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- s +" plus a terminating " +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +function! s:join_posix_lines(lines, ...) abort + let newline = get(a:000, 0, "\n") + return join(a:lines, newline) . newline +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- s +" plus a terminating " +" TEXT into List; split({text}, '\r\?\n', 1); add an extra empty line at the +" end of List because the end of TEXT ends with and keepempty=1 is +" specified. (btw. keepempty=0 cannot be used because it will remove +" emptylines in the head and the tail). +" That's why removing a trailing before proceeding to 'split' is required +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +function! s:split_posix_text(text, ...) abort + let newline = get(a:000, 0, '\r\?\n') + let text = substitute(a:text, newline . '$', '', '') + return split(text, newline, 1) +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Prelude.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Prelude.vim new file mode 100644 index 0000000..773c010 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Prelude.vim @@ -0,0 +1,430 @@ +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +if v:version > 703 || v:version == 703 && has('patch1170') + function! vital#_neocomplete#Prelude#import() abort + return map({'escape_pattern': '', 'is_funcref': '', 'path2directory': '', 'wcswidth': '', 'is_string': '', 'input_helper': '', 'is_number': '', 'is_cygwin': '', 'path2project_directory': '', 'strwidthpart_reverse': '', 'input_safe': '', 'is_list': '', 'truncate_skipping': '', 'glob': '', 'truncate': '', 'is_dict': '', 'set_default': '', 'is_numeric': '', 'getchar_safe': '', 'substitute_path_separator': '', 'is_mac': '', 'strwidthpart': '', 'getchar': '', 'is_unix': '', 'is_windows': '', 'globpath': '', 'escape_file_searching': '', 'is_float': '', 'smart_execute_command': ''}, 'function("s:" . v:key)') + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + execute join(['function! vital#_neocomplete#Prelude#import() abort', printf("return map({'escape_pattern': '', 'is_funcref': '', 'path2directory': '', 'wcswidth': '', 'is_string': '', 'input_helper': '', 'is_number': '', 'is_cygwin': '', 'path2project_directory': '', 'strwidthpart_reverse': '', 'input_safe': '', 'is_list': '', 'truncate_skipping': '', 'glob': '', 'truncate': '', 'is_dict': '', 'set_default': '', 'is_numeric': '', 'getchar_safe': '', 'substitute_path_separator': '', 'is_mac': '', 'strwidthpart': '', 'getchar': '', 'is_unix': '', 'is_windows': '', 'globpath': '', 'escape_file_searching': '', 'is_float': '', 'smart_execute_command': ''}, \"function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") + delfunction s:_SID +endif +" ___vital___ +let s:save_cpo = &cpo +set cpo&vim + +if v:version > 703 || +\ (v:version == 703 && has('patch465')) + function! s:glob(expr) abort + return glob(a:expr, 1, 1) + endfunction +else + function! s:glob(expr) abort + return split(glob(a:expr, 1), '\n') + endfunction +endif + +if v:version > 704 || +\ (v:version == 704 && has('patch279')) + function! s:globpath(path, expr) abort + return globpath(a:path, a:expr, 1, 1) + endfunction +else + function! s:globpath(path, expr) abort + return split(globpath(a:path, a:expr, 1), '\n') + endfunction +endif + +" Wrapper functions for type(). +" NOTE: __TYPE_FLOAT = -1 when -float. +" this doesn't match to anything. +if has('patch-7.4.2071') + let [ + \ s:__TYPE_NUMBER, + \ s:__TYPE_STRING, + \ s:__TYPE_FUNCREF, + \ s:__TYPE_LIST, + \ s:__TYPE_DICT, + \ s:__TYPE_FLOAT] = [ + \ v:t_number, + \ v:t_string, + \ v:t_func, + \ v:t_list, + \ v:t_dict, + \ v:t_float] +else + let [ + \ s:__TYPE_NUMBER, + \ s:__TYPE_STRING, + \ s:__TYPE_FUNCREF, + \ s:__TYPE_LIST, + \ s:__TYPE_DICT, + \ s:__TYPE_FLOAT] = [ + \ type(3), + \ type(''), + \ type(function('tr')), + \ type([]), + \ type({}), + \ has('float') ? type(str2float('0')) : -1] +endif + +" Number or Float +function! s:is_numeric(Value) abort + let _ = type(a:Value) + return _ ==# s:__TYPE_NUMBER + \ || _ ==# s:__TYPE_FLOAT +endfunction + +" Number +function! s:is_number(Value) abort + return type(a:Value) ==# s:__TYPE_NUMBER +endfunction + +" String +function! s:is_string(Value) abort + return type(a:Value) ==# s:__TYPE_STRING +endfunction + +" Funcref +function! s:is_funcref(Value) abort + return type(a:Value) ==# s:__TYPE_FUNCREF +endfunction + +" List +function! s:is_list(Value) abort + return type(a:Value) ==# s:__TYPE_LIST +endfunction + +" Dictionary +function! s:is_dict(Value) abort + return type(a:Value) ==# s:__TYPE_DICT +endfunction + +" Float +function! s:is_float(Value) abort + return type(a:Value) ==# s:__TYPE_FLOAT +endfunction + + +function! s:truncate_skipping(str, max, footer_width, separator) abort + call s:_warn_deprecated('truncate_skipping', 'Data.String.truncate_skipping') + + let width = s:wcswidth(a:str) + if width <= a:max + let ret = a:str + else + let header_width = a:max - s:wcswidth(a:separator) - a:footer_width + let ret = s:strwidthpart(a:str, header_width) . a:separator + \ . s:strwidthpart_reverse(a:str, a:footer_width) + endif + + return s:truncate(ret, a:max) +endfunction + +function! s:truncate(str, width) abort + " Original function is from mattn. + " http://github.com/mattn/googlereader-vim/tree/master + + call s:_warn_deprecated('truncate', 'Data.String.truncate') + + 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) abort + call s:_warn_deprecated('strwidthpart', 'Data.String.strwidthpart') + + if a:width <= 0 + return '' + endif + 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:wcswidth(char) + endwhile + + return ret +endfunction +function! s:strwidthpart_reverse(str, width) abort + call s:_warn_deprecated('strwidthpart_reverse', 'Data.String.strwidthpart_reverse') + + if a:width <= 0 + return '' + endif + let ret = a:str + let width = s:wcswidth(a:str) + while width > a:width + let char = matchstr(ret, '^.') + let ret = ret[len(char) :] + let width -= s:wcswidth(char) + endwhile + + return ret +endfunction + +if v:version >= 703 + " Use builtin function. + function! s:wcswidth(str) abort + call s:_warn_deprecated('wcswidth', 'Data.String.wcswidth') + return strwidth(a:str) + endfunction +else + function! s:wcswidth(str) abort + call s:_warn_deprecated('wcswidth', 'Data.String.wcswidth') + + 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) abort + 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 + +let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95') +let s:is_cygwin = has('win32unix') +let s:is_mac = !s:is_windows && !s:is_cygwin + \ && (has('mac') || has('macunix') || has('gui_macvim') || + \ (!isdirectory('/proc') && executable('sw_vers'))) +let s:is_unix = has('unix') + +function! s:is_windows() abort + return s:is_windows +endfunction + +function! s:is_cygwin() abort + return s:is_cygwin +endfunction + +function! s:is_mac() abort + return s:is_mac +endfunction + +function! s:is_unix() abort + return s:is_unix +endfunction + +function! s:_warn_deprecated(name, alternative) abort + try + echohl Error + echomsg 'Prelude.' . a:name . ' is deprecated! Please use ' . a:alternative . ' instead.' + finally + echohl None + endtry +endfunction + +function! s:smart_execute_command(action, word) abort + execute a:action . ' ' . (a:word ==# '' ? '' : '`=a:word`') +endfunction + +function! s:escape_file_searching(buffer_name) abort + return escape(a:buffer_name, '*[]?{}, ') +endfunction + +function! s:escape_pattern(str) abort + call s:_warn_deprecated( + \ 'escape_pattern', + \ 'Data.String.escape_pattern', + \) + return escape(a:str, '~"\.^$[]*') +endfunction + +function! s:getchar(...) abort + let c = call('getchar', a:000) + return type(c) == type(0) ? nr2char(c) : c +endfunction + +function! s:getchar_safe(...) abort + let c = s:input_helper('getchar', a:000) + return type(c) == type('') ? c : nr2char(c) +endfunction + +function! s:input_safe(...) abort + return s:input_helper('input', a:000) +endfunction + +function! s:input_helper(funcname, args) abort + let success = 0 + if inputsave() !=# success + throw 'vital: Prelude: inputsave() failed' + endif + try + return call(a:funcname, a:args) + finally + if inputrestore() !=# success + throw 'vital: Prelude: inputrestore() failed' + endif + endtry +endfunction + +function! s:set_default(var, val) abort + if !exists(a:var) || type({a:var}) != type(a:val) + let {a:var} = a:val + endif +endfunction + +function! s:substitute_path_separator(path) abort + return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path +endfunction + +function! s:path2directory(path) abort + return s:substitute_path_separator(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':p:h')) +endfunction + +function! s:_path2project_directory_git(path) abort + let parent = a:path + + while 1 + let path = parent . '/.git' + if isdirectory(path) || filereadable(path) + return parent + endif + let next = fnamemodify(parent, ':h') + if next == parent + return '' + endif + let parent = next + endwhile +endfunction + +function! s:_path2project_directory_svn(path) abort + let search_directory = a:path + let directory = '' + + let find_directory = s:escape_file_searching(search_directory) + let d = finddir('.svn', find_directory . ';') + if d ==# '' + return '' + endif + + let directory = fnamemodify(d, ':p:h:h') + + " Search parent directories. + let parent_directory = s:path2directory( + \ fnamemodify(directory, ':h')) + + if parent_directory !=# '' + let d = finddir('.svn', parent_directory . ';') + if d !=# '' + let directory = s:_path2project_directory_svn(parent_directory) + endif + endif + return directory +endfunction + +function! s:_path2project_directory_others(vcs, path) abort + let vcs = a:vcs + let search_directory = a:path + + let find_directory = s:escape_file_searching(search_directory) + let d = finddir(vcs, find_directory . ';') + if d ==# '' + return '' + endif + return fnamemodify(d, ':p:h:h') +endfunction + +function! s:path2project_directory(path, ...) abort + let is_allow_empty = get(a:000, 0, 0) + let search_directory = s:path2directory(a:path) + let directory = '' + + " Search VCS directory. + for vcs in ['.git', '.bzr', '.hg', '.svn'] + if vcs ==# '.git' + let directory = s:_path2project_directory_git(search_directory) + elseif vcs ==# '.svn' + let directory = s:_path2project_directory_svn(search_directory) + else + let directory = s:_path2project_directory_others(vcs, search_directory) + endif + if directory !=# '' + break + endif + endfor + + " Search project file. + if directory ==# '' + for d in ['build.xml', 'prj.el', '.project', 'pom.xml', 'package.json', + \ 'Makefile', 'configure', 'Rakefile', 'NAnt.build', + \ 'P4CONFIG', 'tags', 'gtags'] + let d = findfile(d, s:escape_file_searching(search_directory) . ';') + if d !=# '' + let directory = fnamemodify(d, ':p:h') + break + endif + endfor + endif + + if directory ==# '' + " Search /src/ directory. + let base = s:substitute_path_separator(search_directory) + if base =~# '/src/' + let directory = base[: strridx(base, '/src/') + 3] + endif + endif + + if directory ==# '' && !is_allow_empty + " Use original path. + let directory = search_directory + endif + + return s:substitute_path_separator(directory) +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Process.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Process.vim new file mode 100644 index 0000000..47f54c2 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/Process.vim @@ -0,0 +1,181 @@ +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +if v:version > 703 || v:version == 703 && has('patch1170') + function! vital#_neocomplete#Process#import() abort + return map({'shellescape': '', 'has_vimproc': '', 'system': '', 'iconv': '', 'spawn': '', 'get_last_status': ''}, 'function("s:" . v:key)') + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + execute join(['function! vital#_neocomplete#Process#import() abort', printf("return map({'shellescape': '', 'has_vimproc': '', 'system': '', 'iconv': '', 'spawn': '', 'get_last_status': ''}, \"function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") + delfunction s:_SID +endif +" ___vital___ +" TODO: move all comments to doc file. +" +" +" FIXME: This module name should be Vital.System ? +" But the name has been already taken. + +let s:save_cpo = &cpo +set cpo&vim + + +" FIXME: Unfortunately, can't use s:_vital_loaded() for this purpose. +" Because these variables are used when this script file is loaded. +let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95') +let s:is_unix = has('unix') +" As of 7.4.122, the system()'s 1st argument is converted internally by Vim. +" Note that Patch 7.4.122 does not convert system()'s 2nd argument and +" return-value. We must convert them manually. +let s:need_trans = v:version < 704 || (v:version == 704 && !has('patch122')) + +let s:TYPE_DICT = type({}) +let s:TYPE_LIST = type([]) +let s:TYPE_STRING = type('') + +function! s:spawn(expr, ...) abort + let shellslash = 0 + if s:is_windows + let shellslash = &l:shellslash + setlocal noshellslash + endif + try + if type(a:expr) is s:TYPE_LIST + let special = 1 + let cmdline = join(map(a:expr, 'shellescape(v:val, special)'), ' ') + elseif type(a:expr) is s:TYPE_STRING + let cmdline = a:expr + if a:0 && a:1 + " for :! command + let cmdline = substitute(cmdline, '\([!%#]\|<[^<>]\+>\)', '\\\1', 'g') + endif + else + throw 'Process.spawn(): invalid argument (value type:'.type(a:expr).')' + endif + if s:is_windows + silent execute '!start' cmdline + else + silent execute '!' cmdline '&' + endif + finally + if s:is_windows + let &l:shellslash = shellslash + endif + endtry + return '' +endfunction + +" iconv() wrapper for safety. +function! s:iconv(expr, from, to) abort + 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 + +" Check vimproc. +function! s:has_vimproc() abort + if !exists('s:exists_vimproc') + try + call vimproc#version() + let s:exists_vimproc = 1 + catch + let s:exists_vimproc = 0 + endtry + endif + return s:exists_vimproc +endfunction + +" * {command} [, {input} [, {timeout}]] +" * {command} [, {dict}] +" {dict} = { +" use_vimproc: bool, +" input: string, +" timeout: bool, +" background: bool, +" } +function! s:system(str, ...) abort + " Process optional arguments at first + " because use_vimproc is required later + " for a:str argument. + let input = '' + let use_vimproc = s:has_vimproc() + let background = 0 + let args = [] + if a:0 ==# 1 + " {command} [, {dict}] + " a:1 = {dict} + if type(a:1) is s:TYPE_DICT + if has_key(a:1, 'use_vimproc') + let use_vimproc = a:1.use_vimproc + endif + if has_key(a:1, 'input') + let args += [s:iconv(a:1.input, &encoding, 'char')] + endif + if use_vimproc && has_key(a:1, 'timeout') + " ignores timeout unless you have vimproc. + let args += [a:1.timeout] + endif + if has_key(a:1, 'background') + let background = a:1.background + endif + elseif type(a:1) is s:TYPE_STRING + let args += [s:iconv(a:1, &encoding, 'char')] + else + throw 'Process.system(): invalid argument (value type:'.type(a:1).')' + endif + elseif a:0 >= 2 + " {command} [, {input} [, {timeout}]] + " a:000 = [{input} [, {timeout}]] + let [input; rest] = a:000 + let input = s:iconv(input, &encoding, 'char') + let args += [input] + rest + endif + + " Process a:str argument. + if type(a:str) is s:TYPE_LIST + let expr = use_vimproc ? '"''" . v:val . "''"' : 's:shellescape(v:val)' + let command = join(map(copy(a:str), expr), ' ') + elseif type(a:str) is s:TYPE_STRING + let command = a:str + else + throw 'Process.system(): invalid argument (value type:'.type(a:str).')' + endif + if s:need_trans + let command = s:iconv(command, &encoding, 'char') + endif + let args = [command] + args + if background && (use_vimproc || !s:is_windows) + let args[0] = args[0] . ' &' + endif + + let funcname = use_vimproc ? 'vimproc#system' : 'system' + let output = call(funcname, args) + let output = s:iconv(output, 'char', &encoding) + return output +endfunction + +function! s:get_last_status() abort + return s:has_vimproc() ? + \ vimproc#get_last_status() : v:shell_error +endfunction + +if s:is_windows + function! s:shellescape(command) abort + return substitute(a:command, '[&()[\]{}^=;!''+,`~]', '^\0', 'g') + endfunction +else + function! s:shellescape(...) abort + return call('shellescape', a:000) + endfunction +endif + + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/System/Cache/Deprecated.vim b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/System/Cache/Deprecated.vim new file mode 100644 index 0000000..d81d6fe --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/_neocomplete/System/Cache/Deprecated.vim @@ -0,0 +1,101 @@ +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +if v:version > 703 || v:version == 703 && has('patch1170') + function! vital#_neocomplete#System#Cache#Deprecated#import() abort + return map({'filereadable': '', '_vital_depends': '', 'delete': '', 'readfile': '', 'getfilename': '', 'deletefile': '', 'check_old_cache': '', 'writefile': '', '_vital_loaded': ''}, 'function("s:" . v:key)') + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + execute join(['function! vital#_neocomplete#System#Cache#Deprecated#import() abort', printf("return map({'filereadable': '', '_vital_depends': '', 'delete': '', 'readfile': '', 'getfilename': '', 'deletefile': '', 'check_old_cache': '', 'writefile': '', '_vital_loaded': ''}, \"function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") + delfunction s:_SID +endif +" ___vital___ +" Note: +" This module is deprecated. Use a new `Syste.Cache` instead. + +let s:save_cpo = &cpo +set cpo&vim + +function! s:_vital_loaded(V) abort + let s:V = a:V + let s:S = s:V.import('Data.String') +endfunction + +function! s:_vital_depends() abort + return ['Data.String'] +endfunction + +function! s:getfilename(cache_dir, filename) abort + return s:_encode_name(a:cache_dir, a:filename) +endfunction + +function! s:filereadable(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return filereadable(cache_name) +endfunction + +function! s:readfile(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return filereadable(cache_name) ? readfile(cache_name) : [] +endfunction + +function! s:writefile(cache_dir, filename, list) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + + call writefile(a:list, cache_name) +endfunction + +function! s:delete(cache_dir, filename) abort + echoerr 'System.Cache.delete() is obsolete. Use its deletefile() instead.' + return call('s:deletefile', a:cache_dir, a:filename) +endfunction + +function! s:deletefile(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return delete(cache_name) +endfunction + +function! s:_encode_name(cache_dir, filename) abort + " Check cache directory. + if !isdirectory(a:cache_dir) + call mkdir(a:cache_dir, 'p') + endif + let cache_dir = a:cache_dir + if cache_dir !~# '/$' + let cache_dir .= '/' + endif + + return cache_dir . s:_create_hash(cache_dir, a:filename) +endfunction + +function! s:check_old_cache(cache_dir, filename) abort + " Check old cache file. + let cache_name = s:_encode_name(a:cache_dir, a:filename) + let ret = getftime(cache_name) == -1 + \ || getftime(cache_name) <= getftime(a:filename) + if ret && filereadable(cache_name) + " Delete old cache. + call delete(cache_name) + endif + + return ret +endfunction + +function! s:_create_hash(dir, str) abort + if len(a:dir) + len(a:str) < 150 + let hash = substitute(substitute( + \ a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g') + else + let hash = s:S.hash(a:str) + endif + + return hash +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vim b/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vim new file mode 100644 index 0000000..d428cc2 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vim @@ -0,0 +1,339 @@ +let s:plugin_name = expand(':t:r') +let s:vital_base_dir = expand(':h') +let s:project_root = expand(':h:h:h') +let s:is_vital_vim = s:plugin_name is# 'vital' + +let s:loaded = {} +let s:cache_sid = {} + +" function() wrapper +if v:version > 703 || v:version == 703 && has('patch1170') + function! s:_function(fstr) abort + return function(a:fstr) + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction +endif + +function! vital#{s:plugin_name}#new() abort + return s:new(s:plugin_name) +endfunction + +function! vital#{s:plugin_name}#import(...) abort + if !exists('s:V') + let s:V = s:new(s:plugin_name) + endif + return call(s:V.import, a:000, s:V) +endfunction + +let s:Vital = {} + +function! s:new(plugin_name) abort + let base = deepcopy(s:Vital) + let base._plugin_name = a:plugin_name + return base +endfunction + +function! s:vital_files() abort + if !exists('s:vital_files') + let s:vital_files = map( + \ s:is_vital_vim ? s:_global_vital_files() : s:_self_vital_files(), + \ 'fnamemodify(v:val, ":p:gs?[\\\\/]?/?")') + endif + return copy(s:vital_files) +endfunction +let s:Vital.vital_files = s:_function('s:vital_files') + +function! s:import(name, ...) abort dict + let target = {} + let functions = [] + for a in a:000 + if type(a) == type({}) + let target = a + elseif type(a) == type([]) + let functions = a + endif + unlet a + endfor + let module = self._import(a:name) + if empty(functions) + call extend(target, module, 'keep') + else + for f in functions + if has_key(module, f) && !has_key(target, f) + let target[f] = module[f] + endif + endfor + endif + return target +endfunction +let s:Vital.import = s:_function('s:import') + +function! s:load(...) abort dict + for arg in a:000 + let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg] + let target = split(join(as, ''), '\W\+') + let dict = self + let dict_type = type({}) + while !empty(target) + let ns = remove(target, 0) + if !has_key(dict, ns) + let dict[ns] = {} + endif + if type(dict[ns]) == dict_type + let dict = dict[ns] + else + unlet dict + break + endif + endwhile + if exists('dict') + call extend(dict, self._import(name)) + endif + unlet arg + endfor + return self +endfunction +let s:Vital.load = s:_function('s:load') + +function! s:unload() abort dict + let s:loaded = {} + let s:cache_sid = {} + unlet! s:vital_files +endfunction +let s:Vital.unload = s:_function('s:unload') + +function! s:exists(name) abort dict + if a:name !~# '\v^\u\w*%(\.\u\w*)*$' + throw 'vital: Invalid module name: ' . a:name + endif + return s:_module_path(a:name) isnot# '' +endfunction +let s:Vital.exists = s:_function('s:exists') + +function! s:search(pattern) abort dict + let paths = s:_extract_files(a:pattern, self.vital_files()) + let modules = sort(map(paths, 's:_file2module(v:val)')) + return s:_uniq(modules) +endfunction +let s:Vital.search = s:_function('s:search') + +function! s:plugin_name() abort dict + return self._plugin_name +endfunction +let s:Vital.plugin_name = s:_function('s:plugin_name') + +function! s:_self_vital_files() abort + let builtin = printf('%s/__%s__/', s:vital_base_dir, s:plugin_name) + let installed = printf('%s/_%s/', s:vital_base_dir, s:plugin_name) + let base = builtin . ',' . installed + return split(globpath(base, '**/*.vim', 1), "\n") +endfunction + +function! s:_global_vital_files() abort + let pattern = 'autoload/vital/__*__/**/*.vim' + return split(globpath(&runtimepath, pattern, 1), "\n") +endfunction + +function! s:_extract_files(pattern, files) abort + let tr = {'.': '/', '*': '[^/]*', '**': '.*'} + let target = substitute(a:pattern, '\.\|\*\*\?', '\=tr[submatch(0)]', 'g') + let regexp = printf('autoload/vital/[^/]\+/%s.vim$', target) + return filter(a:files, 'v:val =~# regexp') +endfunction + +function! s:_file2module(file) abort + let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?') + let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$') + return join(split(tail, '[\\/]\+'), '.') +endfunction + +" @param {string} name e.g. Data.List +function! s:_import(name) abort dict + if has_key(s:loaded, a:name) + return copy(s:loaded[a:name]) + endif + let module = self._get_module(a:name) + if has_key(module, '_vital_created') + call module._vital_created(module) + endif + let export_module = filter(copy(module), 'v:key =~# "^\\a"') + " Cache module before calling module.vital_loaded() to avoid cyclic + " dependences but remove the cache if module._vital_loaded() fails. + " let s:loaded[a:name] = export_module + let s:loaded[a:name] = export_module + if has_key(module, '_vital_loaded') + try + call module._vital_loaded(vital#{s:plugin_name}#new()) + catch + unlet s:loaded[a:name] + throw 'vital: fail to call ._vital_loaded(): ' . v:exception + endtry + endif + return copy(s:loaded[a:name]) +endfunction +let s:Vital._import = s:_function('s:_import') + +" s:_get_module() returns module object wihch has all script local functions. +function! s:_get_module(name) abort dict + let funcname = s:_import_func_name(self.plugin_name(), a:name) + if s:_exists_autoload_func_with_source(funcname) + return call(funcname, []) + else + return s:_get_builtin_module(a:name) + endif +endfunction + +function! s:_get_builtin_module(name) abort + return s:sid2sfuncs(s:_module_sid(a:name)) +endfunction + +if s:is_vital_vim + " For vital.vim, we can use s:_get_builtin_module directly + let s:Vital._get_module = s:_function('s:_get_builtin_module') +else + let s:Vital._get_module = s:_function('s:_get_module') +endif + +function! s:_import_func_name(plugin_name, module_name) abort + return printf('vital#_%s#%s#import', a:plugin_name, s:_dot_to_sharp(a:module_name)) +endfunction + +function! s:_module_sid(name) abort + let path = s:_module_path(a:name) + if !filereadable(path) + throw 'vital: module not found: ' . a:name + endif + let vital_dir = s:is_vital_vim ? '__\w\+__' : printf('_\{1,2}%s\%%(__\)\?', s:plugin_name) + let base = join([vital_dir, ''], '[/\\]\+') + let p = base . substitute('' . a:name, '\.', '[/\\\\]\\+', 'g') + let sid = s:_sid(path, p) + if !sid + call s:_source(path) + let sid = s:_sid(path, p) + if !sid + throw printf('vital: cannot get from path: %s', path) + endif + endif + return sid +endfunction + +function! s:_module_path(name) abort + return get(s:_extract_files(a:name, s:vital_files()), 0, '') +endfunction + +function! s:_module_sid_base_dir() abort + return s:is_vital_vim ? &rtp : s:project_root +endfunction + +function! s:_dot_to_sharp(name) abort + return substitute(a:name, '\.', '#', 'g') +endfunction + +" It will sources autoload file if a given func is not already defined. +function! s:_exists_autoload_func_with_source(funcname) abort + if exists('*' . a:funcname) + " Return true if a given func is already defined + return 1 + endif + " source a file which may include a given func definition and try again. + let path = 'autoload/' . substitute(substitute(a:funcname, '#[^#]*$', '.vim', ''), '#', '/', 'g') + call s:_runtime(path) + return exists('*' . a:funcname) +endfunction + +function! s:_runtime(path) abort + execute 'runtime' fnameescape(a:path) +endfunction + +function! s:_source(path) abort + execute 'source' fnameescape(a:path) +endfunction + +" @vimlint(EVL102, 1, l:_) +" @vimlint(EVL102, 1, l:__) +function! s:_sid(path, filter_pattern) abort + let unified_path = s:_unify_path(a:path) + if has_key(s:cache_sid, unified_path) + return s:cache_sid[unified_path] + endif + for line in filter(split(s:_redir(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern') + let [_, sid, path; __] = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$') + if s:_unify_path(path) is# unified_path + let s:cache_sid[unified_path] = sid + return s:cache_sid[unified_path] + endif + endfor + return 0 +endfunction + +function! s:_redir(cmd) abort + let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] + set verbose=0 verbosefile= + redir => res + silent! execute a:cmd + redir END + let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] + return res +endfunction + +if filereadable(expand(':r') . '.VIM') " is case-insensitive or not + let s:_unify_path_cache = {} + " resolve() is slow, so we cache results. + " Note: On windows, vim can't expand path names from 8.3 formats. + " So if getting full path via and $HOME was set as 8.3 format, + " vital load duplicated scripts. Below's :~ avoid this issue. + function! s:_unify_path(path) abort + if has_key(s:_unify_path_cache, a:path) + return s:_unify_path_cache[a:path] + endif + let value = tolower(fnamemodify(resolve(fnamemodify( + \ a:path, ':p')), ':~:gs?[\\/]?/?')) + let s:_unify_path_cache[a:path] = value + return value + endfunction +else + function! s:_unify_path(path) abort + return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?')) + endfunction +endif + +" copied and modified from Vim.ScriptLocal +let s:SNR = join(map(range(len("\")), '"[\\x" . printf("%0x", char2nr("\"[v:val])) . "]"'), '') +function! s:sid2sfuncs(sid) abort + let fs = split(s:_redir(printf(':function /^%s%s_', s:SNR, a:sid)), "\n") + let r = {} + let pattern = printf('\m^function\s%d_\zs\w\{-}\ze(', a:sid) + for fname in map(fs, 'matchstr(v:val, pattern)') + let r[fname] = function(s:_sfuncname(a:sid, fname)) + endfor + return r +endfunction + +"" Return funcname of script local functions with SID +function! s:_sfuncname(sid, funcname) abort + return printf('%s_%s', a:sid, a:funcname) +endfunction + +if exists('*uniq') + function! s:_uniq(list) abort + return uniq(a:list) + endfunction +else + function! s:_uniq(list) abort + let i = len(a:list) - 1 + while 0 < i + if a:list[i] ==# a:list[i - 1] + call remove(a:list, i) + endif + let i -= 1 + endwhile + return a:list + endfunction +endif diff --git a/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vital b/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vital new file mode 100644 index 0000000..55fa256 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/autoload/vital/neocomplete.vital @@ -0,0 +1,8 @@ +neocomplete +645fe7142afdf5ef90e07cd275a15657c3328f53 + +Prelude +Data.List +Data.String +Process +System.Cache.Deprecated diff --git a/pack/acp/start/neocomplete.vim/doc/neocomplete.txt b/pack/acp/start/neocomplete.vim/doc/neocomplete.txt new file mode 100644 index 0000000..5868d8d --- /dev/null +++ b/pack/acp/start/neocomplete.vim/doc/neocomplete.txt @@ -0,0 +1,1861 @@ +*neocomplete.txt* Next generation of auto completion framework. + +Version: 2.2 +Author: Shougo +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. +}}} + +CONTENTS *neocomplete-contents* + +Introduction |neocomplete-introduction| +Install |neocomplete-install| +Interface |neocomplete-interface| + Commands |neocomplete-commands| + Variables |neocomplete-variables| + Sources variables |neocomplete-sources-variables| + Key mappings |neocomplete-key-mappings| + Functions |neocomplete-functions| +Examples |neocomplete-examples| +Sources |neocomplete-sources| + User sources |neocomplete-user-sources| +Create source |neocomplete-create-source| + Source attributes |neocomplete-source-attributes| + Candidate attributes |neocomplete-candidate-attributes| +Create filter |neocomplete-create-filter| + Filter attributes |neocomplete-filter-attributes| +FILTERS |neocomplete-filters| +External sources |neocomplete-external-sources| +FAQ |neocomplete-faq| + +============================================================================== +INTRODUCTION *neocomplete-introduction* + +*neocomplete* is the next generation auto completion framework and a superior +successor of the |neocomplcache| plugin. It provides a keyword completion +system by maintaining a keyword cache of the current buffer. The neocomplete +framework can be customized easily and has a lot more features than Vim's +standard completion. + +Note: neocomplete may consume more memory than other plugins do. + +Improvements in neocomplete in comparison to |neocomplcache|: + +1. Real fuzzy match behavior like |YouCompleteMe| by default. +2. Refactored source interface. +3. Removed legacy interface. +4. Requires |if_lua|. +5. Optimized completion speed. +6. Changed source names. +7. Changed variable names. +8. Added new features. + +============================================================================== +INSTALL *neocomplete-install* + +Install prerequisites + +In order to use neocomplete, the following prerequisites have to be met: + +1. Vim build with the |if_lua| feature +2. Vim version 7.3.885 or above + +The following sections describe where to get a Vim version, neocomplete +works with, for your operating system. + +On Windows: + +github release https://github.com/vim/vim-win32-installer/releases +For 32bit http://files.kaoriya.net/goto/vim73w32 +For 32bit (alternative) http://tuxproject.de/projects/vim/ + http://wyw.dcweb.cn/#download +For 64bit http://files.kaoriya.net/goto/vim73w64 + +On Mac: + +You can get |if_lua| enabled MacVim versions here: + +https://github.com/zhaocai/macvim +http://code.google.com/p/macvim-kaoriya/ + +Or install it with homebrew: +> + brew install macvim --with-cscope --with-lua --HEAD +< + +On Linux: + +As almost all Vim packages offered by distributions are too old, you should +build Vim manually using gnu make and enable |if_lua| in the configuration +step. The following steps show you the general process on how to build Vim: + +1. Get the source package +2. Unpack the sources +3. Configure the package (./configure). This step is essential to enable + the Vim features you like to use. +4. Build the package with gnu make +5. Install the package using your distributions package manager + +You can find detailed information on ho to configure and build Vim from source +under following link: http://vim.wikia.com/wiki/Building_Vim. Or follow the +guide on: +https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source + +Install the plugin + +After you have installed the right version of Vim, you can go on to install +the neocomplete plugin. You can do this in a more old fashioned, manual way +or use a plugin manager like pathogen, vundle, neobundle. The second approach +is the recommended installation method. + +Manual: + +1. Get the plugin package +2. Extract the files and put them in your Vim directory + (usually ~/.vim/ or Program Files/Vim/vimfiles on Windows). +3. Execute |:NeoCompleteEnable| command or set following variable in your vimrc > + let g:neocomplete#enable_at_startup = 1 + +Package manager: + +For instructions on how to set up a Vim package manager see the documentation +of the package manager of your choice. For example after installing +neobundle you can install the neocomplete plugin with the following steps: + +1. Let the plugin manger know about the package (.vimrc) > + NeoBundle 'Shougo/neocomplete.vim' +< +2. Install the plugin with the install command > + :NeoBundleInstall +< + + *neocomplete-migration* + +In case you are planing to move from neocomplcache to neocomplete there is a +wiki page that offers a migration guide. +https://github.com/Shougo/neocomplete.vim/wiki/neocomplete-migration-guide + + *neocomplete-RECOMMENDATION* + + *neocomplete-asynchronous* + +If you have installed the |vimproc| plugin, neocomplete creates the caches +asynchronously. You can find vimproc at: http://github.com/Shougo/vimproc. +The vimproc plugin needs compilation before you can use it. You can find +further information in the vimproc documentation. + + *neocomplete-snippets* + +If you would like to use the snippet feature with neocomplete, you need to +install the neosnippet plugin (https://github.com/Shougo/neosnippet.vim) or +UltiSnips (https://github.com/SirVer/ultisnips). + + *neocomplete-context-filetype* + +If you would like to use the context filetype feature, you need to install the +context_filetype.vim plugin which you can find under the following repository: +https://github.com/Shougo/context_filetype.vim + + *neocomplete-include* + +If you want to complete the candidates from include files or include files +candidates, you need to install the neoinclude plugin +(https://github.com/Shougo/neoinclude.vim). + + *neocomplete-syntax* + +If you want to complete the candidates from syntax files, you need to install +the neco-syntax plugin (https://github.com/Shougo/neco-syntax). + + *neocomplete-neopairs* + +If you want to insert the parentheses pairs automatically, you need to install +the neopairs plugin (https://github.com/Shougo/neopairs.vim). + +============================================================================== +INTERFACE *neocomplete-interface* + +------------------------------------------------------------------------------ +COMMANDS *neocomplete-commands* + +:NeoCompleteEnable *:NeoCompleteEnable* + Validate neocomplete and initialize it. + Warning: Existing cache disappears. + +:NeoCompleteDisable *:NeoCompleteDisable* + Invalidate neocomplete and clean it up. + +:NeoCompleteToggle *:NeoCompleteToggle* + Change the lock/unlock state of neocomplete. + While neocomplete is in locking, you cannot use automatic + completions. + Note: This command also enables neocomplete if it is disabled. + +:NeoCompleteLock *:NeoCompleteLock* + Lock neocomplete. + While neocomplete is in locking, you cannot use automatic + completions but can use manual completions. + The lock status is local to each buffer. + Note: This command is disabled when neocomplete is disabled. + +:NeoCompleteUnlock *:NeoCompleteUnlock* + Unlock neocomplete. + Note: This command is disabled when neocomplete is disabled. + + *:NeoCompleteAutoCompletionLength* +:NeoCompleteAutoCompletionLength {length} + Change the length of chars to start automatic completion to + {length}. + Note: The length value is local to each buffer. + +:NeoCompleteClean *:NeoCompleteClean* + Clean files in |g:neocomplete#data_directory|. + +:NeoCompleteSetFileType [filetype] *:NeoCompleteSetFileType* + Change the filetype to [filetype] in the current buffer. + This filetype is only used by neocomplete, so syntax + highlighting and etc stay same. + + Note: You can get the current filetype by + |neocomplete#get_context_filetype()| + + +SOURCES COMMANDS *neocomplete-sources-COMMANDS* + +:NeoCompleteBufferMakeCache [bufname] *:NeoCompleteBufferMakeCache* + Make a cache based on the buffer with the name [bufname]. + The command selects the current buffer when you omit + [bufname]. + If [bufname] is not loaded, neocomplete will open + [bufname] automatically. + Note: It may take time considerably for the big buffer. + + *:NeoCompleteDictionaryMakeCache* +:NeoCompleteDictionaryMakeCache [filetype] + Make a cache from a dictionary file with [filetype]. + Selects the filetype of the current buffer if [filetype] is + omitted. + +:NeoCompleteTagMakeCache *:NeoCompleteTagMakeCache* + Make a cache from a tags file in current buffer. + +:NeoCompleteMemberMakeCache *:NeoCompleteMemberMakeCache* + Make a member cache based in current buffer. + +------------------------------------------------------------------------------ +VARIABLES *neocomplete-variables* + + *g:neocomplete#enable_at_startup* +g:neocomplete#enable_at_startup + neocomplete gets started automatically when Vim starts if + this value is 1. + + With the default value 0, you cannot use neocomplete + unless you start it manually. + + Note: This option has to be set in your .vimrc or _vimrc. + NOT IN the .gvimrc nor _gvimrc! + +g:neocomplete#max_list *g:neocomplete#max_list* + This variable controls the number of candidates displayed in a + pop-up menu. If the list of candidates exceeds the limit, not + all candidates will show up. + + Default value is 100. + + *g:neocomplete#max_keyword_width* +g:neocomplete#max_keyword_width + This variable controls the indication width of a candidate + displayed in a pop-up menu. If the keyword length exceeds + the length it will be cut down properly. + + Default value is 80. + + *g:neocomplete#auto_completion_start_length* +g:neocomplete#auto_completion_start_length + This variable controls the number of the input completion + at the time of key input automatically. + Note: |g:neocomplete#auto_completion_start_length| is used + for "keyword" kind source only. Please refer to + |neocomplete-source-attribute-min_pattern_length|. + + Default value is 2. + + *g:neocomplete#manual_completion_start_length* +g:neocomplete#manual_completion_start_length + This variable controls the number of the input completion + at the time of manual completion. It is convenient when you + reduce this value, but may get heavy when you deleted a + letter in or at popup indication time. + + Default value is 0. + + *g:neocomplete#min_keyword_length* +g:neocomplete#min_keyword_length + In a buffer or dictionary files, this variable controls + length of keyword becoming the targets of the completion at + the minimum. + + Default value is 4. + + *g:neocomplete#enable_ignore_case* +g:neocomplete#enable_ignore_case + When neocomplete looks for candidate completion, this + variable controls whether neocomplete ignores the upper- + and lowercase. If it is 1, neocomplete ignores case. + + Default value is 'ignorecase'. + + *g:neocomplete#enable_smart_case* +g:neocomplete#enable_smart_case + When a capital letter is included in input, neocomplete does + not ignore the upper- and lowercase. + + Default value is 'infercase'. + + *g:neocomplete#enable_camel_case* +g:neocomplete#enable_camel_case + When a capital letter is matched with the uppercase, but a + lower letter is matched with the upper- and lowercase. + Ex: "foB" is matched with "FooBar" not "foobar". + Note: This feature is only available in + |neocomplete-filter-matcher_fuzzy|. + + Default value is 0. + + *g:neocomplete#disable_auto_complete* +g:neocomplete#disable_auto_complete + This variable controls whether you invalidate automatic + completion. If it is 1, automatic completion becomes + invalid, but can use the manual completion by + |neocomplete#start_manual_complete()|. + + Default value is 0. + + *g:neocomplete#auto_complete_delay* +g:neocomplete#auto_complete_delay + It is the auto completion delay time after your input. + The unit is ms. + Note: It requires |+timers| feature. + Note: It is disabled in MacVim. + + Default value is 50. + + *g:neocomplete#enable_auto_select* +g:neocomplete#enable_auto_select + When neocomplete displays candidates, this option controls + whether neocomplete selects the first candidate + automatically. If you enable this option, neocomplete's + completion behavior is like |AutoComplPop|. + + Note: If you want to enable the feature in + |g:neocomplete#force_omni_input_patterns|, you need Vim + 7.4.775 or above. + + Default value is 0. + + *g:neocomplete#enable_auto_delimiter* +g:neocomplete#enable_auto_delimiter + This option controls whether neocomplete insert delimiter + automatically. For example, / (filenames) or # (Vim scripts.) + + Default value is 0. + + *g:neocomplete#enable_fuzzy_completion* +g:neocomplete#enable_fuzzy_completion + When you input one character, this variable controls whether + neocomplete takes an ambiguous searching as an end of the + words in it. For example, neocomplete comes to match it with + "public_html" or "PublicHtml" when you input it with "puh". + Note: The first letter must be matched. + + Default value is 1. + + *g:neocomplete#enable_refresh_always* +g:neocomplete#enable_refresh_always + Neocomplete refreshes the candidates automatically if this + value is 1. + Note: It increases the screen flicker. + + Default value is 0. + + *g:neocomplete#enable_multibyte_completion* +g:neocomplete#enable_multibyte_completion + If it is non-0, neocomplete can complete multibyte characters. + Note: This feature may conflict Input Method in Unix systems. + Note: To use multibyte completion, you must change + |g:neocomplete#keyword_patterns| variable. + + Default value is 0. + + *g:neocomplete#lock_buffer_name_pattern* +g:neocomplete#lock_buffer_name_pattern + This variable sets a pattern of the buffer name. If matched it, + neocomplete does not complete automatically. When it is an + empty character string, neocomplete will ignore it. + + Default value is ''. + +g:neocomplete#lock_iminsert *g:neocomplete#lock_iminsert* + If this variable is non-zero, neocomplete locks when + 'iminsert' is non-zero. + + Default value is 0. + +g:neocomplete#data_directory *g:neocomplete#data_directory* + This variable appoints the directory that neocomplete + begins to write a file at one time. When there is not the + directory which appointed here, it is made. For example, + buffer.vim stores cache of the keyword in this + 'buffer_cache' sub directory. + + Default value is "$XDG_CACHE_HOME/neocomplete" or + expand("~/.cache/neocomplete"); the absolute path of it. + + *g:neocomplete#keyword_patterns* +g:neocomplete#keyword_patterns + This dictionary records keyword patterns to completion. + This is appointed in regular expression every file type. + If the key is "_" or "default", it is used for default + pattern. + + Because it is complicated, refer to + neocomplete#init#_variables() in + autoload/neocomplete/init.vim for the initial value. +> + " Examples: + if !exists('g:neocomplete#keyword_patterns') + let g:neocomplete#keyword_patterns = {} + endif + let g:neocomplete#keyword_patterns._ = '\h\w*' +< + *g:neocomplete#force_omni_input_patterns* +g:neocomplete#force_omni_input_patterns + This dictionary records keyword patterns to Omni completion. + This is appointed in regular expression every file type. + If this pattern is not defined or empty pattern, neocomplete + does not call 'omnifunc'. + Note: If it is a set, neocomplete will call 'omnifunc' + directly. So almost neocomplete features are disabled. But + all Omni completion works instead of + |g:neocomplete#sources#omni#input_patterns|. +> + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + let g:neocomplete#force_omni_input_patterns.ruby = + \ '[^. *\t]\.\w*\|\h\w*::' +< + Because it is complicated, refer to + neocomplete#init#_variables() in + autoload/neocomplete/init.vim for the initial value. + + *g:neocomplete#text_mode_filetypes* +g:neocomplete#text_mode_filetypes + It is a dictionary to define text mode filetypes. The + dictionary's key is filetype and value is number. If the + value is non-zero, this filetype is text mode. In text mode, + neocomplete supports word conversion to write English. + If the key is "_" and the value is non-zero, all filetypes are + text mode. + + For example, if you input "Fo", neocomplete will convert + candidate "foo" to "Foo". If you input "foo", neocomplete + will convert candidate "FooBar" to "foobar". If you input + "FO", neocomplete will convert candidate "foo" to "FOO". + Note: Text mode conversion is only used for "foobar" or + "Foobar" or "FOOBAR" words. Not "fooBar" or "FooBar". + + Because it is complicated, refer to + neocomplete#init#_variables() in + autoload/neocomplete/init.vim for the initial value. + + *g:neocomplete#delimiter_patterns* +g:neocomplete#delimiter_patterns + This variable appoints a delimiter pattern to smart complete a + function. This is appointed in string list every file type. + Note: This string is not regular expression. +> + " Examples: + if !exists('g:neocomplete#delimiter_patterns') + let g:neocomplete#delimiter_patterns= {} + endif + let g:neocomplete#delimiter_patterns.vim = ['#'] + let g:neocomplete#delimiter_patterns.cpp = ['::'] +< + Because it is complicated, refer to + neocomplete#init#_variables() in + autoload/neocomplete/init.vim for the initial value. + +g:neocomplete#sources *g:neocomplete#sources* + It is a dictionary to decide use source names. The key is + filetype and the value is source names list. If the key is + "_", the value will be used for default filetypes. For + example, you can disable some sources in C++ filetype. + If the value is "_", it will load all sources. + Default value is {}. +> + " Examples: + if !exists('g:neocomplete#sources') + let g:neocomplete#sources = {} + endif + let g:neocomplete#sources._ = ['buffer'] + let g:neocomplete#sources.cpp = ['buffer', 'dictionary'] +< +b:neocomplete_sources *b:neocomplete_sources* + It is a list to decide use source names in buffer local. +> + " Examples: + " In cmdwin, only use vim source. + autocmd CmdwinEnter * let b:neocomplete_sources = ['vim'] +< + *g:neocomplete#release_cache_time* +g:neocomplete#release_cache_time + This variable defines time of automatic released cache by a + second unit. + + Default value is 900. + + *g:neocomplete#tags_filter_patterns* +g:neocomplete#tags_filter_patterns + This dictionary records a pattern to filter a candidate in + the tag completion. For example, it can exclude a candidate + beginning in _ in file type of C/C++. + + Because it is complicated, refer to + neocomplete#init#_variables() in + autoload/neocomplete/init.vim for the initial value. + +g:neocomplete#use_vimproc *g:neocomplete#use_vimproc* + This variable is non 0, neocomplete uses |vimproc|. + Note: If this variable is non 0, neocomplete will make cache + asynchronously. + + Default value is vimproc auto detection result. + + *g:neocomplete#skip_auto_completion_time* +g:neocomplete#skip_auto_completion_time + It is a string for skip auto completion. + If completion time is higher than it, neocomplete will skip + auto completion. + If it is "", the skip feature will be disabled. + + Default value is "0.3". + {only available when compiled with the |+reltime| feature} + + *g:neocomplete#enable_auto_close_preview* +g:neocomplete#enable_auto_close_preview + If it is non-zero, neocomplete will close preview window + automatically. + + Default value is 0. + + *g:neocomplete#fallback_mappings* +g:neocomplete#fallback_mappings + Neocomplete fallback mappings. + If you want to complete keywords by neocomplete and the + omnifunc, it is useful. > + " Search from neocomplete, omni candidates, vim keywords. + let g:neocomplete#fallback_mappings = + \ ["\\", "\\"] +< + Default value is []. + +SOURCES VARIABLES *neocomplete-sources-variables* + + *g:neocomplete#sources#buffer#cache_limit_size* +g:neocomplete#sources#buffer#cache_limit_size + This variable sets file size to make a cache of a file. If + open file is bigger than this size, neocomplete does not + make a cache. + + Default value is 500000. + + *g:neocomplete#sources#buffer#disabled_pattern* +g:neocomplete#sources#buffer#disabled_pattern + This variable sets a pattern of the buffer file path. If + matched it, neocomplete does not save a cache of the buffer. + When it is an empty character string, neocomplete will + ignore. + + Default value is ''. + + *g:neocomplete#sources#buffer#max_keyword_width* +g:neocomplete#sources#buffer#max_keyword_width + If the keyword length exceeds the length it will be not shown + in popup menu. + + Default value is 80. + + *g:neocomplete#sources#dictionary#dictionaries* +g:neocomplete#sources#dictionary#dictionaries + It is a dictionary to connect a dictionary file with file + type. The dictionary's key is filetype and comma-separated + multiple value is a path to a dictionary file. If the + variable is unset or has an empty key, the native 'dictionary' + option will be inherited. When you set "text" + key, you will appoint dictionary files in text mode. If the + key is "_", it is loaded in every filetype. + Note: Global 'dictionary' file is not loaded automatically. + + Default value is {}. + + *g:neocomplete#sources#member#prefix_patterns* +g:neocomplete#sources#member#prefix_patterns + This variable appoints a prefix pattern to complete a member + in buffer. + This is appointed in regular expression every file type. + If filetype key is not set, disable member completion. + + Because it is complicated, refer in + autoload/neocomplete/sources/buffer.vim for the + initial value. + + *g:neocomplete#sources#member#input_patterns* +g:neocomplete#sources#member#input_patterns + This variable appoints a keyword pattern to complete a member + in buffer. + This is appointed in regular expression every file type. + If filetype key is not set, use filetype "_" setting. + + Because it is complicated, refer in + autoload/neocomplete/sources/buffer.vim for the + initial value. + + *g:neocomplete#sources#omni#functions* +g:neocomplete#sources#omni#functions + This dictionary which appoints omni source call functions. + The key is 'filetype'. The value is omnifunc name String or + List of omnifunc name String. + If |g:neocomplete#sources#omni#functions| [&filetype] is + undefined, omni source calls 'omnifunc'. + If the key is "_", used for all filetypes. + + Default value is {}. + + *g:neocomplete#sources#omni#input_patterns* +g:neocomplete#sources#omni#input_patterns + This dictionary records keyword patterns used in + omni source. This is appointed in regular expression + every file type or 'omnifunc' name. If this pattern is not + defined or empty pattern, neocomplete does not call + 'omnifunc'. + Note: ruby and php omnifunc are disabled, because they are too + slow. + Note: Partial omnifunc has problem when neocomplete call (Ex: + rubycomplete, jedi.vim, cocoa.vim, and clang_complete.) You + should |g:neocomplete#force_omni_input_patterns| instead. + + Because it is complicated, refer to s:source.initialize() + autoload/neocomplete/sources/omni.vim for the + initial value. +> + " Examples: + if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + endif + let g:neocomplete#sources#omni#input_patterns.php = + \ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + let g:neocomplete#sources#omni#input_patterns.c = + \ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?' +< + *g:neocomplete#sources#tags#cache_limit_size* +g:neocomplete#sources#tags#cache_limit_size + This variable sets file size to make a cache of a file in + tag source. If open file is bigger than this size, + neocomplete does not make a tags cache. + + Default value is 500000. + + *g:neocomplete#sources#vim#complete_functions* +g:neocomplete#sources#vim#complete_functions + This dictionary which appoints vim source call function + when completes custom and customlist command. The key is + command name. The value is function name. + + Default value is {}. +> + " Examples: + if !exists('g:neocomplete#sources#vim#complete_functions') + let g:neocomplete#sources#vim#complete_functions = {} + endif + let g:neocomplete#sources#vim#complete_functions.Ref = + \ 'ref#complete' +< + *g:neocomplete#ignore_source_files* +g:neocomplete#ignore_source_files + Ignore source filenames (not full path.) You can optimize + source initialization. + + Note: You cannot use the sources in ignored source files. +> + let g:neocomplete#ignore_source_files = ['tag.vim'] +< + The default value is []. + +------------------------------------------------------------------------------ +FUNCTIONS *neocomplete-functions* + +neocomplete#initialize() *neocomplete#initialize()* + Initialize neocomplete and sources. + Note: It enables neocomplete. + Note: You should call it in |VimEnter| autocmd. + User customization for neocomplete must be set before + initialization of neocomplete. + +neocomplete#custom#source({source-name}, {option-name}, {value}) + *neocomplete#custom#source()* + Set {source-name} source specialized {option-name} + to {value}. You may specify multiple sources with + separating "," in {source-name}. + If {source-name} is "_", sources default option will be + change. + + These options below are available: + |neocomplete-source-attributes| + Note: User customization for neocomplete must be set before + initialization of neocomplete. + + *neocomplete#custom_source()* + neocomplete#custom_source() is used for compatibility. + + *neocomplete#get_context_filetype()* +neocomplete#get_context_filetype() + Get current context filetype of the cursor. This is smarter + than 'filetype' about handling nested filetypes. + Note: To enable context filetype feature, you must install + context_filetype.vim. + https://github.com/Shougo/context_filetype.vim + + For example html filetype has javascript inside. Say, you have + a buffer which content is below with filetype is html. +> + +< + At the line 1 and 3, neocomplete#get_context_filetype() is + "html" and at the line 2 it's "javascript", while at any + lines 'filetype' is "html". + + *neocomplete#disable_default_dictionary()* +neocomplete#disable_default_dictionary({variable-name}) + Disable default {variable-name} dictionary initialization. + Note: It must be called in .vimrc. + + *neocomplete#get_default_matchers()* +neocomplete#get_default_matchers() + Get default matchers in current buffer. + + *neocomplete#set_default_matchers()* +neocomplete#set_default_matchers({names}) + Chang default matchers in current buffer. +> + call neocomplete#set_default_matchers('matcher_head') +< +------------------------------------------------------------------------------ +KEY MAPPINGS *neocomplete-key-mappings* + + *neocomplete#start_manual_complete()* +neocomplete#start_manual_complete([{sources}]) + Use this function on inoremap . The keymapping call the + completion of neocomplete. When you rearrange the completion + of the Vim standard, you use it. + If you give {sources} argument, neocomplete call {sources}. + {sources} is name of source or list of sources name. +> + inoremap neocomplete#start_manual_complete() +< + *neocomplete#close_popup()* +neocomplete#close_popup() + Insert candidate and close popup menu for neocomplete. + Note: It is deprecated function. You should use "\" + character instead. + + *neocomplete#cancel_popup()* +neocomplete#cancel_popup() + Cancel completion menu for neocomplete. + Note: It is deprecated function. You should use "\" + character instead. + + *neocomplete#smart_close_popup()* +neocomplete#smart_close_popup() + Insert candidate and re-generate popup menu for neocomplete. + Unlike |neocomplete#close_popup()|, this function changes + behavior by |g:neocomplete#enable_auto_select| smart. + Note: This mapping is conflicted with |SuperTab| or |endwise| + plugins. + Note: This key mapping is for or keymappings. + You should not use it for . + + *neocomplete#undo_completion()* +neocomplete#undo_completion() + Use this function on inoremap to undo inputted + candidate. Because there is not mechanism to cancel + candidate in Vim, it will be convenient when it inflects. +> + inoremap neocomplete#undo_completion() +< + *neocomplete#complete_common_string()* +neocomplete#complete_common_string() + Use this function on inoremap to complete common + string in candidates. It will be convenient when candidates + have long common string. +> + inoremap neocomplete#complete_common_string() + inoremap + \ neocomplete#complete_common_string() != '' ? + \ neocomplete#complete_common_string() : + \ pumvisible() ? "\" : "\" +< + *(neocomplete_start_unite_complete)* +(neocomplete_start_unite_complete) + Start completion with |unite|. + Note: unite.vim Latest ver.3.0 or above is required. + Note: In unite interface, uses partial match instead of head + match. + + *(neocomplete_start_quick_match)* +(neocomplete_start_unite_quick_match) + Start completion with |unite| and start quick match mode. + Note: unite.vim Latest ver.3.0 or above is required. + +============================================================================== +EXAMPLES *neocomplete-examples* +> + " Note: This option must set it in .vimrc (_vimrc). + " NOT IN .gvimrc (_gvimrc)! + " Disable AutoComplPop. + let g:acp_enableAtStartup = 0 + " Use neocomplete. + let g:neocomplete#enable_at_startup = 1 + " Use smartcase. + let g:neocomplete#enable_smart_case = 1 + + " Define dictionary. + let g:neocomplete#sources#dictionary#dictionaries = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + + " Define keyword. + if !exists('g:neocomplete#keyword_patterns') + let g:neocomplete#keyword_patterns = {} + endif + let g:neocomplete#keyword_patterns['default'] = '\h\w*' + + " Plugin key-mappings. + inoremap neocomplete#undo_completion() + inoremap neocomplete#complete_common_string() + + " Recommended key-mappings. + " : close popup and save indent. + inoremap =my_cr_function() + function! s:my_cr_function() + return (pumvisible() ? "\" : "" ) . "\" + " For no inserting key. + "return pumvisible() ? "\" : "\" + endfunction + " : completion. + inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ neocomplete#start_manual_complete() + function! s:check_back_space() abort "{{{ + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' + endfunction"}}} + " , : close popup and delete backword char. + inoremap neocomplete#smart_close_popup()."\" + inoremap neocomplete#smart_close_popup()."\" + " Close popup by . + "inoremap pumvisible() ? "\" : "\" + + " AutoComplPop like behavior. + "let g:neocomplete#enable_auto_select = 1 + + " Shell like behavior (not recommended.) + "set completeopt+=longest + "let g:neocomplete#enable_auto_select = 1 + "let g:neocomplete#disable_auto_complete = 1 + "inoremap pumvisible() ? "\" : + " \ neocomplete#start_manual_complete() + + " 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:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + endif + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + "let g:neocomplete#sources#omni#input_patterns.php = + "\ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + "let g:neocomplete#sources#omni#input_patterns.c = + "\ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?' + "let g:neocomplete#sources#omni#input_patterns.cpp = + "\ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + + " For perlomni.vim setting. + " https://github.com/c9s/perlomni.vim + let g:neocomplete#sources#omni#input_patterns.perl = + \ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' + + " For smart TAB completion. + "inoremap pumvisible() ? "\" : + " \ check_back_space() ? "\" : + " \ neocomplete#start_manual_complete() + " function! s:check_back_space() "{{{ + " let col = col('.') - 1 + " return !col || getline('.')[col - 1] =~ '\s' + " endfunction"}}} +< +============================================================================== +SOURCES *neocomplete-sources* + +neocomplete reads automatically sources saved in an +autoload/neocomplete/sources directory. + +buffer *neocomplete-source-buffer* + This source collects keywords from buffer. + +member *neocomplete-source-member* + This source collects use of member variables from buffer. + +tag *neocomplete-source-tag* + This source analyzes a tag file from tagfiles() for completion. + When a huge tag file (above + |g:neocomplete#sources#tags#cache_limit_size|) is set, + neocomplete does not make cache if you do not execute + |:NeoCompleteTagMakeCache| command. Because tag is + too slow if tag read a big tags file. You should use + more convenient include source completion now. + +dictionary *neocomplete-source-dictionary* + This source adds candidates from 'dictionary' or + |g:neocomplete#sources#dictionary#dictionaries|. + +file *neocomplete-source-file* + This source collects filename candidates. + Note: It is relative path to current buffer directory. + +omni *neocomplete-source-omni* + This source calls 'omnifunc' automatically when cursor + text is matched with + |g:neocomplete#sources#omni#input_patterns|. If + |g:neocomplete_omni_function_list| is defined, neocomplete + will give priority it. + Note: It supports the fuzzy match using the previous result. + + +suffix of complete candidates in popup menu declaration. +(This will be good for user to know where candidate from and what it is.) + + file -> [F] {filename} + file/include -> [FI] {filename} + dictionary -> [D] {words} + member -> [M] member + buffer -> [B] {buffer} + syntax -> [S] {syntax-keyword} + include -> [I] + neosnippet -> [neosnip] + UltiSnips -> [US] + vim -> [vim] type + omni -> [O] + tag -> [T] + other sources -> [plugin-name-prefix] + +------------------------------------------------------------------------------ +USER SOURCES *neocomplete-user-sources* + +This section, introduce non default neocomplete sources. + +neosnippet *neocomplete-sources-neosnippet* + This source is for snippets completion. + https://github.com/Shougo/neosnippet + +UltiSnips *neocomplete-sources-ultisnips* + This source is for UltiSnips snippets completion. + https://github.com/SirVer/ultisnips + +neco-ghc *neocomplete-sources-neco-ghc* + https://github.com/eagletmt/neco-ghc + eagletmt originally implemented and ujihisa added some new + features. It completes a source file written in Haskell. + It requires ghc-mod . + +neco-vim *neocomplete-sources-neco-vim* + https://github.com/Shougo/neco-vim + It analyzes context and start Omni completion of Vim script. + It does not work other than editing time of Vim script. I + created it because neocomplete cannot call |i_CTRL-X_CTRL-V|. + Local variable and a script variable, a function and the + analysis of the command are implemented now. + +============================================================================== +FILTERS *neocomplete-filters* + +To custom candidates, neocomplete uses the filters. There are three kinds of +filters are available. "matcher" is to filter candidates by user input. +"sorter" is to sort candidates. "converter" is to candidates conversion. + +Default sources are below. But you can create original filters (cf: +|neocomplete-create-filter|) and set them by +|neocomplete#custom#source()|. +> + call neocomplete#custom#source( + \ 'buffer', 'converters', []) + + " Change default matcher. + call neocomplete#custom#source('_', 'matchers', + \ ['matcher_head', 'matcher_length']) + + " Change default sorter. + call neocomplete#custom#source('_', 'sorters', + \ ['sorter_length']) + + " Disable sort. + call neocomplete#custom#source('_', 'sorters', []) + + " Change default converter. + call neocomplete#custom#source('_', 'converters', + \ ['converter_remove_overlap', 'converter_remove_last_paren', + \ 'converter_delimiter', 'converter_abbr']) +< + *neocomplete-filter-matcher_default* +Default matchers: + If |g:neocomplete#enable_fuzzy_completion|: + ['matcher_head', 'matcher_length'] + Otherwise: + ['matcher_fuzzy', 'matcher_length'] + + You can change it by |neocomplete#set_default_matchers()|. + + *neocomplete-filter-sorter_default* +Default sorters: ['sorter_rank']. + + *neocomplete-filter-converter_default* +Default converters: ['converter_remove_overlap', + \ 'converter_delimiter', 'converter_abbr']. + + *neocomplete-filter-matcher_head* +matcher_head Head matching matcher. + + *neocomplete-filter-matcher_fuzzy* +matcher_fuzzy Fuzzy matching matcher. + + *neocomplete-filter-matcher_length* +matcher_length Input keyword length matcher. It removes candidates which is + less than input keyword length. + + *neocomplete-filter-matcher_nothing* +matcher_nothing Nothing matcher. It disables the matcher filtering. + + *neocomplete-filter-sorter_rank* +sorter_rank Matched rank order sorter. The higher the matched word is + already selected or in current buffer + + *neocomplete-filter-sorter_length* +sorter_length Candidates length order sorter. + + *neocomplete-filter-sorter_word* +sorter_word Candidates word order sorter. + + *neocomplete-filter-converter_abbr* +converter_abbr + The converter which abbreviates a candidate's abbr. + + *neocomplete-filter-converter_disable_abbr* +converter_disable_abbr + The converter which disables a candidate's abbr. + + *neocomplete-filter-converter_delimiter* +converter_delimiter + The converter which abbreviates a candidate's delimiter. + (cf: |g:neocomplete#delimiter_patterns|) + + *neocomplete-filter-converter_remove_overlap* +converter_remove_overlap + The converter which removes overlapped text in a candidate's + word. + Note: It removes candidates which is not overlapped + (it is in auto completion only). + + *neocomplete-filter-converter_remove_last_paren* +converter_remove_last_paren + The converter which removes last parentheses in a + candidate's word. It is useful if you use auto closing + parentheses plugins. + + *neocomplete-filter-converter_add_paren* +converter_add_paren + The converter which adds parentheses in a candidate's word. It + is useful if you use |neopairs.vim| or |neosnippet.vim| + plugins. + +============================================================================== +CREATE SOURCE *neocomplete-create-source* + +In this clause, I comment on a method to make source of neocomplete. The +ability of neocomplete will spread by creating source by yourself. + +The files in autoload/neocomplete/sources are automatically loaded and it +calls neocomplete#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 |neocomplete#define_source()|. + +------------------------------------------------------------------------------ +SOURCE ATTRIBUTES *neocomplete-source-attributes* + + *neocomplete-source-attribute-name* +name String (Required) + The name of a source. Allowed characters are: + - a-z + - 0-9 + - _ + - / + - - (Not head) + + *neocomplete-source-attribute-kind* +kind String (Optional) + The kind of the source. It decides the behaviour of the + complete position. The following values are available: + + "manual": The source decides the complete position manually + with the "get_complete_position" attribute. + See also: + |neocomplete-source-attribute-get_complete_position| + + "keyword": The source decides the complete position with + |g:neocomplete#keyword_patterns|. This pattern is + also used to filter the candidates. + + Note that "plugin", "complfunc" and "ftplugin" are old values + that are no longer accepted. + + + *neocomplete-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. + + *neocomplete-source-attribute-disabled_filetypes* +disabled_filetypes Dictionary (Optional) + Not available filetype dictionary. + If the key is "_", the source is disabled in all sources. + + *neocomplete-source-attribute-rank* +rank Number (Optional) + Source priority. Higher values imply higher priority. + If you omit it, it is set below value. + Note: It is high priority than match position. + + If kind attribute is "keyword": 5 + If filetype attribute is empty: 10 + Otherwise: 100 + + Example: +> + " Change vim source default rank value of 300. + call neocomplete#custom#source('ultisnips', 'rank', 1000) +< + *neocomplete-source-attribute-min_pattern_length* +min_pattern_length + Number (Optional) + Required pattern length for completion. + + If you omit it, it is set to + |g:neocomplete#auto_completion_start_length| + + *neocomplete-source-attribute-input_pattern* +input_pattern + String (Optional) + If it is matched, neocomplete ignores + |neocomplete-source-attribute-min_pattern_length|. + It is useful for omni function sources. + + If you omit it, it is set to "". + + *neocomplete-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. + + *neocomplete-source-attribute-keyword_patterns* +keyword_patterns + Dictionary (Optional) + This dictionary changes keyword patterns to completion for + specific types. +> + let keyword_patterns = {} + let keyword_patterns.tex = '\\\?\h\w*' + call neocomplete#custom#source('dictionary', + \ 'keyword_patterns', keyword_patterns) +< + This attribute is optional; if it is not given, + |g:neocomplete#keyword_patterns| is used as the default value. + + *neocomplete-source-attribute-is_volatile* +is_volatile Number (Optional) + Whether the source recalculates the candidates everytime the + input is changed. + This attribute is optional. + If it's not given, 0 is set as the default value. In this + case, candidates are cached. + + *neocomplete-source-attribute-disabled* +disabled Number (Optional) + This attribute is optional. + If it's not given, 0 is set as the default value. + Otherwise, the source is disabled. + + *neocomplete-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: + + *neocomplete-source-attribute-hooks-on_init* + on_init + Called when initializing the source. + This function takes {context} as its parameters. + + *neocomplete-source-attribute-hooks-on_final* + on_final + Called after executing |:NeoCompleteDisable|. + This function takes {context} as its parameters. + + *neocomplete-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. + + *neocomplete-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(|neocomplete-notation-{context}|). + If you omit it, neocomplete will use the position using + |g:neocomplete#keyword_patterns|. + Note: If the source returns candidates which are not matched + |g:neocomplete#keyword_patterns|, you must define + |neocomplete-source-attribute-get_complete_position|. + + *neocomplete-source-attribute-gather_candidates* +gather_candidates Function (Required) + This function is called in gathering candidates. If you + enabled fuzzy completion by + |g:neocomplete#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(|neocomplete-notation-{context}|). + +{context} *neocomplete-notation-{context}* + A dictionary to give context information. + The followings are the primary information. + The global context information can be acquired by + |neocomplete#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 *neocomplete-candidate-attributes* + + *neocomplete-candidate-attribute-name* +word String (Required) + The completion word of a candidate. It is used for matching + inputs. + + *neocomplete-candidate-attribute-abbr* +abbr String (Optional) + The abbreviation of a candidate. It is displayed in popup + window. It is omitted by |g:neocomplete#max_keyword_width|. + + *neocomplete-candidate-attribute-kind* +kind String (Optional) + The kind of a candidate. It is displayed in popup window. + + *neocomplete-candidate-attribute-menu* +menu String (Optional) + The menu information of a candidate. It is displayed in popup + window. + + *neocomplete-candidate-attribute-info* +info String (Optional) + The preview information of a candidate. If 'completeopt' + contains "preview", it will be displayed in |preview-window|. + + *neocomplete-candidate-attribute-rank* +rank Number (Optional) + The completion priority. + +CONTEXT *neocomplete-context* + +============================================================================== +CREATE FILTER *neocomplete-create-filter* + +The files in autoload/neocomplete/filters are automatically loaded and it +calls neocomplete#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 |neocomplete#define_filter()|. + +------------------------------------------------------------------------------ +FILTER ATTRIBUTES *neocomplete-filter-attributes* + + + *neocomplete-filter-attribute-name* +name String (Required) + The filter name. + + *neocomplete-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 |neocomplete-source-attribute-gather_candidates|. + + *neocomplete-filter-attribute-description* +description String (Optional) + The filter description string. + +============================================================================== +UNITE SOURCES *neocomplete-unite-sources* + + *neocomplete-unite-source-neocomplete* +neocomplete + Nominates neocomplete completion candidates. The kind is + "completion". This source is used in + |(neocomplete_start_unite_complete)|. +> + imap (neocomplete_start_unite_complete) + imap (neocomplete_start_unite_quick_match) +< +============================================================================== +EXTERNAL SOURCES *neocomplete-external-sources* + +neosnippet source: + +https://github.com/Shougo/neosnippet.vim + +include, file/include sources: + +https://github.com/Shougo/neoinclude.vim + +UltiSnips source: + +https://github.com/SirVer/ultisnips + +vimshell source: + +https://github.com/Shougo/vimshell.vim + +look source: + +https://github.com/ujihisa/neco-look + +ghc source: + +https://github.com/eagletmt/neco-ghc + +calc source: + +https://github.com/hrsh7th/vim-neco-calc + +============================================================================== +FAQ *neocomplete-faq* + +Q: My customization for neocomplete is invalid. Why? + +A: User customization for neocomplete must be set before initialization of +neocomplete. For example: |neocomplete#custom#source()| + +Q: I want to use head match instead of default fuzzy match. + +A: +> + let g:neocomplete#enable_fuzzy_completion = 0 +< +or +> + call neocomplete#custom#source('_', 'matchers', + \ ['matcher_head', 'matcher_length']) +< +Q: I want to sort candidates by different way. + +A: +> +> + call neocomplete#custom#source('_', 'sorters', + \ ['sorter_length']) +< +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 neocomplete or not +responding when input ".": + +A: This is not neocomplete's issue. Please report to the maintainers of the +omnicomplete (rubycomplete or pythoncomplete) and its Vim interface. You +should disable omni source in python or ruby. +> + if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + endif + let g:neocomplete#sources#omni#input_patterns.python = '' + let g:neocomplete#sources#omni#input_patterns.ruby = '' +< + +Q: Where are the snippets for neocomplete? + +A: https://github.com/Shougo/neosnippet or +https://github.com/SirVer/ultisnips + + +Q: How can I disable python omni complete of neocomplete?: + +A: +> + if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + endif + let g:neocomplete#sources#omni#input_patterns.python = '' +< + +Q: Can I enable quick match?: + +A: Quick match feature had been removed in latest neocomplete +because quick match turned into hard to implement. +But you can use |unite.vim| instead to use quick match. +> + imap - pumvisible() ? + \ "\(neocomplete_start_unite_quick_match)" : '-' +< + +Q: neocomplete cannot create cache files in "sudo vim": + +A: Because neocomplete (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 neocomplete. +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:neocomplete#sources#omni#input_patterns|. +https://github.com/vim-ruby/vim-ruby/issues/95 + +A: Please set |g:neocomplete#force_omni_input_patterns| instead of +|g:neocomplete#sources#omni#input_patterns|. + +Q: Does not work with clang_complete. + +A: Please try below settings. +> + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + let g:neocomplete#force_omni_input_patterns.c = + \ '[^.[:digit:] *\t]\%(\.\|->\)\w*' + let g:neocomplete#force_omni_input_patterns.cpp = + \ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*' + let g:neocomplete#force_omni_input_patterns.objc = + \ '\[\h\w*\s\h\?\|\h\w*\%(\.\|->\)' + let g:neocomplete#force_omni_input_patterns.objcpp = + \ '\[\h\w*\s\h\?\|\h\w*\%(\.\|->\)\|\h\w*::\w*' + let g:clang_complete_auto = 0 + let g:clang_auto_select = 0 + let g:clang_omnicppcomplete_compliance = 0 + let g:clang_make_default_keymappings = 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:neocomplete#sources#omni#functions.go = + \ 'gocomplete#Complete' + " Clojure (plugin: vim-clojure) + let g:neocomplete#sources#omni#functions.clojure = + \ 'vimclojure#OmniCompletion' + " SQL + let g:neocomplete#sources#omni#functions.sql = + \ 'sqlcomplete#Complete' + " R (plugin: vim-R-plugin) + let g:neocomplete#sources#omni#input_patterns.r = + \ '[[:alnum:].\\]\+' + let g:neocomplete#sources#omni#functions.r = + \ 'rcomplete#CompleteR' + " XQuery (plugin: XQuery-indentomnicomplete) + let g:neocomplete#sources#omni#input_patterns.xquery = + \ '\k\|:\|\-\|&' + let g:neocomplete#sources#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 neocomplete first. +https://github.com/vim-ruby/vim-ruby + +neocomplete 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 (pumvisible() ? "\" : "" ) . "\" + " For no inserting key. + "return pumvisible() ? "\" : "\" + endfunction +> +Q: Suggestions are case insensitive in "gitcommit" buffers, but not +"javascript". + +A: This is g:neocomplete#text_mode_filetypes feature. +You can disable it by following code. +> + if !exists('g:neocomplete#text_mode_filetypes') + let g:neocomplete#tags_filter_patterns = {} + endif + let g:neocomplete#text_mode_filetypes.gitcommit = 0 +< +Q: I want to use Ruby omni completion. + +A: Please set |g:neocomplete#force_omni_input_patterns|. But this completion +is heavy, so disabled by default. +Note: But you should use |vim-monster| instead of rubycomplete. +https://github.com/osyo-manga/vim-monster +> + autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + let g:neocomplete#force_omni_input_patterns.ruby = + \ '[^. *\t]\.\w*\|\h\w*::' +< +Q: I want to use jedi omni completion. +https://github.com/davidhalter/jedi-vim + +A: Please set |g:neocomplete#force_omni_input_patterns| as below. +> + autocmd FileType python setlocal omnifunc=jedi#completions + let g:jedi#completions_enabled = 0 + let g:jedi#auto_vim_configuration = 0 + let g:jedi#smart_auto_mappings = 0 + let g:neocomplete#force_omni_input_patterns.python = + \ '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*' + " alternative pattern: '\h\w*\|[^. \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:neocomplete#skip_auto_completion_time = '' +< +Q: I want to initialize neocomplete in .vimrc. + +A: Please call neocomplete#initialize() in .vimrc. But this function slows +your Vim initialization. +> + call neocomplete#initialize() +< +Q: neocomplete conflicts when multibyte input in GVim. + +A: Because Vim multibyte IME integration is incomplete. +You should use "fcitx" instead of "ibus". +If you set |g:neocomplete#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.vim/issues/368 + +A: I think you use 'foldmethod' is "expr" or "syntax". It is too heavy to use +neocomplete (or other auto completion.) You should change 'foldmethod' +option or install FastFold plugin. + +https://github.com/Konfekt/FastFold + +Note: In current version, neocomplete does not restore 'foldmethod'. Because +it is too heavy. + +Q: I want to use Pydiction with neocomplete. + +A: You should set |g:neocomplete#sources#dictionary#dictionaries|. +neocomplete 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:neocomplete#sources#omni#input_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:lua_define_completion_mappings = 0 + + let g:neocomplete#sources#omni#functions.lua = + \ 'xolox#lua#omnifunc' + let g:neocomplete#sources#omni#input_patterns.lua = + \ '\w\+[.:]\|require\s*(\?["'']\w*' +< + +Q: I want to disable sources in certain filetype. + +A: +> + " Disable dictionary source in python filetype. + call neocomplete#custom#source('dictionary', + \ 'disabled_filetypes', {'python' : 1}) +< + +Q: neocomplete closes DiffGitCached window from vim-fugitive +https://github.com/Shougo/neocomplcache.vim/issues/424 +A: +> + let g:neocomplete#enable_auto_close_preview = 0 +< + +Q: I want to use PHP omni completion. + +A: +Note: You should use this omni completion for PHP. +https://github.com/shawncplus/phpcomplete.vim +> + let g:neocomplete#sources#omni#input_patterns.php = + \ '\h\w*\|[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' +< + +Q: Eclim does not work well with neocomplete. +https://github.com/Shougo/neocomplete.vim/issues/39 + +A: neocomplete does not support eclim. You should use +|g:neocomplete#force_omni_input_patterns| instead of +|g:neocomplete#sources#omni#input_patterns|. +> + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + let g:neocomplete#force_omni_input_patterns.java = + \ \'\%(\h\w*\|)\)\.\w* + +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: I don't want to complete too long words. +https://github.com/Shougo/neocomplete.vim/issues/69 + +A: You can use |g:neocomplete#sources#buffer#max_keyword_width|. + +Q: neocomplete will change external completeopt value (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 neocomplete. +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 + +Q: I want to complete by Erlang omnifunc. +https://github.com/vim-erlang/vim-erlang-omnicomplete + +A: > + if !exists('g:neocomplete#force_omni_input_patterns') + let g:neocomplete#force_omni_input_patterns = {} + endif + let g:neocomplete#force_omni_input_patterns.erlang = + \ '\<[[:digit:][:alnum:]_-]\+:[[:digit:][:alnum:]_-]*' + +Q: I want to look selected function's arguments in neocomplete. But I don't +like preview window feature. +https://github.com/Shougo/neocomplete.vim/issues/120 + +A: You can do it by |echodoc|. +http://github.com/Shougo/echodoc.vim + +Q: In ||g:neocomplete#force_omni_input_patterns|, +|g:neocomplete#enable_auto_select| feature is not work. +https://github.com/Shougo/neocomplete.vim/issues/139 + +A: Please update your Vim to 7.4.775 or above. + +Q: I want to disable all sources by default. + +A: > + call neocomplete#custom#source('_', 'disabled', 1) + +Q: I want to disable candidates abbr in tag source. +https://github.com/Shougo/neocomplete.vim/issues/158 + +A: > + call neocomplete#custom#source('tags', 'converters', + \ ['converter_remove_overlap', 'converter_remove_last_paren', + \ 'converter_delimiter', 'converter_disable_abbr', 'converter_abbr']) + +Q: does not work. +https://github.com/Shougo/neocomplete.vim/issues/305 + +A: It is feature. +You must use |neocomplete#start_manual_complete()| instead of . + +Q: My mapping never works. + +A: https://github.com/Shougo/neocomplete.vim/issues/334 +Note: It is fixed in Vim 7.4.653. + +Q: When I press enter, Vim inserts new line instead of selected item. + +A: It is Vim's default behavior (feature.) If you want to select the item, you +should map . > + + inoremap pumvisible()? "\" : "\" + +Q: After updating Vim, some completion plugins automatically select the last +candidate in the popup menu. + +A: Vim 7.4.775 introduced "noselect" and "noinsert" options for 'completeopt'. +It is likely that those completion plugins use keymappings such as to +display the popup menu. However, there is no need to do this after 7.4.775 +since neocomplete.vim handles that part. If that's the case, you will need to +contact the author of the plugin and have it not send those key strokes if +"noselect" or "noinsert" option is present in 'completeopt'. + +Q: Any plan to support Vim 8.0 async API? + +A: No. + +============================================================================== +vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: diff --git a/pack/acp/start/neocomplete.vim/plugin/neocomplete.vim b/pack/acp/start/neocomplete.vim/plugin/neocomplete.vim new file mode 100644 index 0000000..1c17170 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/plugin/neocomplete.vim @@ -0,0 +1,63 @@ +"============================================================================= +" FILE: neocomplete.vim +" AUTHOR: Shougo Matsushita +" 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_neocomplete') + finish +endif +let g:loaded_neocomplete = 1 + +let s:save_cpo = &cpo +set cpo&vim + +command! -nargs=0 -bar NeoCompleteEnable + \ call neocomplete#init#enable() +command! -nargs=0 -bar NeoCompleteDisable + \ call neocomplete#init#disable() +command! -nargs=0 -bar NeoCompleteLock + \ call neocomplete#commands#_lock() +command! -nargs=0 -bar NeoCompleteUnlock + \ call neocomplete#commands#_unlock() +command! -nargs=0 -bar NeoCompleteToggle + \ call neocomplete#commands#_toggle_lock() +command! -nargs=1 -bar -complete=filetype NeoCompleteSetFileType + \ call neocomplete#commands#_set_file_type() +command! -nargs=0 -bar NeoCompleteClean + \ call neocomplete#commands#_clean() + +" Global options definition. "{{{ +let g:neocomplete#enable_debug = + \ get(g:, 'neocomplete#enable_debug', 0) +if get(g:, 'neocomplete#enable_at_startup', 0) + augroup neocomplete + " Enable startup. + autocmd CursorHold,InsertEnter + \ * call neocomplete#init#enable() + augroup END +endif"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/plugin/neocomplete/buffer.vim b/pack/acp/start/neocomplete.vim/plugin/neocomplete/buffer.vim new file mode 100644 index 0000000..db3da89 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/plugin/neocomplete/buffer.vim @@ -0,0 +1,24 @@ +"============================================================================= +" FILE: buffer.vim +" AUTHOR: Shougo Matsushita +"============================================================================= + +if exists('g:loaded_neocomplete_buffer') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=file -bar + \ NeoCompleteBufferMakeCache + \ call neocomplete#sources#buffer#make_cache() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplete_buffer = 1 + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/plugin/neocomplete/dictionary.vim b/pack/acp/start/neocomplete.vim/plugin/neocomplete/dictionary.vim new file mode 100644 index 0000000..39d6294 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/plugin/neocomplete/dictionary.vim @@ -0,0 +1,24 @@ +"============================================================================= +" FILE: dictionary.vim +" AUTHOR: Shougo Matsushita +"============================================================================= + +if exists('g:loaded_neocomplete_dictionary') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=customlist,neocomplete#filetype_complete + \ NeoCompleteDictionaryMakeCache + \ call neocomplete#sources#dictionary#remake_cache() +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplete_dictionary = 1 + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/plugin/neocomplete/member.vim b/pack/acp/start/neocomplete.vim/plugin/neocomplete/member.vim new file mode 100644 index 0000000..9670160 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/plugin/neocomplete/member.vim @@ -0,0 +1,24 @@ +"============================================================================= +" FILE: member.vim +" AUTHOR: Shougo Matsushita +"============================================================================= + +if exists('g:loaded_neocomplete_member') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=? -complete=file -bar + \ NeoCompleteMemberMakeCache + \ call neocomplete#sources#member#remake_cache(&l:filetype) +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplete_member = 1 + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/plugin/neocomplete/tag.vim b/pack/acp/start/neocomplete.vim/plugin/neocomplete/tag.vim new file mode 100644 index 0000000..ff58ff3 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/plugin/neocomplete/tag.vim @@ -0,0 +1,24 @@ +"============================================================================= +" FILE: tag.vim +" AUTHOR: Shougo Matsushita +"============================================================================= + +if exists('g:loaded_neocomplete_tag') + finish +endif + +let s:save_cpo = &cpo +set cpo&vim + +" Add commands. "{{{ +command! -nargs=0 -bar + \ NeoCompleteTagMakeCache + \ call neocomplete#sources#tag#make_cache(1) +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +let g:loaded_neocomplete_tag = 1 + +" vim: foldmethod=marker diff --git a/pack/acp/start/neocomplete.vim/test/neocomplete.vim b/pack/acp/start/neocomplete.vim/test/neocomplete.vim new file mode 100644 index 0000000..1657764 --- /dev/null +++ b/pack/acp/start/neocomplete.vim/test/neocomplete.vim @@ -0,0 +1,58 @@ + +let s:suite = themis#suite('parser') +let s:assert = themis#helper('assert') + +function! s:suite.escape() abort + call s:assert.equals( + \ neocomplete#filters#fuzzy_escape('abc'), 'a.*b.*c.*') + call s:assert.equals( + \ neocomplete#filters#fuzzy_escape('%a%b%c'), '%%a.*%%b.*%%c.*') + call s:assert.equals( + \ neocomplete#filters#fuzzy_escape('%[ab]c'), '%%%[a.*b.*%]c.*') + call s:assert.equals( + \ neocomplete#filters#fuzzy_escape('.abc'), '%.a.*b.*c.*') +endfunction + +function! s:suite.sort() abort + let candidates = [] + for i in range(1, 1000) + call add(candidates, { 'word' : i, 'rank' : i }) + endfor + function! CompareRank(i1, i2) abort + let diff = (get(a:i2, 'rank', 0) - get(a:i1, 'rank', 0)) + return (diff != 0) ? diff : (len(a:i1.word) < len(a:i2.word)) ? 1 : -1 + endfunction" + + " Benchmark. + let start = reltime() + call sort(copy(candidates), 'CompareRank') + echomsg reltimestr(reltime(start)) + let start = reltime() + call neocomplete#filters#sorter_rank#define().filter( + \ {'candidates' : copy(candidates), 'input' : '' }) + echomsg reltimestr(reltime(start)) + + call s:assert.equals(sort(copy(candidates), 'CompareRank'), + \ neocomplete#filters#sorter_rank#define().filter( + \ {'candidates' : copy(candidates), 'input' : '' })) +endfunction + +function! s:suite.fuzzy() abort + call s:assert.equals(neocomplete#filters#matcher_fuzzy#define().filter( + \ {'complete_str' : 'ae', 'candidates' : ['~/~']}), []) +endfunction + +function! s:suite.overlap() abort + call s:assert.equals(neocomplete#filters#converter_remove_overlap# + \length('foo bar', 'bar baz'), 3) + call s:assert.equals(neocomplete#filters#converter_remove_overlap# + \length('foobar', 'barbaz'), 3) + call s:assert.equals(neocomplete#filters#converter_remove_overlap# + \length('foob', 'baz'), 1) + call s:assert.equals(neocomplete#filters#converter_remove_overlap# + \length('foobar', 'foobar'), 6) + call s:assert.equals(neocomplete#filters#converter_remove_overlap# + \length('тест', 'ст'), len('ст')) +endfunction + +" vim:foldmethod=marker:fen: diff --git a/vimrc b/vimrc index a25881e..2079153 100644 --- a/vimrc +++ b/vimrc @@ -90,6 +90,10 @@ else set listchars=eol:¶,tab:→ ,trail:~,extends:>,precedes:< endif +if has("lua") + let g:neocomplete#enable_at_startup=1 +endif + if !empty(&viminfo) set viminfo^=! endif