Full Code of Shougo/neocomplcache for AI

master f8c1de81908e cached
58 files
461.7 KB
132.0k tokens
1 requests
Download .txt
Showing preview only (485K chars total). Download the full file or copy to clipboard to get everything.
Repository: Shougo/neocomplcache
Branch: master
Commit: f8c1de81908e
Files: 58
Total size: 461.7 KB

Directory structure:
gitextract_6vmgprjt/

├── .gitignore
├── README.md
├── autoload/
│   ├── neocomplcache/
│   │   ├── async_cache.vim
│   │   ├── cache.vim
│   │   ├── commands.vim
│   │   ├── complete.vim
│   │   ├── context_filetype.vim
│   │   ├── filters/
│   │   │   ├── converter_abbr.vim
│   │   │   ├── converter_case.vim
│   │   │   ├── converter_delimiter.vim
│   │   │   ├── converter_nothing.vim
│   │   │   ├── converter_remove_next_keyword.vim
│   │   │   ├── matcher_fuzzy.vim
│   │   │   ├── matcher_head.vim
│   │   │   ├── matcher_old.vim
│   │   │   ├── sorter_length.vim
│   │   │   ├── sorter_nothing.vim
│   │   │   └── sorter_rank.vim
│   │   ├── filters.vim
│   │   ├── handler.vim
│   │   ├── helper.vim
│   │   ├── init.vim
│   │   ├── mappings.vim
│   │   ├── sources/
│   │   │   ├── buffer_complete.vim
│   │   │   ├── dictionary_complete.vim
│   │   │   ├── filename_complete.vim
│   │   │   ├── filename_include.vim
│   │   │   ├── include_complete.vim
│   │   │   ├── member_complete.vim
│   │   │   ├── omni_complete.vim
│   │   │   ├── syntax_complete.vim
│   │   │   ├── tags_complete.vim
│   │   │   ├── vim_complete/
│   │   │   │   ├── autocmds.dict
│   │   │   │   ├── command_args.dict
│   │   │   │   ├── command_completions.dict
│   │   │   │   ├── command_prototypes.dict
│   │   │   │   ├── command_replaces.dict
│   │   │   │   ├── commands.dict
│   │   │   │   ├── features.dict
│   │   │   │   ├── functions.dict
│   │   │   │   ├── helper.vim
│   │   │   │   ├── mappings.dict
│   │   │   │   ├── options.dict
│   │   │   │   └── variables.dict
│   │   │   └── vim_complete.vim
│   │   ├── util.vim
│   │   └── variables.vim
│   ├── neocomplcache.vim
│   └── unite/
│       └── sources/
│           ├── file_include.vim
│           └── neocomplcache.vim
├── doc/
│   └── neocomplcache.txt
├── plugin/
│   ├── neocomplcache/
│   │   ├── buffer_complete.vim
│   │   ├── dictionary_complete.vim
│   │   ├── include_complete.vim
│   │   ├── syntax_complete.vim
│   │   └── tags_complete.vim
│   └── neocomplcache.vim
└── vest/
    └── test-neocomplcache.vim

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
doc/tags*
*.swp


================================================
FILE: README.md
================================================
**neocomplcache**
=================

**Note**: The development of this plugin is finished. Accepts minor patches and
issues but no new features.
[ddc.vim](https://github.com/Shougo/ddc.vim) is the next generation auto
completion plugin. Consider migrating to it.


Description
-----------

neocomplcache is the abbreviation of "neo-completion with cache". It
provides keyword completion system by maintaining a cache of keywords in the
current buffer. neocomplcache could be customized easily and has a lot more
features than the Vim's standard completion feature.

If you use Vim 7.3.885 or above with if\_lua feature, you should use
neocomplete.  It is faster than neocomplcache.

https://github.com/Shougo/neocomplete.vim

Installation
============

* Extract the file and put files in your Vim directory
   (usually ~/.vim/ or Program Files/Vim/vimfiles on Windows).
* Execute `|:NeoComplCacheEnable|` command or
`let g:neocomplcache_enable_at_startup = 1`
in your `.vimrc`. Not in `.gvimrc`(`_gvimrc`)!

Caution
-------

Because all variable names were changed in neocomplcache Ver.5, it is not
backwards compatible. If you want to upgrade, you should use the following
script from Mr.thinca.

http://gist.github.com/422503

Snippets feature(snippets\_complete source) was split from Ver.7.
If you used it, please install neosnippet source manually.

https://github.com/Shougo/neosnippet

Screen shots
============

Original filename completion.
-----------
![Original filename completion.](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1O5_bOQ2I/AAAAAAAAADE/vHf9Xg_mrTI/s1600/filename_complete.png)

Omni completion.
----------------
![Omni completion.](http://2.bp.blogspot.com/_ci2yBnqzJgM/TD1PTolkTBI/AAAAAAAAADU/knJ3eniuHWI/s1600/omni_complete.png)

Completion with vimshell(http://github.com/Shougo/vimshell).
------------------------------------------------------------
![Completion with vimshell(http://github.com/Shougo/vimshell).](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1PLfdQrwI/AAAAAAAAADM/2pSFRTHwYOY/s1600/neocomplcache_with_vimshell.png)

Vim completion
------------------------------------------------------------
![Vim completion.](http://1.bp.blogspot.com/_ci2yBnqzJgM/TD1PfKTlwnI/AAAAAAAAADs/nOGWTRLuae8/s1600/vim_complete.png)

Setting examples

```vim
"Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" Enable heavy features.
" Use camel case completion.
"let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
"let g:neocomplcache_enable_underbar_completion = 1

" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
    \ }

" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplcache#undo_completion()
inoremap <expr><C-l>     neocomplcache#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return neocomplcache#smart_close_popup() . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y>  neocomplcache#close_popup()
inoremap <expr><C-e>  neocomplcache#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>"

" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left>  neocomplcache#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
"inoremap <expr><Up>    neocomplcache#close_popup() . "\<Up>"
"inoremap <expr><Down>  neocomplcache#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplcache_enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplcache_enable_insert_char_pre = 1

" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

" Enable heavy omni completion.
if !exists('g:neocomplcache_force_omni_patterns')
  let g:neocomplcache_force_omni_patterns = {}
endif
let g:neocomplcache_force_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_force_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_force_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplcache_force_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
```


================================================
FILE: autoload/neocomplcache/async_cache.vim
================================================
"=============================================================================
" FILE: async_cache.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 16 Jul 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following condition
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! s:main(argv) "{{{
  " args: funcname, outputname filename pattern_file_name mark minlen maxfilename
  let [funcname, outputname, filename, pattern_file_name, mark, minlen, maxfilename, fileencoding]
        \ = a:argv

  if funcname ==# 'load_from_file'
    let keyword_list = s:load_from_file(
          \ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, 1)
  else
    let keyword_list = s:load_from_tags(
          \ filename, pattern_file_name, mark, minlen, maxfilename, fileencoding)
  endif

  if empty(keyword_list)
    return
  endif

  " Output cache.
  call writefile([string(keyword_list)], outputname)
endfunction"}}}

function! s:load_from_file(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding, is_string) "{{{
  if !filereadable(a:filename) || !filereadable(a:pattern_file_name)
    " File not found.
    return []
  endif

  let lines = map(readfile(a:filename),
        \ 's:iconv(v:val, a:fileencoding, &encoding)')

  let pattern = get(readfile(a:pattern_file_name), 0, '\h\w*')

  let max_lines = len(lines)

  let keyword_list = []
  let dup_check = {}
  let keyword_pattern2 = '^\%('.pattern.'\m\)'

  for line in lines "{{{
    let match = match(line, pattern)
    while match >= 0 "{{{
      let match_str = matchstr(line, keyword_pattern2, match)

      if !has_key(dup_check, match_str) && len(match_str) >= a:minlen
        " Append list.
        call add(keyword_list, (a:is_string ?
              \ match_str : { 'word' : match_str }))

        let dup_check[match_str] = 1
      endif

      let match += len(match_str)

      let match = match(line, pattern, match)
    endwhile"}}}
  endfor"}}}

  return keyword_list
endfunction"}}}

function! s:load_from_tags(filename, pattern_file_name, mark, minlen, maxfilename, fileencoding) "{{{
  let keyword_lists = []
  let dup_check = {}

  let [pattern, tags_file_name, filter_pattern, filetype] =
        \ readfile(a:pattern_file_name)[: 4]
  if tags_file_name !=# '$dummy$'
    " Check output.
    let tags_list = []

    let i = 0
    while i < 2
      if filereadable(tags_file_name)
        " Use filename.
        let tags_list = map(readfile(tags_file_name),
              \ 's:iconv(v:val, a:fileencoding, &encoding)')
        break
      endif

      sleep 500m
      let i += 1
    endwhile
  else
    if !filereadable(a:filename)
      return []
    endif

    " Use filename.
    let tags_list = map(readfile(a:filename),
          \ 's:iconv(v:val, a:fileencoding, &encoding)')
  endif

  if empty(tags_list)
    " File caching.
    return s:load_from_file(a:filename, a:pattern_file_name,
          \ a:mark, a:minlen, a:maxfilename, a:fileencoding, 0)
  endif

  for line in tags_list "{{{
    let tag = split(substitute(line, "\<CR>", '', '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:], "\<TAB>")
    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 <namespace>".
    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 <typedef \1>', 'g')

    let keyword = {
          \ 'word' : tag[0], 'abbr' : abbr,
          \ 'kind' : option['kind'], 'dup' : 1,
          \ }
    if has_key(option, 'struct')
      let keyword.menu = option.struct
    elseif has_key(option, 'class')
      let keyword.menu = option.class
    elseif has_key(option, 'enum')
      let keyword.menu = option.enum
    elseif has_key(option, 'union')
      let keyword.menu = option.union
    endif

    call add(keyword_lists, keyword)
    let dup_check[tag[0]] = 1
  endfor"}}}

  if filter_pattern != ''
    call filter(keyword_lists, filter_pattern)
  endif

  return keyword_lists
endfunction"}}}

function! s:truncate(str, width) "{{{
  " Original function is from mattn.
  " http://github.com/mattn/googlereader-vim/tree/master

  if a:str =~# '^[\x00-\x7f]*$'
    return len(a:str) < a:width ?
          \ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width)
  endif

  let ret = a:str
  let width = s:wcswidth(a:str)
  if width > a:width
    let ret = s:strwidthpart(ret, a:width)
    let width = s:wcswidth(ret)
  endif

  if width < a:width
    let ret .= repeat(' ', a:width - width)
  endif

  return ret
endfunction"}}}

function! s:strwidthpart(str, width) "{{{
  let ret = a:str
  let width = s:wcswidth(a:str)
  while width > a:width
    let char = matchstr(ret, '.$')
    let ret = ret[: -1 - len(char)]
    let width -= s:wcwidth(char)
  endwhile

  return ret
endfunction"}}}

function! s:iconv(expr, from, to)
  if a:from == '' || a:to == '' || a:from ==? a:to
    return a:expr
  endif
  let result = iconv(a:expr, a:from, a:to)
  return result != '' ? result : a:expr
endfunction

if v:version >= 703
  " Use builtin function.
  function! s:wcswidth(str) "{{{
    return strdisplaywidth(a:str)
  endfunction"}}}
  function! s:wcwidth(str) "{{{
    return strwidth(a:str)
  endfunction"}}}
else
  function! s:wcswidth(str) "{{{
    if a:str =~# '^[\x00-\x7f]*$'
      return strlen(a:str)
    end

    let mx_first = '^\(.\)'
    let str = a:str
    let width = 0
    while 1
      let ucs = char2nr(substitute(str, mx_first, '\1', ''))
      if ucs == 0
        break
      endif
      let width += s:wcwidth(ucs)
      let str = substitute(str, mx_first, '', '')
    endwhile
    return width
  endfunction"}}}

  " UTF-8 only.
  function! s:wcwidth(ucs) "{{{
    let ucs = a:ucs
    if (ucs >= 0x1100
          \  && (ucs <= 0x115f
          \  || ucs == 0x2329
          \  || ucs == 0x232a
          \  || (ucs >= 0x2e80 && ucs <= 0xa4cf
          \      && ucs != 0x303f)
          \  || (ucs >= 0xac00 && ucs <= 0xd7a3)
          \  || (ucs >= 0xf900 && ucs <= 0xfaff)
          \  || (ucs >= 0xfe30 && ucs <= 0xfe6f)
          \  || (ucs >= 0xff00 && ucs <= 0xff60)
          \  || (ucs >= 0xffe0 && ucs <= 0xffe6)
          \  || (ucs >= 0x20000 && ucs <= 0x2fffd)
          \  || (ucs >= 0x30000 && ucs <= 0x3fffd)
          \  ))
      return 2
    endif
    return 1
  endfunction"}}}
endif

if argc() == 8 &&
      \ (argv(0) ==# 'load_from_file' || argv(0) ==# 'load_from_tags')
  try
    call s:main(argv())
  catch
    call writefile([v:throwpoint, v:exception],
          \     fnamemodify(argv(1), ':h:h').'/async_error_log')
  endtry

  qall!
else
  function! neocomplcache#async_cache#main(argv) "{{{
    call s:main(a:argv)
  endfunction"}}}
endif

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/cache.vim
================================================
"=============================================================================
" FILE: cache.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 26 Sep 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditionneocomplcache#cache#
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

" Cache loader.
function! neocomplcache#cache#check_cache_list(cache_dir, key, async_cache_dictionary, index_keyword_list, ...) "{{{
  if !has_key(a:async_cache_dictionary, a:key)
    return
  endif

  let is_string = get(a:000, 0, 0)

  let keyword_list = []
  let cache_list = a:async_cache_dictionary[a:key]
  for cache in cache_list
    if filereadable(cache.cachename)
      let keyword_list += neocomplcache#cache#load_from_cache(
            \ a:cache_dir, cache.filename, is_string)
    endif
  endfor

  call neocomplcache#cache#list2index(keyword_list, a:index_keyword_list, is_string)
  call filter(cache_list, '!filereadable(v:val.cachename)')

  if empty(cache_list)
    " Delete from dictionary.
    call remove(a:async_cache_dictionary, a:key)
  endif
endfunction"}}}
function! neocomplcache#cache#check_cache(cache_dir, key, async_cache_dictionary, keyword_list_dictionary, ...) "{{{
  let is_string = get(a:000, 0, 0)

  " Caching.
  if !has_key(a:keyword_list_dictionary, a:key)
    let a:keyword_list_dictionary[a:key] = {}
  endif
  return neocomplcache#cache#check_cache_list(
        \ a:cache_dir, a:key, a:async_cache_dictionary,
        \ a:keyword_list_dictionary[a:key], is_string)
endfunction"}}}
function! neocomplcache#cache#load_from_cache(cache_dir, filename, ...) "{{{
  let is_string = get(a:000, 0, 0)

  try
    let list = eval(get(neocomplcache#cache#readfile(
          \ a:cache_dir, a:filename), 0, '[]'))
    if !empty(list) && is_string && type(list[0]) != type('')
      " Type check.
      throw 'Type error'
    endif

    return list
  catch
    " Delete old cache file.
    let cache_name =
          \ neocomplcache#cache#encode_name(a:cache_dir, a:filename)
    if filereadable(cache_name)
      call delete(cache_name)
    endif

    return []
  endtry
endfunction"}}}
function! neocomplcache#cache#index_load_from_cache(cache_dir, filename, ...) "{{{
  let is_string = get(a:000, 0, 0)
  let keyword_lists = {}

  let completion_length = 2
  for keyword in neocomplcache#cache#load_from_cache(
        \ a:cache_dir, a:filename, is_string)
    let key = tolower(
          \ (is_string ? keyword : keyword.word)[: completion_length-1])
    if !has_key(keyword_lists, key)
      let keyword_lists[key] = []
    endif
    call add(keyword_lists[key], keyword)
  endfor

  return keyword_lists
endfunction"}}}
function! neocomplcache#cache#list2index(list, dictionary, is_string) "{{{
  let completion_length = 2
  for keyword in a:list
    let word = a:is_string ? keyword : keyword.word

    let key = tolower(word[: completion_length-1])
    if !has_key(a:dictionary, key)
      let a:dictionary[key] = {}
    endif
    let a:dictionary[key][word] = keyword
  endfor

  return a:dictionary
endfunction"}}}

function! neocomplcache#cache#save_cache(cache_dir, filename, keyword_list) "{{{
  if neocomplcache#util#is_sudo()
    return
  endif

  call neocomplcache#cache#writefile(
        \ a:cache_dir, a:filename, [string(a:keyword_list)])
endfunction"}}}
function! neocomplcache#cache#save_cache_old(cache_dir, filename, keyword_list) "{{{
  if neocomplcache#util#is_sudo()
    return
  endif

  " Create dictionary key.
  for keyword in a:keyword_list
    if !has_key(keyword, 'abbr')
      let keyword.abbr = keyword.word
    endif
    if !has_key(keyword, 'kind')
      let keyword.kind = ''
    endif
    if !has_key(keyword, 'menu')
      let keyword.menu = ''
    endif
  endfor

  " Output cache.
  let word_list = []
  for keyword in a:keyword_list
    call add(word_list, printf('%s|||%s|||%s|||%s',
          \keyword.word, keyword.abbr, keyword.menu, keyword.kind))
  endfor

  call neocomplcache#cache#writefile(
        \ a:cache_dir, a:filename, word_list)
endfunction"}}}

" Cache helper.
function! neocomplcache#cache#getfilename(cache_dir, filename) "{{{
  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  return s:_encode_name(cache_dir, a:filename)
endfunction"}}}
function! neocomplcache#cache#filereadable(cache_dir, filename) "{{{
  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  let cache_name = s:_encode_name(cache_dir, a:filename)
  return filereadable(cache_name)
endfunction"}}}
function! neocomplcache#cache#readfile(cache_dir, filename) "{{{
  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  let cache_name = s:_encode_name(cache_dir, a:filename)
  return filereadable(cache_name) ? readfile(cache_name) : []
endfunction"}}}
function! neocomplcache#cache#writefile(cache_dir, filename, list) "{{{
  if neocomplcache#util#is_sudo()
    return
  endif

  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  let cache_name = s:_encode_name(cache_dir, a:filename)

  call writefile(a:list, cache_name)
endfunction"}}}
function! neocomplcache#cache#encode_name(cache_dir, filename)
  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  return s:_encode_name(cache_dir, a:filename)
endfunction
function! neocomplcache#cache#check_old_cache(cache_dir, filename) "{{{
  let cache_dir = neocomplcache#get_temporary_directory() . '/' . a:cache_dir
  " Check old cache file.
  let cache_name = s:_encode_name(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"}}}

let s:sdir = neocomplcache#util#substitute_path_separator(
      \ fnamemodify(expand('<sfile>'), ':p:h'))

function! neocomplcache#cache#async_load_from_file(cache_dir, filename, pattern, mark) "{{{
  if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename)
        \ || neocomplcache#util#is_sudo()
    return neocomplcache#cache#encode_name(a:cache_dir, a:filename)
  endif

  let pattern_file_name =
        \ neocomplcache#cache#encode_name('keyword_patterns', a:filename)
  let cache_name =
        \ neocomplcache#cache#encode_name(a:cache_dir, a:filename)

  " Create pattern file.
  call neocomplcache#cache#writefile(
        \ 'keyword_patterns', a:filename, [a:pattern])

  " args: funcname, outputname, filename pattern mark
  "       minlen maxlen encoding
  let fileencoding =
        \ &fileencoding == '' ? &encoding : &fileencoding
  let argv = [
        \  'load_from_file', cache_name, a:filename, pattern_file_name, a:mark,
        \  g:neocomplcache_min_keyword_length,
        \  g:neocomplcache_max_menu_width, fileencoding
        \ ]
  return s:async_load(argv, a:cache_dir, a:filename)
endfunction"}}}
function! neocomplcache#cache#async_load_from_tags(cache_dir, filename, filetype, mark, is_create_tags) "{{{
  if !neocomplcache#cache#check_old_cache(a:cache_dir, a:filename)
        \ || neocomplcache#util#is_sudo()
    return neocomplcache#cache#encode_name(a:cache_dir, a:filename)
  endif

  let cache_name =
        \ neocomplcache#cache#encode_name(a:cache_dir, a:filename)
  let pattern_file_name =
        \ neocomplcache#cache#encode_name('tags_pattens', a:filename)

  if a:is_create_tags
    if !executable(g:neocomplcache_ctags_program)
      echoerr 'Create tags error! Please install '
            \ . g:neocomplcache_ctags_program . '.'
      return neocomplcache#cache#encode_name(a:cache_dir, a:filename)
    endif

    " Create tags file.
    let tags_file_name =
          \ neocomplcache#cache#encode_name('tags_output', a:filename)

    let default = get(g:neocomplcache_ctags_arguments_list, '_', '')
    let args = get(g:neocomplcache_ctags_arguments_list, a:filetype, default)

    if has('win32') || has('win64')
      let filename =
            \ neocomplcache#util#substitute_path_separator(a:filename)
      let command = printf('%s -f "%s" %s "%s" ',
            \ g:neocomplcache_ctags_program, tags_file_name, args, filename)
    else
      let command = printf('%s -f ''%s'' 2>/dev/null %s ''%s''',
            \ g:neocomplcache_ctags_program, tags_file_name, args, a:filename)
    endif

    if neocomplcache#has_vimproc()
      call vimproc#system_bg(command)
    else
      call system(command)
    endif
  else
    let tags_file_name = '$dummy$'
  endif

  let filter_pattern =
        \ get(g:neocomplcache_tags_filter_patterns, a:filetype, '')
  call neocomplcache#cache#writefile('tags_pattens', a:filename,
        \ [neocomplcache#get_keyword_pattern(),
        \  tags_file_name, filter_pattern, a:filetype])

  " args: funcname, outputname, filename pattern mark
  "       minlen maxlen encoding
  let fileencoding = &fileencoding == '' ? &encoding : &fileencoding
  let argv = [
        \  'load_from_tags', cache_name, a:filename, pattern_file_name, a:mark,
        \  g:neocomplcache_min_keyword_length,
        \  g:neocomplcache_max_menu_width, fileencoding
        \ ]
  return s:async_load(argv, a:cache_dir, a:filename)
endfunction"}}}
function! s:async_load(argv, cache_dir, filename) "{{{
  " if 0
  if neocomplcache#has_vimproc()
    let paths = vimproc#get_command_name(v:progname, $PATH, -1)
    if empty(paths)
      if has('gui_macvim')
        " MacVim check.
        if !executable('/Applications/MacVim.app/Contents/MacOS/Vim')
          call neocomplcache#print_error(
                \ 'You installed MacVim in not default directory!'.
                \ ' You must add MacVim installed path in $PATH.')
          let g:neocomplcache_use_vimproc = 0
          return
        endif

        let vim_path = '/Applications/MacVim.app/Contents/MacOS/Vim'
      else
        call neocomplcache#print_error(
              \ printf('Vim path : "%s" is not found.'.
              \        ' You must add "%s" installed path in $PATH.',
              \        v:progname, v:progname))
        let g:neocomplcache_use_vimproc = 0
        return
      endif
    else
      let base_path = neocomplcache#util#substitute_path_separator(
            \ fnamemodify(paths[0], ':p:h'))

      let vim_path = base_path .
            \ (neocomplcache#util#is_windows() ? '/vim.exe' : '/vim')
    endif

    if !executable(vim_path) && neocomplcache#util#is_mac()
      " Note: Search "Vim" instead of vim.
      let vim_path = base_path. '/Vim'
    endif

    if !executable(vim_path)
      call neocomplcache#print_error(
            \ printf('Vim path : "%s" is not executable.', vim_path))
      let g:neocomplcache_use_vimproc = 0
      return
    endif

    let args = [vim_path, '-u', 'NONE', '-i', 'NONE', '-n',
          \       '-N', '-S', s:sdir.'/async_cache.vim']
          \ + a:argv
    call vimproc#system_bg(args)
    " call vimproc#system(args)
    " call system(join(args))
  else
    call neocomplcache#async_cache#main(a:argv)
  endif

  return neocomplcache#cache#encode_name(a:cache_dir, a:filename)
endfunction"}}}

function! s:_encode_name(cache_dir, filename)
  " 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

" Check md5.
try
  call md5#md5()
  let s:exists_md5 = 1
catch
  let s:exists_md5 = 0
endtry

function! s:_create_hash(dir, str)
  if len(a:dir) + len(a:str) < 150
    let hash = substitute(substitute(
          \ a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g')
  elseif s:exists_md5
    " Use md5.vim.
    let hash = md5#md5(a:str)
  else
    " Use simple hash.
    let sum = 0
    for i in range(len(a:str))
      let sum += char2nr(a:str[i]) * (i + 1)
    endfor

    let hash = printf('%x', sum)
  endif

  return hash
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/commands.vim
================================================
"=============================================================================
" FILE: commands.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 12 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#commands#_initialize() "{{{
  command! -nargs=? Neco call s:display_neco(<q-args>)
  command! -nargs=1 NeoComplCacheAutoCompletionLength
        \ call s:set_auto_completion_length(<args>)
endfunction"}}}

function! neocomplcache#commands#_toggle_lock() "{{{
  if neocomplcache#get_current_neocomplcache().lock
    echo 'neocomplcache is unlocked!'
    call neocomplcache#commands#_unlock()
  else
    echo 'neocomplcache is locked!'
    call neocomplcache#commands#_lock()
  endif
endfunction"}}}

function! neocomplcache#commands#_lock() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.lock = 1
endfunction"}}}

function! neocomplcache#commands#_unlock() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.lock = 0
endfunction"}}}

function! neocomplcache#commands#_lock_source(source_name) "{{{
  if !neocomplcache#is_enabled()
    call neocomplcache#print_warning(
          \ 'neocomplcache is disabled! This command is ignored.')
    return
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let neocomplcache.lock_sources[a:source_name] = 1
endfunction"}}}

function! neocomplcache#commands#_unlock_source(source_name) "{{{
  if !neocomplcache#is_enabled()
    call neocomplcache#print_warning(
          \ 'neocomplcache is disabled! This command is ignored.')
    return
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let neocomplcache.lock_sources[a:source_name] = 1
endfunction"}}}

function! neocomplcache#commands#_clean() "{{{
  " Delete cache files.
  for directory in filter(neocomplcache#util#glob(
        \ g:neocomplcache_temporary_dir.'/*'), 'isdirectory(v:val)')
    for filename in filter(neocomplcache#util#glob(directory.'/*'),
          \ '!isdirectory(v:val)')
      call delete(filename)
    endfor
  endfor

  echo 'Cleaned cache files in: ' . g:neocomplcache_temporary_dir
endfunction"}}}

function! neocomplcache#commands#_set_file_type(filetype) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.filetype = a:filetype
endfunction"}}}

function! s:display_neco(number) "{{{
  let cmdheight_save = &cmdheight

  let animation = [
    \[
        \[
        \ "   A A",
        \ "~(-'_'-)"
        \],
        \[
        \ "      A A",
        \ "   ~(-'_'-)",
        \],
        \[
        \ "        A A",
        \ "     ~(-'_'-)",
        \],
        \[
        \ "          A A  ",
        \ "       ~(-'_'-)",
        \],
        \[
        \ "             A A",
        \ "          ~(-^_^-)",
        \],
    \],
    \[
        \[
        \ "   A A",
        \ "~(-'_'-)",
        \],
        \[
        \ "      A A",
        \ "   ~(-'_'-)",
        \],
        \[
        \ "        A A",
        \ "     ~(-'_'-)",
        \],
        \[
        \ "          A A  ",
        \ "       ~(-'_'-)",
        \],
        \[
        \ "             A A",
        \ "          ~(-'_'-)",
        \],
        \[
        \ "          A A  ",
        \ "       ~(-'_'-)"
        \],
        \[
        \ "        A A",
        \ "     ~(-'_'-)"
        \],
        \[
        \ "      A A",
        \ "   ~(-'_'-)"
        \],
        \[
        \ "   A A",
        \ "~(-'_'-)"
        \],
    \],
    \[
        \[
        \ "   A A",
        \ "~(-'_'-)",
        \],
        \[
        \ "        A A",
        \ "     ~(-'_'-)",
        \],
        \[
        \ "             A A",
        \ "          ~(-'_'-)",
        \],
        \[
        \ "                  A A",
        \ "               ~(-'_'-)",
        \],
        \[
        \ "                       A A",
        \ "                    ~(-'_'-)",
        \],
        \["                           A A",
        \ "                        ~(-'_'-)",
        \],
    \],
    \[
        \[
        \ "",
        \ "   A A",
        \ "~(-'_'-)",
        \],
        \["      A A",
        \ "   ~(-'_'-)",
        \ "",
        \],
        \[
        \ "",
        \ "        A A",
        \ "     ~(-'_'-)",
        \],
        \[
        \ "          A A  ",
        \ "       ~(-'_'-)",
        \ "",
        \],
        \[
        \ "",
        \ "             A A",
        \ "          ~(-^_^-)",
        \],
    \],
    \[
        \[
        \ "   A A        A A",
        \ "~(-'_'-)  -8(*'_'*)"
        \],
        \[
        \ "     A A        A A",
        \ "  ~(-'_'-)  -8(*'_'*)"
        \],
        \[
        \ "       A A        A A",
        \ "    ~(-'_'-)  -8(*'_'*)"
        \],
        \[
        \ "     A A        A A",
        \ "  ~(-'_'-)  -8(*'_'*)"
        \],
        \[
        \ "   A A        A A",
        \ "~(-'_'-)  -8(*'_'*)"
        \],
    \],
    \[
        \[
        \ "  A\\_A\\",
        \ "(=' .' ) ~w",
        \ "(,(\")(\")",
        \],
    \],
  \]

  let number = (a:number != '') ? a:number : len(animation)
  let anim = get(animation, number, animation[s:rand(len(animation) - 1)])
  let &cmdheight = len(anim[0])

  for frame in anim
    echo repeat("\n", &cmdheight-2)
    redraw
    echon join(frame, "\n")
    sleep 300m
  endfor
  redraw

  let &cmdheight = cmdheight_save
endfunction"}}}

function! s:rand(max) "{{{
  if !has('reltime')
    " Same value.
    return 0
  endif

  let time = reltime()[1]
  return (time < 0 ? -time : time)% (a:max + 1)
endfunction"}}}

function! s:set_auto_completion_length(len) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.completion_length = a:len
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/complete.vim
================================================
"=============================================================================
" FILE: complete.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 06 Jun 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#complete#manual_complete(findstart, base) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  if a:findstart
    let cur_text = neocomplcache#get_cur_text()
    if !neocomplcache#is_enabled()
          \ || neocomplcache#helper#is_omni_complete(cur_text)
      call neocomplcache#helper#clear_result()
      let &l:completefunc = 'neocomplcache#complete#manual_complete'

      return (neocomplcache#is_prefetch()
            \ || g:neocomplcache_enable_insert_char_pre) ?
            \ -1 : -3
    endif

    " Get complete_pos.
    if neocomplcache#is_prefetch() && !empty(neocomplcache.complete_results)
      " Use prefetch results.
    else
      let neocomplcache.complete_results =
            \ neocomplcache#complete#_get_results(cur_text)
    endif
    let complete_pos =
          \ neocomplcache#complete#_get_complete_pos(neocomplcache.complete_results)

    if complete_pos < 0
      call neocomplcache#helper#clear_result()

      let neocomplcache = neocomplcache#get_current_neocomplcache()
      let complete_pos = (neocomplcache#is_prefetch() ||
            \ g:neocomplcache_enable_insert_char_pre ||
            \ neocomplcache#get_current_neocomplcache().skipped) ?  -1 : -3
      let neocomplcache.skipped = 0
    endif

    return complete_pos
  else
    let complete_pos = neocomplcache#complete#_get_complete_pos(
          \ neocomplcache.complete_results)
    let neocomplcache.candidates = neocomplcache#complete#_get_words(
          \ neocomplcache.complete_results, complete_pos, a:base)
    let neocomplcache.complete_str = a:base

    if v:version > 703 || v:version == 703 && has('patch418')
      let dict = { 'words' : neocomplcache.candidates }

      if (g:neocomplcache_enable_cursor_hold_i
            \      || v:version > 703 || v:version == 703 && has('patch561'))
            \ && len(a:base) < g:neocomplcache_auto_completion_start_length
        " Note: If Vim is less than 7.3.561, it have broken register "." problem.
        let dict.refresh = 'always'
      endif
      return dict
    else
      return neocomplcache.candidates
    endif
  endif
endfunction"}}}

function! neocomplcache#complete#sources_manual_complete(findstart, base) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  if a:findstart
    if !neocomplcache#is_enabled()
      call neocomplcache#helper#clear_result()
      return -2
    endif

    " Get complete_pos.
    let complete_results = neocomplcache#complete#_get_results(
          \ neocomplcache#get_cur_text(1), neocomplcache.manual_sources)
    let neocomplcache.complete_pos =
          \ neocomplcache#complete#_get_complete_pos(complete_results)

    if neocomplcache.complete_pos < 0
      call neocomplcache#helper#clear_result()

      return -2
    endif

    let neocomplcache.complete_results = complete_results

    return neocomplcache.complete_pos
  endif

  let neocomplcache.complete_pos =
        \ neocomplcache#complete#_get_complete_pos(
        \     neocomplcache.complete_results)
  let candidates = neocomplcache#complete#_get_words(
        \ neocomplcache.complete_results,
        \ neocomplcache.complete_pos, a:base)

  let neocomplcache.candidates = candidates
  let neocomplcache.complete_str = a:base

  return candidates
endfunction"}}}

function! neocomplcache#complete#unite_complete(findstart, base) "{{{
  " Dummy.
  return a:findstart ? -1 : []
endfunction"}}}

function! neocomplcache#complete#auto_complete(findstart, base) "{{{
  return neocomplcache#complete#manual_complete(a:findstart, a:base)
endfunction"}}}

function! neocomplcache#complete#_get_results(cur_text, ...) "{{{
  if g:neocomplcache_enable_debug
    echomsg 'start get_complete_results'
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.start_time = reltime()

  let complete_results = call(
        \ 'neocomplcache#complete#_set_results_pos', [a:cur_text] + a:000)
  call neocomplcache#complete#_set_results_words(complete_results)

  return filter(complete_results,
        \ '!empty(v:val.neocomplcache__context.candidates)')
endfunction"}}}

function! neocomplcache#complete#_get_complete_pos(sources) "{{{
  if empty(a:sources)
    return -1
  endif

  return min([col('.')] + map(copy(a:sources),
        \ 'v:val.neocomplcache__context.complete_pos'))
endfunction"}}}

function! neocomplcache#complete#_get_words(sources, complete_pos, complete_str) "{{{
  let frequencies = neocomplcache#variables#get_frequencies()
  if exists('*neocomplcache#sources#buffer_complete#get_frequencies')
    let frequencies = extend(copy(
          \ neocomplcache#sources#buffer_complete#get_frequencies()),
          \ frequencies)
  endif

  " Append prefix.
  let candidates = []
  let len_words = 0
  for source in sort(filter(copy(a:sources),
        \ '!empty(v:val.neocomplcache__context.candidates)'),
        \  's:compare_source_rank')
    let context = source.neocomplcache__context
    let words =
          \ type(context.candidates[0]) == type('') ?
          \ map(copy(context.candidates), "{'word': v:val}") :
          \ deepcopy(context.candidates)
    let context.candidates = words

    call neocomplcache#helper#call_hook(
          \ source, 'on_post_filter', {})

    if context.complete_pos > a:complete_pos
      let prefix = a:complete_str[: context.complete_pos
            \                            - a:complete_pos - 1]

      for candidate in words
        let candidate.word = prefix . candidate.word
      endfor
    endif

    for candidate in words
      if !has_key(candidate, 'menu') && has_key(source, 'mark')
        " Set default menu.
        let candidate.menu = source.mark
      endif
      if has_key(frequencies, candidate.word)
        let candidate.rank = frequencies[candidate.word]
      endif
    endfor

    let words = neocomplcache#helper#call_filters(
          \ source.sorters, source, {})

    if source.max_candidates > 0
      let words = words[: len(source.max_candidates)-1]
    endif

    let words = neocomplcache#helper#call_filters(
          \ source.converters, source, {})

    let candidates += words
    let len_words += len(words)

    if g:neocomplcache_max_list > 0
          \ && len_words > g:neocomplcache_max_list
      break
    endif

    if neocomplcache#complete_check()
      return []
    endif
  endfor

  if g:neocomplcache_max_list > 0
    let candidates = candidates[: g:neocomplcache_max_list]
  endif

  " Check dup and set icase.
  let icase = g:neocomplcache_enable_ignore_case &&
        \!(g:neocomplcache_enable_smart_case && a:complete_str =~ '\u')
        \ && !neocomplcache#is_text_mode()
  for candidate in candidates
    if has_key(candidate, 'kind') && candidate.kind == ''
      " Remove kind key.
      call remove(candidate, 'kind')
    endif

    let candidate.icase = icase
  endfor

  if neocomplcache#complete_check()
    return []
  endif

  return candidates
endfunction"}}}
function! neocomplcache#complete#_set_results_pos(cur_text, ...) "{{{
  " Set context filetype.
  call neocomplcache#context_filetype#set()

  " Initialize sources.
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  for source in filter(values(neocomplcache#variables#get_sources()),
        \ '!v:val.loaded && (empty(v:val.filetypes) ||
        \       get(v:val.filetypes,
        \             neocomplcache.context_filetype, 0))')
    call neocomplcache#helper#call_hook(source, 'on_init', {})
    let source.loaded = 1
  endfor

  let sources = filter(copy(get(a:000, 0,
        \ neocomplcache#helper#get_sources_list())), 'v:val.loaded')
  if a:0 < 1
    call filter(sources, '!neocomplcache#is_plugin_locked(v:key)')
  endif

  " Try source completion. "{{{
  let complete_sources = []
  for source in values(sources)
    let context = source.neocomplcache__context
    let context.input = a:cur_text
    let context.complete_pos = -1
    let context.complete_str = ''
    let context.candidates = []

    let pos = winsaveview()

    try
      let complete_pos =
            \ has_key(source, 'get_keyword_pos') ?
            \ source.get_keyword_pos(context.input) :
            \ has_key(source, 'get_complete_position') ?
            \ source.get_complete_position(context) :
            \ neocomplcache#match_word(context.input)[0]
    catch
      call neocomplcache#print_error(v:throwpoint)
      call neocomplcache#print_error(v:exception)
      call neocomplcache#print_error(
            \ 'Error occurred in source''s get_complete_position()!')
      call neocomplcache#print_error(
            \ 'Source name is ' . source.name)
      return complete_sources
    finally
      if winsaveview() != pos
        call winrestview(pos)
      endif
    endtry

    if complete_pos < 0
      continue
    endif

    let complete_str = context.input[complete_pos :]
    if neocomplcache#is_auto_complete() &&
          \ neocomplcache#util#mb_strlen(complete_str)
          \     < neocomplcache#get_completion_length(source.name)
      " Skip.
      continue
    endif

    let context.complete_pos = complete_pos
    let context.complete_str = complete_str
    call add(complete_sources, source)
  endfor
  "}}}

  return complete_sources
endfunction"}}}
function! neocomplcache#complete#_set_results_words(sources) "{{{
  " Try source completion.
  for source in a:sources
    if neocomplcache#complete_check()
      return
    endif

    " Save options.
    let ignorecase_save = &ignorecase

    let context = source.neocomplcache__context

    if neocomplcache#is_text_mode()
      let &ignorecase = 1
    elseif g:neocomplcache_enable_smart_case
          \ && context.complete_str =~ '\u'
      let &ignorecase = 0
    else
      let &ignorecase = g:neocomplcache_enable_ignore_case
    endif

    let pos = winsaveview()

    try
      let context.candidates = has_key(source, 'get_keyword_list') ?
            \ source.get_keyword_list(context.complete_str) :
            \  has_key(source, 'get_complete_words') ?
            \ source.get_complete_words(
            \   context.complete_pos, context.complete_str) :
            \ source.gather_candidates(context)
    catch
      call neocomplcache#print_error(v:throwpoint)
      call neocomplcache#print_error(v:exception)
      call neocomplcache#print_error(
            \ 'Source name is ' . source.name)
      call neocomplcache#print_error(
            \ 'Error occurred in source''s gather_candidates()!')
      return
    finally
      if winsaveview() != pos
        call winrestview(pos)
      endif
    endtry

    if g:neocomplcache_enable_debug
      echomsg source.name
    endif

    let &ignorecase = ignorecase_save
  endfor
endfunction"}}}

" Source rank order. "{{{
function! s:compare_source_rank(i1, i2)
  return a:i2.rank - a:i1.rank
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/context_filetype.vim
================================================
"=============================================================================
" FILE: context_filetype.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 18 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#context_filetype#initialize() "{{{
  " Initialize context filetype lists.
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_context_filetype_lists', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'c,cpp', [
        \ {'filetype' : 'masm',
        \  'start' : '_*asm_*\s\+\h\w*', 'end' : '$'},
        \ {'filetype' : 'masm',
        \  'start' : '_*asm_*\s*\%(\n\s*\)\?{', 'end' : '}'},
        \ {'filetype' : 'gas',
        \  'start' : '_*asm_*\s*\%(_*volatile_*\s*\)\?(', 'end' : ');'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'd', [
        \ {'filetype' : 'masm',
        \  'start' : 'asm\s*\%(\n\s*\)\?{', 'end' : '}'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'perl6', [
        \ {'filetype' : 'pir', 'start' : 'Q:PIR\s*{', 'end' : '}'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'vimshell', [
        \ {'filetype' : 'vim',
        \  'start' : 'vexe \([''"]\)', 'end' : '\\\@<!\1'},
        \ {'filetype' : 'vim', 'start' : ' :\w*', 'end' : '\n'},
        \ {'filetype' : 'vim', 'start' : ' vexe\s\+', 'end' : '\n'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'eruby', [
        \ {'filetype' : 'ruby', 'start' : '<%[=#]\?', 'end' : '%>'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'vim', [
        \ {'filetype' : 'python',
        \  'start' : '^\s*py\%[thon\]3\? <<\s*\(\h\w*\)', 'end' : '^\1'},
        \ {'filetype' : 'ruby',
        \  'start' : '^\s*rub\%[y\] <<\s*\(\h\w*\)', 'end' : '^\1'},
        \ {'filetype' : 'lua',
        \  'start' : '^\s*lua <<\s*\(\h\w*\)', 'end' : '^\1'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'html,xhtml', [
        \ {'filetype' : 'javascript', 'start' :
        \'<script\%( [^>]*\)\? type="text/javascript"\%( [^>]*\)\?>',
        \  'end' : '</script>'},
        \ {'filetype' : 'coffee', 'start' :
        \'<script\%( [^>]*\)\? type="text/coffeescript"\%( [^>]*\)\?>',
        \  'end' : '</script>'},
        \ {'filetype' : 'css', 'start' :
        \'<style\%( [^>]*\)\? type="text/css"\%( [^>]*\)\?>',
        \  'end' : '</style>'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'python', [
        \ {'filetype' : 'vim',
        \  'start' : 'vim.command\s*(\([''"]\)', 'end' : '\\\@<!\1\s*)'},
        \ {'filetype' : 'vim',
        \  'start' : 'vim.eval\s*(\([''"]\)', 'end' : '\\\@<!\1\s*)'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'help', [
        \ {'filetype' : 'vim', 'start' : '^>', 'end' : '^<'},
        \])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_context_filetype_lists',
        \ 'nyaos,int-nyaos', [
        \ {'filetype' : 'lua',
        \  'start' : '\<lua_e\s\+\(["'']\)', 'end' : '^\1'},
        \])
endfunction"}}}

function! neocomplcache#context_filetype#set() "{{{
  let old_filetype = neocomplcache#get_current_neocomplcache().filetype
  if old_filetype == ''
    let old_filetype = &filetype
  endif
  if old_filetype == ''
    let old_filetype = 'nothing'
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let dup_check = {}
  while 1
    let new_filetype = neocomplcache#context_filetype#get(old_filetype)

    " Check filetype root.
    if get(dup_check, old_filetype, '') ==# new_filetype
      let neocomplcache.context_filetype = old_filetype
      break
    endif

    " Save old -> new filetype graph.
    let dup_check[old_filetype] = new_filetype
    let old_filetype = new_filetype
  endwhile

  return neocomplcache.context_filetype
endfunction"}}}
function! neocomplcache#context_filetype#get(filetype) "{{{
  " Default.
  let filetype = a:filetype
  if filetype == ''
    let filetype = 'nothing'
  endif

  " Default range.
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let pos = [line('.'), col('.')]
  for include in get(g:neocomplcache_context_filetype_lists, filetype, [])
    let start_backward = searchpos(include.start, 'bneW')

    " Check pos > start.
    if start_backward[0] == 0 || s:compare_pos(start_backward, pos) > 0
      continue
    endif

    let end_pattern = include.end
    if end_pattern =~ '\\1'
      let match_list = matchlist(getline(start_backward[0]), include.start)
      let end_pattern = substitute(end_pattern, '\\1', '\=match_list[1]', 'g')
    endif
    let end_forward = searchpos(end_pattern, 'nW')
    if end_forward[0] == 0
      let end_forward = [line('$'), len(getline('$'))+1]
    endif

    " Check end > pos.
    if s:compare_pos(pos, end_forward) > 0
      continue
    endif

    let end_backward = searchpos(end_pattern, 'bnW')

    " Check start <= end.
    if s:compare_pos(start_backward, end_backward) < 0
      continue
    endif

    if start_backward[1] == len(getline(start_backward[0]))
      " Next line.
      let start_backward[0] += 1
      let start_backward[1] = 1
    endif
    if end_forward[1] == 1
      " Previous line.
      let end_forward[0] -= 1
      let end_forward[1] = len(getline(end_forward[0]))
    endif

    let neocomplcache.context_filetype_range =
          \ [ start_backward, end_forward ]
    return include.filetype
  endfor

  return filetype
endfunction"}}}

function! s:compare_pos(i1, i2)
  return a:i1[0] == a:i2[0] ? a:i1[1] - a:i2[1] : a:i1[0] - a:i2[0]
endfunction"

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/converter_abbr.vim
================================================
"=============================================================================
" FILE: converter_abbr.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 06 Jun 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#converter_abbr#define() "{{{
  return s:converter
endfunction"}}}

let s:converter = {
      \ 'name' : 'converter_abbr',
      \ 'description' : 'abbr converter',
      \}

function! s:converter.filter(context) "{{{
  if g:neocomplcache_max_keyword_width < 0
    return a:context.candidates
  endif

  for candidate in a:context.candidates
    let abbr = get(candidate, 'abbr', candidate.word)
    if len(abbr) > g:neocomplcache_max_keyword_width
      let len = neocomplcache#util#wcswidth(abbr)

      if len > g:neocomplcache_max_keyword_width
        let candidate.abbr = neocomplcache#util#truncate_smart(
              \ abbr, g:neocomplcache_max_keyword_width,
              \ g:neocomplcache_max_keyword_width/2, '..')
      endif
    endif
  endfor

  return a:context.candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/converter_case.vim
================================================
"=============================================================================
" FILE: converter_case.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 02 Jun 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#converter_case#define() "{{{
  return s:converter
endfunction"}}}

let s:converter = {
      \ 'name' : 'converter_case',
      \ 'description' : 'case converter',
      \}

function! s:converter.filter(context) "{{{
  if !neocomplcache#is_text_mode() && !neocomplcache#within_comment()
    return a:context.candidates
  endif

  let convert_candidates = filter(copy(a:context.candidates),
        \ "get(v:val, 'neocomplcache__convertable', 1)
        \  && v:val.word =~ '^[a-zA-Z0-9_''-]\\+$'")

  if a:context.complete_str =~ '^\l\+$'
    for candidate in convert_candidates
      let candidate.word = tolower(candidate.word)
      if has_key(candidate, 'abbr')
        let candidate.abbr = tolower(candidate.abbr)
      endif
    endfor
  elseif a:context.complete_str =~ '^\u\+$'
    for candidate in convert_candidates
      let candidate.word = toupper(candidate.word)
      if has_key(candidate, 'abbr')
        let candidate.abbr = toupper(candidate.abbr)
      endif
    endfor
  elseif a:context.complete_str =~ '^\u\l\+$'
    for candidate in convert_candidates
      let candidate.word = toupper(candidate.word[0]).
            \ tolower(candidate.word[1:])
      if has_key(candidate, 'abbr')
        let candidate.abbr = toupper(candidate.abbr[0]).
              \ tolower(candidate.abbr[1:])
      endif
    endfor
  endif

  return a:context.candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/converter_delimiter.vim
================================================
"=============================================================================
" FILE: converter_delimiter.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 06 Jun 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#converter_delimiter#define() "{{{
  return s:converter
endfunction"}}}

let s:converter = {
      \ 'name' : 'converter_delimiter',
      \ 'description' : 'delimiter converter',
      \}

function! s:converter.filter(context) "{{{
  if g:neocomplcache_max_keyword_width < 0
    return a:context.candidates
  endif

  " Delimiter check.
  let filetype = neocomplcache#get_context_filetype()

  let next_keyword = neocomplcache#filters#
        \converter_remove_next_keyword#get_next_keyword(a:context.source_name)
  for delimiter in ['/'] +
        \ get(g:neocomplcache_delimiter_patterns, filetype, [])
    " Count match.
    let delim_cnt = 0
    let matchend = matchend(a:context.complete_str, delimiter)
    while matchend >= 0
      let matchend = matchend(a:context.complete_str,
            \ delimiter, matchend)
      let delim_cnt += 1
    endwhile

    for candidate in a:context.candidates
      let split_list = split(candidate.word, delimiter.'\ze.', 1)
      if len(split_list) > 1
        let delimiter_sub = substitute(
              \ delimiter, '\\\([.^$]\)', '\1', 'g')
        let candidate.word = join(split_list[ : delim_cnt], delimiter_sub)
        let candidate.abbr = join(
              \ split(get(candidate, 'abbr', candidate.word),
              \             delimiter.'\ze.', 1)[ : delim_cnt],
              \ delimiter_sub)

        if g:neocomplcache_max_keyword_width >= 0
              \ && len(candidate.abbr) > g:neocomplcache_max_keyword_width
          let candidate.abbr = substitute(candidate.abbr,
                \ '\(\h\)\w*'.delimiter, '\1'.delimiter_sub, 'g')
        endif
        if delim_cnt+1 < len(split_list)
          let candidate.abbr .= delimiter_sub . '~'
          let candidate.dup = 0

          if g:neocomplcache_enable_auto_delimiter && next_keyword == ''
            let candidate.word .= delimiter_sub
          endif
        endif
      endif
    endfor
  endfor

  return a:context.candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/converter_nothing.vim
================================================
"=============================================================================
" FILE: converter_nothing.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 24 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#converter_nothing#define() "{{{
  return s:converter
endfunction"}}}

let s:converter = {
      \ 'name' : 'converter_nothing',
      \ 'description' : 'nothing converter',
      \}

function! s:converter.filter(context) "{{{
  " Nothing.
  return a:context.candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/converter_remove_next_keyword.vim
================================================
"=============================================================================
" FILE: converter_remove_next_keyword.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 31 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#converter_remove_next_keyword#define() "{{{
  return s:converter
endfunction"}}}

let s:converter = {
      \ 'name' : 'converter_remove_next_keyword',
      \ 'description' : 'remove next keyword converter',
      \}

function! s:converter.filter(context) "{{{
  " Remove next keyword.
  let next_keyword = neocomplcache#filters#
        \converter_remove_next_keyword#get_next_keyword(a:context.source_name)
  if next_keyword == ''
    return a:context.candidates
  endif

  let next_keyword = substitute(
        \ substitute(escape(next_keyword,
        \ '~" \.^$*[]'), "'", "''", 'g'), ')$', '', '').'$'

  " No ignorecase.
  let ignorecase_save = &ignorecase
  let &ignorecase = 0
  try
    for r in a:context.candidates
      let pos = match(r.word, next_keyword)
      if pos >= 0
        if !has_key(r, 'abbr')
          let r.abbr = r.word
        endif

        let r.word = r.word[: pos-1]
      endif
    endfor
  finally
    let &ignorecase = ignorecase_save
  endtry

  return a:context.candidates
endfunction"}}}

function! neocomplcache#filters#converter_remove_next_keyword#get_next_keyword(source_name) "{{{
  let pattern = '^\%(' .
        \ ((a:source_name ==# 'filename_complete' ||
        \  a:source_name ==# 'filename_complete') ?
        \   neocomplcache#get_next_keyword_pattern('filename') :
        \   neocomplcache#get_next_keyword_pattern()) . '\m\)'

  let next_keyword = matchstr('a'.
        \ getline('.')[len(neocomplcache#get_cur_text(1)) :], pattern)[1:]
  return next_keyword
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/matcher_fuzzy.vim
================================================
"=============================================================================
" FILE: matcher_fuzzy.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 24 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#matcher_fuzzy#define() "{{{
  return s:matcher
endfunction"}}}

let s:matcher = {
      \ 'name' : 'matcher_fuzzy',
      \ 'description' : 'fuzzy matcher',
      \}

function! s:matcher.filter(context) "{{{
  " Todo:
  return []
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/matcher_head.vim
================================================
"=============================================================================
" FILE: matcher_head.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 25 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#matcher_head#define() "{{{
  return s:matcher
endfunction"}}}

let s:matcher = {
      \ 'name' : 'matcher_head',
      \ 'description' : 'head matcher',
      \}

function! s:matcher.filter(context) "{{{
  " Todo:
  return []
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/matcher_old.vim
================================================
"=============================================================================
" FILE: matcher_old.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 25 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#matcher_old#define() "{{{
  return s:matcher
endfunction"}}}

let s:matcher = {
      \ 'name' : 'matcher_old',
      \ 'description' : 'old matcher',
      \}

function! s:matcher.filter(candidates, context) "{{{
  if a:context.input == ''
    return neocomplcache#util#filter_matcher(
          \ a:candidates, '', a:context)
  endif

  let candidates = a:candidates
  for input in a:context.input_list
    let candidates = neocomplcache#filters#matcher_old#glob_matcher(
          \ candidates, input, a:context)
  endfor

  return candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/sorter_length.vim
================================================
"=============================================================================
" FILE: sorter_length.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 09 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#sorter_length#define() "{{{
  return s:sorter
endfunction"}}}

let s:sorter = {
      \ 'name' : 'sorter_length',
      \ 'description' : 'sort by length order',
      \}

function! s:sorter.filter(context) "{{{
  return sort(a:context.candidates, 's:compare')
endfunction"}}}

function! s:compare(i1, i2)
  let diff = len(a:i1.word) - len(a:i2.word)
  if !diff
    let diff = (a:i1.word ># a:i2.word) ? 1 : -1
  endif
  return diff
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/sorter_nothing.vim
================================================
"=============================================================================
" FILE: sorter_nothing.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 24 Apr 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#sorter_nothing#define() "{{{
  return s:sorter
endfunction"}}}

let s:sorter = {
      \ 'name' : 'sorter_nothing',
      \ 'description' : 'nothing sorter',
      \}

function! s:sorter.filter(context) "{{{
  " Nothing.
  return a:candidates
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters/sorter_rank.vim
================================================
"=============================================================================
" FILE: sorter_rank.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 09 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#sorter_rank#define() "{{{
  return s:sorter
endfunction"}}}

let s:sorter = {
      \ 'name' : 'sorter_rank',
      \ 'description' : 'sort by matched rank order',
      \}

function! s:sorter.filter(context) "{{{
  return sort(a:context.candidates, 's:compare')
endfunction"}}}

function! s:compare(i1, i2)
  let diff = (get(a:i2, 'rank', 0) - get(a:i1, 'rank', 0))
  return (diff != 0) ? diff : (a:i1.word ># a:i2.word) ? 1 : -1
endfunction"

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/filters.vim
================================================
"=============================================================================
" FILE: filters.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 28 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#filters#keyword_filter(list, complete_str) "{{{
  let complete_str = a:complete_str

  if g:neocomplcache_enable_debug
    echomsg len(a:list)
  endif

  " Delimiter check.
  let filetype = neocomplcache#get_context_filetype()
  for delimiter in get(g:neocomplcache_delimiter_patterns, filetype, [])
    let complete_str = substitute(complete_str,
          \ delimiter, '*' . delimiter, 'g')
  endfor

  if complete_str == '' ||
        \ &l:completefunc ==# 'neocomplcache#complete#unite_complete' ||
        \ empty(a:list)
    return a:list
  elseif neocomplcache#check_match_filter(complete_str)
    " Match filter.
    let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word'

    let expr = printf('%s =~ %s',
          \ word, string('^' .
          \ neocomplcache#keyword_escape(complete_str)))
    if neocomplcache#is_auto_complete()
      " Don't complete cursor word.
      let expr .= printf(' && %s !=? a:complete_str', word)
    endif

    " Check head character.
    if complete_str[0] != '\' && complete_str[0] != '.'
      let expr = word.'[0] == ' .
            \ string(complete_str[0]) .' && ' . expr
    endif

    call neocomplcache#print_debug(expr)

    return filter(a:list, expr)
  else
    " Use fast filter.
    return s:head_filter(a:list, complete_str)
  endif
endfunction"}}}

function! s:head_filter(list, complete_str) "{{{
  let word = type(a:list[0]) == type('') ? 'v:val' : 'v:val.word'

  if &ignorecase
   let expr = printf('!stridx(tolower(%s), %s)',
          \ word, string(tolower(a:complete_str)))
  else
    let expr = printf('!stridx(%s, %s)',
          \ word, string(a:complete_str))
  endif

  if neocomplcache#is_auto_complete()
    " Don't complete cursor word.
    let expr .= printf(' && %s !=? a:complete_str', word)
  endif

  return filter(a:list, expr)
endfunction"}}}

function! neocomplcache#filters#dictionary_filter(dictionary, complete_str) "{{{
  if empty(a:dictionary)
    return []
  endif

  let completion_length = 2
  if len(a:complete_str) < completion_length ||
        \ neocomplcache#check_completion_length_match(
        \         a:complete_str, completion_length) ||
        \ &l:completefunc ==# 'neocomplcache#cunite_complete'
    return neocomplcache#keyword_filter(
          \ neocomplcache#unpack_dictionary(a:dictionary), a:complete_str)
  endif

  let key = tolower(a:complete_str[: completion_length-1])

  if !has_key(a:dictionary, key)
    return []
  endif

  let list = a:dictionary[key]
  if type(list) == type({})
    " Convert dictionary dictionary.
    unlet list
    let list = values(a:dictionary[key])
  else
    let list = copy(list)
  endif

  return (len(a:complete_str) == completion_length && &ignorecase
        \ && !neocomplcache#check_completion_length_match(
        \   a:complete_str, completion_length)) ?
        \ list : neocomplcache#keyword_filter(list, a:complete_str)
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/handler.vim
================================================
"=============================================================================
" FILE: handler.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 02 Oct 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#handler#_on_moved_i() "{{{
  " Get cursor word.
  let cur_text = neocomplcache#get_cur_text(1)

  call s:close_preview_window()
endfunction"}}}
function! neocomplcache#handler#_on_insert_enter() "{{{
  if &l:foldmethod ==# 'expr' && foldlevel('.') != 0
    foldopen
  endif
endfunction"}}}
function! neocomplcache#handler#_on_insert_leave() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let neocomplcache.cur_text = ''
  let neocomplcache.old_cur_text = ''

  call s:close_preview_window()
endfunction"}}}
function! neocomplcache#handler#_on_write_post() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  " Restore foldinfo.
  for winnr in filter(range(1, winnr('$')),
        \ "!empty(getwinvar(v:val, 'neocomplcache_foldinfo'))")
    let neocomplcache_foldinfo =
          \ getwinvar(winnr, 'neocomplcache_foldinfo')
    call setwinvar(winnr, '&foldmethod',
          \ neocomplcache_foldinfo.foldmethod)
    call setwinvar(winnr, '&foldexpr',
          \ neocomplcache_foldinfo.foldexpr)
    call setwinvar(winnr,
          \ 'neocomplcache_foldinfo', {})
  endfor
endfunction"}}}
function! neocomplcache#handler#_on_complete_done() "{{{
  " Get cursor word.
  let [_, candidate] = neocomplcache#match_word(
        \ neocomplcache#get_cur_text(1))
  if candidate == ''
    return
  endif

  let frequencies = neocomplcache#variables#get_frequencies()
  if !has_key(frequencies, candidate)
    let frequencies[candidate] = 20
  else
    let frequencies[candidate] += 20
  endif
endfunction"}}}
function! neocomplcache#handler#_change_update_time() "{{{
  if &updatetime > g:neocomplcache_cursor_hold_i_time
    " Change updatetime.
    let neocomplcache = neocomplcache#get_current_neocomplcache()
    let neocomplcache.update_time_save = &updatetime
    let &updatetime = g:neocomplcache_cursor_hold_i_time
  endif
endfunction"}}}
function! neocomplcache#handler#_restore_update_time() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  if &updatetime < neocomplcache.update_time_save
    " Restore updatetime.
    let &updatetime = neocomplcache.update_time_save
  endif
endfunction"}}}

function! neocomplcache#handler#_do_auto_complete(event) "{{{
  if s:check_in_do_auto_complete()
    return
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.skipped = 0
  let neocomplcache.event = a:event

  let cur_text = neocomplcache#get_cur_text(1)

  if g:neocomplcache_enable_debug
    echomsg 'cur_text = ' . cur_text
  endif

  " Prevent infinity loop.
  if s:is_skip_auto_complete(cur_text)
    " Make cache.
    if cur_text =~ '^\s*$\|\s\+$'
      if neocomplcache#is_enabled_source('buffer_complete')
        " Caching current cache line.
        call neocomplcache#sources#buffer_complete#caching_current_line()
      endif
      if neocomplcache#is_enabled_source('member_complete')
        " Caching current cache line.
        call neocomplcache#sources#member_complete#caching_current_line()
      endif
    endif

    if g:neocomplcache_enable_debug
      echomsg 'Skipped.'
    endif

    call neocomplcache#helper#clear_result()
    return
  endif

  let neocomplcache.old_cur_text = cur_text

  if neocomplcache#helper#is_omni_complete(cur_text)
    call feedkeys("\<Plug>(neocomplcache_start_omni_complete)")
    return
  endif

  " Check multibyte input or eskk.
  if neocomplcache#is_eskk_enabled()
        \ || neocomplcache#is_multibyte_input(cur_text)
    if g:neocomplcache_enable_debug
      echomsg 'Skipped.'
    endif

    return
  endif

  " Check complete position.
  let complete_results = neocomplcache#complete#_set_results_pos(cur_text)
  if empty(complete_results)
    if g:neocomplcache_enable_debug
      echomsg 'Skipped.'
    endif

    return
  endif

  let &l:completefunc = 'neocomplcache#complete#auto_complete'

  if neocomplcache#is_prefetch()
    " Do prefetch.
    let neocomplcache.complete_results =
          \ neocomplcache#complete#_get_results(cur_text)

    if empty(neocomplcache.complete_results)
      if g:neocomplcache_enable_debug
        echomsg 'Skipped.'
      endif

      " Skip completion.
      let &l:completefunc = 'neocomplcache#complete#manual_complete'
      call neocomplcache#helper#clear_result()
      return
    endif
  endif

  call s:save_foldinfo()

  " Set options.
  set completeopt-=menu
  set completeopt-=longest
  set completeopt+=menuone

  " Start auto complete.
  call feedkeys(&l:formatoptions !~ 'a' ?
        \ "\<Plug>(neocomplcache_start_auto_complete)":
        \ "\<Plug>(neocomplcache_start_auto_complete_no_select)")
endfunction"}}}

function! s:save_foldinfo() "{{{
  " Save foldinfo.
  let winnrs = filter(range(1, winnr('$')),
        \ "winbufnr(v:val) == bufnr('%')")

  " Note: for foldmethod=expr or syntax.
  call filter(winnrs, "
        \  (getwinvar(v:val, '&foldmethod') ==# 'expr' ||
        \   getwinvar(v:val, '&foldmethod') ==# 'syntax') &&
        \  getwinvar(v:val, '&modifiable')")
  for winnr in winnrs
    call setwinvar(winnr, 'neocomplcache_foldinfo', {
          \ 'foldmethod' : getwinvar(winnr, '&foldmethod'),
          \ 'foldexpr'   : getwinvar(winnr, '&foldexpr')
          \ })
    call setwinvar(winnr, '&foldmethod', 'manual')
    call setwinvar(winnr, '&foldexpr', 0)
  endfor
endfunction"}}}
function! s:check_in_do_auto_complete() "{{{
  if neocomplcache#is_locked()
    return 1
  endif

  if &l:completefunc == ''
    let &l:completefunc = 'neocomplcache#complete#manual_complete'
  endif

  " Detect completefunc.
  if &l:completefunc !~# '^neocomplcache#'
    if &l:buftype =~ 'nofile'
      return 1
    endif

    if g:neocomplcache_force_overwrite_completefunc
      " Set completefunc.
      let &l:completefunc = 'neocomplcache#complete#manual_complete'
    else
      " Warning.
      redir => output
      99verbose setl completefunc?
      redir END
      call neocomplcache#print_error(output)
      call neocomplcache#print_error(
            \ 'Another plugin set completefunc! Disabled neocomplcache.')
      NeoComplCacheLock
      return 1
    endif
  endif

  " Detect AutoComplPop.
  if exists('g:acp_enableAtStartup') && g:acp_enableAtStartup
    call neocomplcache#print_error(
          \ 'Detected enabled AutoComplPop! Disabled neocomplcache.')
    NeoComplCacheLock
    return 1
  endif
endfunction"}}}
function! s:is_skip_auto_complete(cur_text) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  if a:cur_text =~ '^\s*$\|\s\+$'
        \ || a:cur_text == neocomplcache.old_cur_text
        \ || (g:neocomplcache_lock_iminsert && &l:iminsert)
        \ || (&l:formatoptions =~# '[tc]' && &l:textwidth > 0
        \     && neocomplcache#util#wcswidth(a:cur_text) >= &l:textwidth)
    return 1
  endif

  if !neocomplcache.skip_next_complete
    return 0
  endif

  " Check delimiter pattern.
  let is_delimiter = 0
  let filetype = neocomplcache#get_context_filetype()

  for delimiter in ['/', '\.'] +
        \ get(g:neocomplcache_delimiter_patterns, filetype, [])
    if a:cur_text =~ delimiter . '$'
      let is_delimiter = 1
      break
    endif
  endfor

  if is_delimiter && neocomplcache.skip_next_complete == 2
    let neocomplcache.skip_next_complete = 0
    return 0
  endif

  let neocomplcache.skip_next_complete = 0
  let neocomplcache.cur_text = ''
  let neocomplcache.old_cur_text = ''

  return 1
endfunction"}}}
function! s:close_preview_window() "{{{
  if g:neocomplcache_enable_auto_close_preview &&
        \ bufname('%') !=# '[Command Line]' &&
        \ winnr('$') != 1 && !&l:previewwindow
    " Close preview window.
    pclose!
  endif
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/helper.vim
================================================
"=============================================================================
" FILE: helper.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 20 Aug 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#helper#get_cur_text() "{{{
  let cur_text =
        \ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
        \      getline('.') :
        \      matchstr(getline('.'),
        \         '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))

  if cur_text =~ '^.\{-}\ze\S\+$'
    let complete_str = matchstr(cur_text, '\S\+$')
    let cur_text = matchstr(cur_text, '^.\{-}\ze\S\+$')
  else
    let complete_str = ''
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()
  if neocomplcache.event ==# 'InsertCharPre'
    let complete_str .= v:char
  endif

  let filetype = neocomplcache#get_context_filetype()
  let wildcard = get(g:neocomplcache_wildcard_characters, filetype,
        \ get(g:neocomplcache_wildcard_characters, '_', '*'))
  if g:neocomplcache_enable_wildcard &&
        \ wildcard !=# '*' && len(wildcard) == 1
    " Substitute wildcard character.
    while 1
      let index = stridx(complete_str, wildcard)
      if index <= 0
        break
      endif

      let complete_str = complete_str[: index-1]
            \ . '*' . complete_str[index+1: ]
    endwhile
  endif

  let neocomplcache.cur_text = cur_text . complete_str

  " Save cur_text.
  return neocomplcache.cur_text
endfunction"}}}

function! neocomplcache#helper#keyword_escape(complete_str) "{{{
  " Fuzzy completion.
  let keyword_len = len(a:complete_str)
  let keyword_escape = s:keyword_escape(a:complete_str)
  if g:neocomplcache_enable_fuzzy_completion
        \ && (g:neocomplcache_fuzzy_completion_start_length
        \          <= keyword_len && keyword_len < 20)
    let pattern = keyword_len >= 8 ?
          \ '\0\\w*' : '\\%(\0\\w*\\|\U\0\E\\l*\\)'

    let start = g:neocomplcache_fuzzy_completion_start_length
    if start <= 1
      let keyword_escape =
            \ substitute(keyword_escape, '\w', pattern, 'g')
    elseif keyword_len < 8
      let keyword_escape = keyword_escape[: start - 2]
            \ . substitute(keyword_escape[start-1 :], '\w', pattern, 'g')
    else
      let keyword_escape = keyword_escape[: 3] .
            \ substitute(keyword_escape[4:12], '\w',
            \   pattern, 'g') . keyword_escape[13:]
    endif
  else
    " Underbar completion. "{{{
    if g:neocomplcache_enable_underbar_completion
          \ && keyword_escape =~ '[^_]_\|^_'
      let keyword_escape = substitute(keyword_escape,
            \ '\%(^\|[^_]\)\zs_', '[^_]*_', 'g')
    endif
    if g:neocomplcache_enable_underbar_completion
          \ && '-' =~ '\k' && keyword_escape =~ '[^-]-'
      let keyword_escape = substitute(keyword_escape,
            \ '[^-]\zs-', '[^-]*-', 'g')
    endif
    "}}}
    " Camel case completion. "{{{
    if g:neocomplcache_enable_camel_case_completion
          \ && keyword_escape =~ '\u\?\U*'
      let keyword_escape =
            \ substitute(keyword_escape,
            \ '\u\?\zs\U*',
            \ '\\%(\0\\l*\\|\U\0\E\\u*_\\?\\)', 'g')
    endif
    "}}}
  endif

  call neocomplcache#print_debug(keyword_escape)
  return keyword_escape
endfunction"}}}

function! neocomplcache#helper#is_omni_complete(cur_text) "{{{
  " Check eskk complete length.
  if neocomplcache#is_eskk_enabled()
        \ && exists('g:eskk#start_completion_length')
    if !neocomplcache#is_eskk_convertion(a:cur_text)
          \ || !neocomplcache#is_multibyte_input(a:cur_text)
      return 0
    endif

    let complete_pos = call(&l:omnifunc, [1, ''])
    let complete_str = a:cur_text[complete_pos :]
    return neocomplcache#util#mb_strlen(complete_str) >=
          \ g:eskk#start_completion_length
  endif

  let filetype = neocomplcache#get_context_filetype()
  let omnifunc = get(g:neocomplcache_omni_functions,
        \ filetype, &l:omnifunc)

  if neocomplcache#check_invalid_omnifunc(omnifunc)
    return 0
  endif

  let syn_name = neocomplcache#helper#get_syn_name(1)
  if syn_name ==# 'Comment' || syn_name ==# 'String'
    " Skip omni_complete in string literal.
    return 0
  endif

  if has_key(g:neocomplcache_force_omni_patterns, omnifunc)
    let pattern = g:neocomplcache_force_omni_patterns[omnifunc]
  elseif filetype != '' &&
        \ get(g:neocomplcache_force_omni_patterns, filetype, '') != ''
    let pattern = g:neocomplcache_force_omni_patterns[filetype]
  else
    return 0
  endif

  if a:cur_text !~# '\%(' . pattern . '\m\)$'
    return 0
  endif

  " Set omnifunc.
  let &omnifunc = omnifunc

  return 1
endfunction"}}}

function! neocomplcache#helper#is_enabled_source(source_name) "{{{
  if neocomplcache#is_disabled_source(a:source_name)
    return 0
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()
  if !has_key(neocomplcache, 'sources')
    call neocomplcache#helper#get_sources_list()
  endif

  return index(keys(neocomplcache.sources), a:source_name) >= 0
endfunction"}}}

function! neocomplcache#helper#get_source_filetypes(filetype) "{{{
  let filetype = (a:filetype == '') ? 'nothing' : a:filetype

  let filetype_dict = {}

  let filetypes = [filetype]
  if filetype =~ '\.'
    if exists('g:neocomplcache_ignore_composite_filetype_lists')
          \ && has_key(g:neocomplcache_ignore_composite_filetype_lists, filetype)
      let filetypes = [g:neocomplcache_ignore_composite_filetype_lists[filetype]]
    else
      " Set composite filetype.
      let filetypes += split(filetype, '\.')
    endif
  endif

  if exists('g:neocomplcache_same_filetype_lists')
    for ft in copy(filetypes)
      let filetypes += split(get(g:neocomplcache_same_filetype_lists, ft,
            \ get(g:neocomplcache_same_filetype_lists, '_', '')), ',')
    endfor
  endif

  return neocomplcache#util#uniq(filetypes)
endfunction"}}}

function! neocomplcache#helper#get_completion_length(plugin_name) "{{{
  " Todo.
endfunction"}}}

function! neocomplcache#helper#complete_check() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  if g:neocomplcache_enable_debug
    echomsg split(reltimestr(reltime(neocomplcache.start_time)))[0]
  endif
  let ret = (!neocomplcache#is_prefetch() && complete_check())
        \ || (neocomplcache#is_auto_complete()
        \     && g:neocomplcache_skip_auto_completion_time != ''
        \     && split(reltimestr(reltime(neocomplcache.start_time)))[0] >
        \          g:neocomplcache_skip_auto_completion_time)
  if ret
    let neocomplcache = neocomplcache#get_current_neocomplcache()
    let neocomplcache.skipped = 1

    redraw
    echo 'Skipped.'
  endif

  return ret
endfunction"}}}

function! neocomplcache#helper#get_syn_name(is_trans) "{{{
  return len(getline('.')) < 200 ?
        \ synIDattr(synIDtrans(synID(line('.'), mode() ==# 'i' ?
        \          col('.')-1 : col('.'), a:is_trans)), 'name') : ''
endfunction"}}}

function! neocomplcache#helper#match_word(cur_text, ...) "{{{
  let pattern = a:0 >= 1 ? a:1 : neocomplcache#get_keyword_pattern_end()

  " Check wildcard.
  let complete_pos = s:match_wildcard(
        \ a:cur_text, pattern, match(a:cur_text, pattern))

  let complete_str = (complete_pos >=0) ?
        \ a:cur_text[complete_pos :] : ''

  return [complete_pos, complete_str]
endfunction"}}}

function! neocomplcache#helper#filetype_complete(arglead, cmdline, cursorpos) "{{{
  " Dup check.
  let ret = {}
  for item in map(
        \ split(globpath(&runtimepath, 'syntax/*.vim'), '\n') +
        \ split(globpath(&runtimepath, 'indent/*.vim'), '\n') +
        \ split(globpath(&runtimepath, 'ftplugin/*.vim'), '\n')
        \ , 'fnamemodify(v:val, ":t:r")')
    if !has_key(ret, item) && item =~ '^'.a:arglead
      let ret[item] = 1
    endif
  endfor

  return sort(keys(ret))
endfunction"}}}

function! neocomplcache#helper#unite_patterns(pattern_var, filetype) "{{{
  let keyword_patterns = []
  let dup_check = {}

  " Composite filetype.
  for ft in split(a:filetype, '\.')
    if has_key(a:pattern_var, ft) && !has_key(dup_check, ft)
      let dup_check[ft] = 1
      call add(keyword_patterns, a:pattern_var[ft])
    endif

    " Same filetype.
    if exists('g:neocomplcache_same_filetype_lists')
          \ && has_key(g:neocomplcache_same_filetype_lists, ft)
      for ft in split(g:neocomplcache_same_filetype_lists[ft], ',')
        if has_key(a:pattern_var, ft) && !has_key(dup_check, ft)
          let dup_check[ft] = 1
          call add(keyword_patterns, a:pattern_var[ft])
        endif
      endfor
    endif
  endfor

  if empty(keyword_patterns)
    let default = get(a:pattern_var, '_', get(a:pattern_var, 'default', ''))
    if default != ''
      call add(keyword_patterns, default)
    endif
  endif

  return join(keyword_patterns, '\m\|')
endfunction"}}}

function! neocomplcache#helper#ftdictionary2list(dictionary, filetype) "{{{
  let list = []
  for filetype in neocomplcache#get_source_filetypes(a:filetype)
    if has_key(a:dictionary, filetype)
      call add(list, a:dictionary[filetype])
    endif
  endfor

  return list
endfunction"}}}

function! neocomplcache#helper#get_sources_list(...) "{{{
  let filetype = neocomplcache#get_context_filetype()

  let source_names = exists('b:neocomplcache_sources_list') ?
        \ b:neocomplcache_sources_list :
        \ get(a:000, 0,
        \   get(g:neocomplcache_sources_list, filetype,
        \     get(g:neocomplcache_sources_list, '_', ['_'])))
  let disabled_sources = get(
        \ g:neocomplcache_disabled_sources_list, filetype,
        \   get(g:neocomplcache_disabled_sources_list, '_', []))
  call neocomplcache#init#_sources(source_names)

  let all_sources = neocomplcache#available_sources()
  let sources = {}
  for source_name in source_names
    if source_name ==# '_'
      " All sources.
      let sources = all_sources
      break
    endif

    if !has_key(all_sources, source_name)
      call neocomplcache#print_warning(printf(
            \ 'Invalid source name "%s" is given.', source_name))
      continue
    endif

    let sources[source_name] = all_sources[source_name]
  endfor

  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.sources = filter(sources, "
        \ index(disabled_sources, v:val.name) < 0 &&
        \   (empty(v:val.filetypes) ||
        \    get(v:val.filetypes, neocomplcache.context_filetype, 0))")

  return neocomplcache.sources
endfunction"}}}

function! neocomplcache#helper#clear_result() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let neocomplcache.complete_str = ''
  let neocomplcache.candidates = []
  let neocomplcache.complete_results = []
  let neocomplcache.complete_pos = -1
endfunction"}}}

function! neocomplcache#helper#call_hook(sources, hook_name, context) "{{{
  for source in neocomplcache#util#convert2list(a:sources)
    try
      if !has_key(source.hooks, a:hook_name)
        if a:hook_name ==# 'on_init' && has_key(source, 'initialize')
          call source.initialize()
        elseif a:hook_name ==# 'on_final' && has_key(source, 'finalize')
          call source.finalize()
        endif
      else
        call call(source.hooks[a:hook_name],
              \ [extend(source.neocomplcache__context, a:context)],
              \ source.hooks)
      endif
    catch
      call neocomplcache#print_error(v:throwpoint)
      call neocomplcache#print_error(v:exception)
      call neocomplcache#print_error(
            \ '[unite.vim] Error occurred in calling hook "' . a:hook_name . '"!')
      call neocomplcache#print_error(
            \ '[unite.vim] Source name is ' . source.name)
    endtry
  endfor
endfunction"}}}

function! neocomplcache#helper#call_filters(filters, source, context) "{{{
  let context = extend(a:source.neocomplcache__context, a:context)
  let _ = []
  for filter in neocomplcache#init#_filters(
        \ neocomplcache#util#convert2list(a:filters))
    try
      let context.candidates = call(filter.filter, [context], filter)
    catch
      call neocomplcache#print_error(v:throwpoint)
      call neocomplcache#print_error(v:exception)
      call neocomplcache#print_error(
            \ '[unite.vim] Error occurred in calling filter '
            \   . filter.name . '!')
      call neocomplcache#print_error(
            \ '[unite.vim] Source name is ' . a:source.name)
    endtry
  endfor

  return context.candidates
endfunction"}}}

function! s:match_wildcard(cur_text, pattern, complete_pos) "{{{
  let complete_pos = a:complete_pos
  while complete_pos > 1 && a:cur_text[complete_pos - 1] == '*'
    let left_text = a:cur_text[: complete_pos - 2]
    if left_text == '' || left_text !~ a:pattern
      break
    endif

    let complete_pos = match(left_text, a:pattern)
  endwhile

  return complete_pos
endfunction"}}}

function! s:keyword_escape(complete_str) "{{{
  let keyword_escape = escape(a:complete_str, '~" \.^$[]')
  if g:neocomplcache_enable_wildcard
    let keyword_escape = substitute(
          \ substitute(keyword_escape, '.\zs\*', '.*', 'g'),
          \ '\%(^\|\*\)\zs\*', '\\*', 'g')
  else
    let keyword_escape = escape(keyword_escape, '*')
  endif

  return keyword_escape
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/init.vim
================================================
"=============================================================================
" FILE: init.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 25 Oct 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

if !exists('s:is_enabled')
  let s:is_enabled = 0
endif

function! neocomplcache#init#lazy() "{{{
  if !exists('s:lazy_progress')
    let s:lazy_progress = 0
  endif

  if s:lazy_progress == 0
    call neocomplcache#init#_others()
    let s:is_enabled = 0
  elseif s:lazy_progress == 1
    call neocomplcache#init#_sources(get(g:neocomplcache_sources_list,
          \ neocomplcache#get_context_filetype(), ['_']))
  else
    call neocomplcache#init#_autocmds()
    let s:is_enabled = 1
  endif

  let s:lazy_progress += 1
endfunction"}}}

function! neocomplcache#init#enable() "{{{
  if neocomplcache#is_enabled()
    return
  endif

  call neocomplcache#init#_autocmds()
  call neocomplcache#init#_others()

  call neocomplcache#init#_sources(get(g:neocomplcache_sources_list,
        \ neocomplcache#get_context_filetype(), ['_']))
  let s:is_enabled = 1
endfunction"}}}

function! neocomplcache#init#disable() "{{{
  if !neocomplcache#is_enabled()
    call neocomplcache#print_warning(
          \ 'neocomplcache is disabled! This command is ignored.')
    return
  endif

  let s:is_enabled = 0

  augroup neocomplcache
    autocmd!
  augroup END

  delcommand NeoComplCacheDisable

  call neocomplcache#helper#call_hook(filter(values(
        \ neocomplcache#variables#get_sources()), 'v:val.loaded'),
        \ 'on_final', {})
endfunction"}}}

function! neocomplcache#init#is_enabled() "{{{
  return s:is_enabled
endfunction"}}}

function! neocomplcache#init#_autocmds() "{{{
  augroup neocomplcache
    autocmd!
    autocmd InsertEnter *
          \ call neocomplcache#handler#_on_insert_enter()
    autocmd InsertLeave *
          \ call neocomplcache#handler#_on_insert_leave()
    autocmd CursorMovedI *
          \ call neocomplcache#handler#_on_moved_i()
    autocmd BufWritePost *
          \ call neocomplcache#handler#_on_write_post()
  augroup END

  if g:neocomplcache_enable_insert_char_pre
        \ && (v:version > 703 || v:version == 703 && has('patch418'))
    autocmd neocomplcache InsertCharPre *
          \ call neocomplcache#handler#_do_auto_complete('InsertCharPre')
  elseif g:neocomplcache_enable_cursor_hold_i
    augroup neocomplcache
      autocmd CursorHoldI *
            \ call neocomplcache#handler#_do_auto_complete('CursorHoldI')
      autocmd InsertEnter *
            \ call neocomplcache#handler#_change_update_time()
      autocmd InsertLeave *
            \ call neocomplcache#handler#_restore_update_time()
    augroup END
  else
    autocmd neocomplcache CursorMovedI *
          \ call neocomplcache#handler#_do_auto_complete('CursorMovedI')
  endif

  if (v:version > 703 || v:version == 703 && has('patch598'))
    autocmd neocomplcache CompleteDone *
          \ call neocomplcache#handler#_on_complete_done()
  endif
endfunction"}}}

function! neocomplcache#init#_others() "{{{
  call neocomplcache#init#_variables()

  call neocomplcache#context_filetype#initialize()

  call neocomplcache#commands#_initialize()

  " Save options.
  let s:completefunc_save = &completefunc
  let s:completeopt_save = &completeopt

  " Set completefunc.
  let completefunc_save = &l:completefunc
  let &completefunc = 'neocomplcache#complete#manual_complete'
  if completefunc_save != ''
    let &l:completefunc = completefunc_save
  endif

  " For auto complete keymappings.
  call neocomplcache#mappings#define_default_mappings()

  " Detect set paste.
  if &paste
    redir => output
    99verbose set paste
    redir END
    call neocomplcache#print_error(output)
    call neocomplcache#print_error(
          \ 'Detected set paste! Disabled neocomplcache.')
  endif

  command! -nargs=0 -bar NeoComplCacheDisable
        \ call neocomplcache#init#disable()
endfunction"}}}

function! neocomplcache#init#_variables() "{{{
  " Initialize keyword patterns. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_keyword_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'_',
        \'\k\+')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_keyword_patterns',
        \'filename',
        \ neocomplcache#util#is_windows() ?
        \'\%(\a\+:/\)\?\%([/[:alnum:]()$+_~.\x80-\xff-]\|[^[:print:]]\|\\.\)\+' :
        \'\%([/\[\][:alnum:]()$+_~.-]\|[^[:print:]]\|\\.\)\+')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'lisp,scheme,clojure,int-gosh,int-clisp,int-clj',
        \'[[:alpha:]+*/@$_=.!?-][[:alnum:]+*/@$_:=.!?-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'ruby,int-irb',
        \'^=\%(b\%[egin]\|e\%[nd]\)\|\%(@@\|[$@]\)\h\w*\|\h\w*\%(::\w*\)*[!?]\?')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'php,int-php',
        \'</\?\%(\h[[:alnum:]_-]*\s*\)\?\%(/\?>\)\?'.
        \'\|\$\h\w*\|\h\w*\%(\%(\\\|::\)\w*\)*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'perl,int-perlsh',
        \'<\h\w*>\?\|[$@%&*]\h\w*\|\h\w*\%(::\w*\)*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'perl6,int-perl6',
        \'<\h\w*>\?\|[$@%&][!.*?]\?\h[[:alnum:]_-]*'.
        \'\|\h[[:alnum:]_-]*\%(::[[:alnum:]_-]*\)*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'pir',
        \'[$@%.=]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'pasm',
        \'[=]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'vim,help',
        \'-\h[[:alnum:]-]*=\?\|\c\[:\%(\h\w*:\]\)\?\|&\h[[:alnum:]_:]*\|'.
        \'<SID>\%(\h\w*\)\?\|<Plug>([^)]*)\?'.
        \'\|<\h[[:alnum:]_-]*>\?\|\h[[:alnum:]_:#]*!\?\|$\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'tex',
        \'\\\a{\a\{1,2}}\|\\[[:alpha:]@][[:alnum:]@]*'.
        \'\%({\%([[:alnum:]:_]\+\*\?}\?\)\?\)\?\|\a[[:alnum:]:_]*\*\?')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'sh,zsh,int-zsh,int-bash,int-sh',
        \'[[:alpha:]_.-][[:alnum:]_.-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'vimshell',
        \'\$\$\?\w*\|[[:alpha:]_.\\/~-][[:alnum:]_.\\/~-]*\|\d\+\%(\.\d\+\)\+')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'ps1,int-powershell',
        \'\[\h\%([[:alnum:]_.]*\]::\)\?\|[$%@.]\?[[:alpha:]_.:-][[:alnum:]_.:-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'c',
        \'^\s*#\s*\h\w*\|\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'cpp',
        \'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'objc',
        \'^\s*#\s*\h\w*\|\h\w*\|@\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'objcpp',
        \'^\s*#\s*\h\w*\|\h\w*\%(::\w*\)*\|@\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'objj',
        \'\h\w*\|@\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'d',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'python,int-python,int-ipython',
        \'[@]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'cs',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'java',
        \'[@]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'javascript,actionscript,int-js,int-kjs,int-rhino',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'coffee,int-coffee',
        \'[@]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'awk',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'haskell,int-ghci',
        \'\%(\u\w*\.\)\+[[:alnum:]_'']*\|[[:alpha:]_''][[:alnum:]_'']*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'ml,ocaml,int-ocaml,int-sml,int-smlsharp',
        \'[''`#.]\?\h[[:alnum:]_'']*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'erlang,int-erl',
        \'^\s*-\h\w*\|\%(\h\w*:\)*\h\w*\|\h[[:alnum:]_@]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'html,xhtml,xml,markdown,eruby',
        \'</\?\%([[:alnum:]_:-]\+\s*\)\?\%(/\?>\)\?\|&\h\%(\w*;\)\?'.
        \'\|\h[[:alnum:]_-]*="\%([^"]*"\?\)\?\|\h[[:alnum:]_:-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'css,stylus,scss,less',
        \'[@#.]\?[[:alpha:]_:-][[:alnum:]_:-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'tags',
        \'^[^!][^/[:blank:]]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'pic',
        \'^\s*#\h\w*\|\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'arm',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'asmh8300',
        \'[[:alpha:]_.][[:alnum:]_.]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'masm',
        \'\.\h\w*\|[[:alpha:]_@?$][[:alnum:]_@?$]*\|\h\w*:\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'nasm',
        \'^\s*\[\h\w*\|[%.]\?\h\w*\|\%(\.\.@\?\|%[%$!]\)\%(\h\w*\)\?\|\h\w*:\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'asm',
        \'[%$.]\?\h\w*\%(\$\h\w*\)\?')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'gas',
        \'[$.]\?\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'gdb,int-gdb',
        \'$\h\w*\|[[:alnum:]:._-]\+')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'make',
        \'[[:alpha:]_.-][[:alnum:]_.-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'scala,int-scala',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'int-termtter',
        \'\h[[:alnum:]_/-]*\|\$\a\+\|#\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'int-earthquake',
        \'[:#$]\h\w*\|\h[[:alnum:]_/-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'dosbatch,int-cmdproxy',
        \'\$\w+\|[[:alpha:]_./-][[:alnum:]_.-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'vb',
        \'\h\w*\|#\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'lua',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \ 'zimbu',
        \'\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'konoha',
        \'[*$@%]\h\w*\|\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'cobol',
        \'\a[[:alnum:]-]*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'coq',
        \'\h[[:alnum:]_'']*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'tcl',
        \'[.-]\h\w*\|\h\w*')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_keyword_patterns',
        \'nyaos,int-nyaos',
        \'\h\w*')
  "}}}

  " Initialize next keyword patterns. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_next_keyword_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'perl',
        \'\h\w*>')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'perl6',
        \'\h\w*>')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'vim,help',
        \'\w*()\?\|\w*:\]\|[[:alnum:]_-]*[)>=]')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'python',
        \'\w*()\?')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'tex',
        \'[[:alnum:]:_]\+[*[{}]')
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_next_keyword_patterns', 'html,xhtml,xml,mkd',
        \'[^"]*"\|[[:alnum:]_:-]*>')
  "}}}

  " Initialize same file type lists. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_same_filetype_lists', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'c', 'cpp')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'cpp', 'c')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'erb', 'ruby,html,xhtml')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'html,xml', 'xhtml')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'html,xhtml', 'css,stylus,less')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'css', 'scss')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'scss', 'css')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'stylus', 'css')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'less', 'css')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'xhtml', 'html,xml')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'help', 'vim')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'tex', 'bib,plaintex')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'plaintex', 'bib,tex')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'lingr-say', 'lingr-messages,lingr-members')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'J6uil_say', 'J6uil')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'vimconsole', 'vim')

  " Interactive filetypes.
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-irb', 'ruby')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-ghci,int-hugs', 'haskell')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-python,int-ipython', 'python')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-gosh', 'scheme')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-clisp', 'lisp')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-erl', 'erlang')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-zsh', 'zsh')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-bash', 'bash')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-sh', 'sh')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-cmdproxy', 'dosbatch')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-powershell', 'powershell')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-perlsh', 'perl')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-perl6', 'perl6')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-ocaml', 'ocaml')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-clj', 'clojure')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-sml,int-smlsharp', 'sml')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-js,int-kjs,int-rhino', 'javascript')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-coffee', 'coffee')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-gdb', 'gdb')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-scala', 'scala')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-nyaos', 'nyaos')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_same_filetype_lists',
        \ 'int-php', 'php')
  "}}}

  " Initialize delimiter patterns. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_delimiter_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'vim,help', ['#'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'erlang,lisp,int-clisp', [':'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'lisp,int-clisp', ['/', ':'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'clojure,int-clj', ['/', '\.'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'perl,cpp', ['::'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'php', ['\', '::'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'java,d,javascript,actionscript,'.
        \ 'ruby,eruby,haskell,int-ghci,coffee,zimbu,konoha',
        \ ['\.'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'lua', ['\.', ':'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_delimiter_patterns',
        \ 'perl6', ['\.', '::'])
  "}}}

  " Initialize ctags arguments. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_ctags_arguments_list', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_ctags_arguments_list',
        \ '_', '')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_ctags_arguments_list', 'vim',
        \ '--extra=fq --fields=afmiKlnsStz ' .
        \ "--regex-vim='/function!? ([a-z#:_0-9A-Z]+)/\\1/function/'")
  if neocomplcache#util#is_mac()
    call neocomplcache#util#set_default_dictionary(
          \ 'g:neocomplcache_ctags_arguments_list', 'c',
          \ '--c-kinds=+p --fields=+iaS --extra=+q
          \ -I__DARWIN_ALIAS,__DARWIN_ALIAS_C,__DARWIN_ALIAS_I,__DARWIN_INODE64
          \ -I__DARWIN_1050,__DARWIN_1050ALIAS,__DARWIN_1050ALIAS_C,__DARWIN_1050ALIAS_I,__DARWIN_1050INODE64
          \ -I__DARWIN_EXTSN,__DARWIN_EXTSN_C
          \ -I__DARWIN_LDBL_COMPAT,__DARWIN_LDBL_COMPAT2')
  else
    call neocomplcache#util#set_default_dictionary(
          \ 'g:neocomplcache_ctags_arguments_list', 'c',
          \ '-R --sort=1 --c-kinds=+p --fields=+iaS --extra=+q ' .
          \ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'.
          \   '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+')
  endif
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_ctags_arguments_list', 'cpp',
        \ '--language-force=C++ -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q '.
        \ '-I __wur,__THROW,__attribute_malloc__,__nonnull+,'.
        \   '__attribute_pure__,__attribute_warn_unused_result__,__attribute__+')
  "}}}

  " Initialize text mode filetypes. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_text_mode_filetypes', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_text_mode_filetypes',
        \ 'hybrid,text,help,tex,gitcommit,gitrebase,vcs-commit,markdown,'.
        \   'textile,creole,org,rdoc,mediawiki,rst,asciidoc,pod', 1) 
  "}}}

  " Initialize tags filter patterns. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_tags_filter_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_tags_filter_patterns', 'c,cpp',
        \'v:val.word !~ ''^[~_]''')
  "}}}

  " Initialize force omni completion pattern. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_force_omni_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \'g:neocomplcache_force_omni_patterns', 'objc',
        \'\h\w\+\|[^.[:digit:] *\t]\%(\.\|->\)')
  "}}}

  " Initialize ignore composite filetypes
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_ignore_composite_filetype_lists', {})

  " Must g:neocomplcache_auto_completion_start_length > 1.
  if g:neocomplcache_auto_completion_start_length < 1
    let g:neocomplcache_auto_completion_start_length = 1
  endif
  " Must g:neocomplcache_min_keyword_length > 1.
  if g:neocomplcache_min_keyword_length < 1
    let g:neocomplcache_min_keyword_length = 1
  endif

  " Initialize omni function list. "{{{
  if !exists('g:neocomplcache_omni_functions')
    let g:neocomplcache_omni_functions = {}
  endif
  "}}}

  " Set custom.
  call s:set_default_custom()
endfunction"}}}

function! neocomplcache#init#_current_neocomplcache() "{{{
  let b:neocomplcache = {
        \ 'context' : {
        \      'input' : '',
        \      'complete_pos' : -1,
        \      'complete_str' : '',
        \      'candidates' : [],
        \ },
        \ 'lock' : 0,
        \ 'skip_next_complete' : 0,
        \ 'filetype' : '',
        \ 'context_filetype' : '',
        \ 'context_filetype_range' :
        \    [[1, 1], [line('$'), len(getline('$'))+1]],
        \ 'completion_length' : -1,
        \ 'update_time_save' : &updatetime,
        \ 'foldinfo' : [],
        \ 'lock_sources' : {},
        \ 'skipped' : 0,
        \ 'event' : '',
        \ 'cur_text' : '',
        \ 'old_cur_text' : '',
        \ 'complete_str' : '',
        \ 'complete_pos' : -1,
        \ 'candidates' : [],
        \ 'complete_results' : [],
        \ 'complete_sources' : [],
        \ 'manual_sources' : [],
        \ 'start_time' : reltime(),
        \}
endfunction"}}}

function! neocomplcache#init#_sources(names) "{{{
  if !exists('s:loaded_source_files')
    " Initialize.
    let s:loaded_source_files = {}
    let s:loaded_all_sources = 0
    let s:runtimepath_save = ''
  endif

  " Initialize sources table.
  if s:loaded_all_sources && &runtimepath ==# s:runtimepath_save
    return
  endif

  let runtimepath_save = neocomplcache#util#split_rtp(s:runtimepath_save)
  let runtimepath = neocomplcache#util#join_rtp(
        \ filter(neocomplcache#util#split_rtp(),
        \ 'index(runtimepath_save, v:val) < 0'))
  let sources = neocomplcache#variables#get_sources()

  for name in filter(copy(a:names), '!has_key(sources, v:val)')
    " Search autoload.
    for source_name in map(split(globpath(runtimepath,
          \ 'autoload/neocomplcache/sources/*.vim'), '\n'),
          \ "fnamemodify(v:val, ':t:r')")
      if has_key(s:loaded_source_files, source_name)
        continue
      endif

      let s:loaded_source_files[source_name] = 1

      let source = neocomplcache#sources#{source_name}#define()
      if empty(source)
        " Ignore.
        continue
      endif

      call neocomplcache#define_source(source)
    endfor

    if name == '_'
      let s:loaded_all_sources = 1
      let s:runtimepath_save = &runtimepath
    endif
  endfor
endfunction"}}}

function! neocomplcache#init#_source(source) "{{{
  let default = {
        \ 'max_candidates' : 0,
        \ 'filetypes' : {},
        \ 'hooks' : {},
        \ 'matchers' : ['matcher_old'],
        \ 'sorters' : ['sorter_rank'],
        \ 'converters' : [
        \      'converter_remove_next_keyword',
        \      'converter_delimiter',
        \      'converter_case',
        \      'converter_abbr',
        \ ],
        \ 'neocomplcache__context' : copy(neocomplcache#get_context()),
        \ }

  let source = extend(copy(default), a:source)

  " Overwritten by user custom.
  let custom = neocomplcache#variables#get_custom().sources
  let source = extend(source, get(custom, source.name,
        \ get(custom, '_', {})))

  let source.loaded = 0
  " Source kind convertion.
  if source.kind ==# 'plugin' ||
        \ (!has_key(source, 'gather_candidates') &&
        \  !has_key(source, 'get_complete_words'))
    let source.kind = 'keyword'
  elseif source.kind ==# 'ftplugin' || source.kind ==# 'complfunc'
    " For compatibility.
    let source.kind = 'manual'
  else
    let source.kind = 'manual'
  endif

  if !has_key(source, 'rank')
    " Set default rank.
    let source.rank = (source.kind ==# 'keyword') ? 5 :
          \ empty(source.filetypes) ? 10 : 100
  endif

  if !has_key(source, 'min_pattern_length')
    " Set min_pattern_length.
    let source.min_pattern_length = (source.kind ==# 'keyword') ?
          \ g:neocomplcache_auto_completion_start_length : 0
  endif

  let source.neocomplcache__context.source_name = source.name

  " Note: This routine is for compatibility of old sources implementation.
  " Initialize sources.
  if empty(source.filetypes) && has_key(source, 'initialize')
    try
      call source.initialize()
    catch
      call neocomplcache#print_error(v:throwpoint)
      call neocomplcache#print_error(v:exception)
      call neocomplcache#print_error(
            \ 'Error occurred in source''s initialize()!')
      call neocomplcache#print_error(
            \ 'Source name is ' . source.name)
    endtry

    let source.loaded = 1
  endif

  return source
endfunction"}}}

function! neocomplcache#init#_filters(names) "{{{
  let _ = []
  let filters = neocomplcache#variables#get_filters()

  for name in a:names
    if !has_key(filters, name)
      " Search autoload.
      for filter_name in map(split(globpath(&runtimepath,
            \ 'autoload/neocomplcache/filters/'.
            \   substitute(name,
            \'^\%(matcher\|sorter\|converter\)_[^/_-]\+\zs[/_-].*$', '', '')
            \  .'*.vim'), '\n'), "fnamemodify(v:val, ':t:r')")
        let filter = neocomplcache#filters#{filter_name}#define()
        if empty(filter)
          " Ignore.
          continue
        endif

        call neocomplcache#define_filter(filter)
      endfor

      if !has_key(filters, name)
        " Not found.
        call neocomplcache#print_error(
              \ printf('filter name : %s is not found.', string(name)))
        continue
      endif
    endif

    if has_key(filters, name)
      call add(_, filters[name])
    endif
  endfor

  return _
endfunction"}}}

function! neocomplcache#init#_filter(filter) "{{{
  let default = {
        \ }

  let filter = extend(default, a:filter)
  if !has_key(filter, 'kind')
    let filter.kind =
          \ (filter.name =~# '^matcher_') ? 'matcher' :
          \ (filter.name =~# '^sorter_') ? 'sorter' : 'converter'
  endif

  return filter
endfunction"}}}

function! s:set_default_custom() "{{{
  let custom = neocomplcache#variables#get_custom().sources

  " Initialize completion length.
  for [source_name, length] in items(
        \ g:neocomplcache_source_completion_length)
    if !has_key(custom, source_name)
      let custom[source_name] = {}
    endif
    let custom[source_name].min_pattern_length = length
  endfor

  " Initialize rank.
  for [source_name, rank] in items(
        \ g:neocomplcache_source_rank)
    if !has_key(custom, source_name)
      let custom[source_name] = {}
    endif
    let custom[source_name].rank = rank
  endfor
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/mappings.vim
================================================
"=============================================================================
" FILE: mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 19 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

function! neocomplcache#mappings#define_default_mappings() "{{{
  inoremap <expr><silent> <Plug>(neocomplcache_start_unite_complete)
        \ unite#sources#neocomplcache#start_complete()
  inoremap <expr><silent> <Plug>(neocomplcache_start_unite_quick_match)
        \ unite#sources#neocomplcache#start_quick_match()
  inoremap <silent> <Plug>(neocomplcache_start_auto_complete)
        \ <C-x><C-u><C-r>=neocomplcache#mappings#popup_post()<CR>
  inoremap <silent> <Plug>(neocomplcache_start_auto_complete_no_select)
        \ <C-x><C-u><C-p>
  " \ <C-x><C-u><C-p>
  inoremap <silent> <Plug>(neocomplcache_start_omni_complete)
        \ <C-x><C-o><C-p>
endfunction"}}}

function! neocomplcache#mappings#smart_close_popup() "{{{
  return g:neocomplcache_enable_auto_select ?
        \ neocomplcache#mappings#cancel_popup() :
        \ neocomplcache#mappings#close_popup()
endfunction
"}}}
function! neocomplcache#mappings#close_popup() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.complete_str = ''
  let neocomplcache.skip_next_complete = 2
  let neocomplcache.candidates = []

  return pumvisible() ? "\<C-y>" : ''
endfunction
"}}}
function! neocomplcache#mappings#cancel_popup() "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let neocomplcache.skip_next_complete = 1
  call neocomplcache#helper#clear_result()

  return pumvisible() ? "\<C-e>" : ''
endfunction
"}}}

function! neocomplcache#mappings#popup_post() "{{{
  return  !pumvisible() ? "" :
        \ g:neocomplcache_enable_auto_select ? "\<C-p>\<Down>" :
        \ "\<C-p>"
endfunction"}}}

function! neocomplcache#mappings#undo_completion() "{{{
  if !exists(':NeoComplCacheDisable')
    return ''
  endif

  let neocomplcache = neocomplcache#get_current_neocomplcache()

  " Get cursor word.
  let [complete_pos, complete_str] =
        \ neocomplcache#match_word(neocomplcache#get_cur_text(1))
  let old_keyword_str = neocomplcache.complete_str
  let neocomplcache.complete_str = complete_str

  return (!pumvisible() ? '' :
        \ complete_str ==# old_keyword_str ? "\<C-e>" : "\<C-y>")
        \. repeat("\<BS>", len(complete_str)) . old_keyword_str
endfunction"}}}

function! neocomplcache#mappings#complete_common_string() "{{{
  if !exists(':NeoComplCacheDisable')
    return ''
  endif

  " Save options.
  let ignorecase_save = &ignorecase

  " Get cursor word.
  let [complete_pos, complete_str] =
        \ neocomplcache#match_word(neocomplcache#get_cur_text(1))

  if neocomplcache#is_text_mode()
    let &ignorecase = 1
  elseif g:neocomplcache_enable_smart_case && complete_str =~ '\u'
    let &ignorecase = 0
  else
    let &ignorecase = g:neocomplcache_enable_ignore_case
  endif

  let is_fuzzy = g:neocomplcache_enable_fuzzy_completion

  try
    let g:neocomplcache_enable_fuzzy_completion = 0
    let neocomplcache = neocomplcache#get_current_neocomplcache()
    let candidates = neocomplcache#keyword_filter(
          \ copy(neocomplcache.candidates), complete_str)
  finally
    let g:neocomplcache_enable_fuzzy_completion = is_fuzzy
  endtry

  if empty(candidates)
    let &ignorecase = ignorecase_save

    return ''
  endif

  let common_str = candidates[0].word
  for keyword in candidates[1:]
    while !neocomplcache#head_match(keyword.word, common_str)
      let common_str = common_str[: -2]
    endwhile
  endfor
  if &ignorecase
    let common_str = tolower(common_str)
  endif

  let &ignorecase = ignorecase_save

  if common_str == ''
    return ''
  endif

  return (pumvisible() ? "\<C-e>" : '')
        \ . repeat("\<BS>", len(complete_str)) . common_str
endfunction"}}}

" Manual complete wrapper.
function! neocomplcache#mappings#start_manual_complete(...) "{{{
  if !neocomplcache#is_enabled()
    return ''
  endif

  " Set context filetype.
  call neocomplcache#context_filetype#set()

  let neocomplcache = neocomplcache#get_current_neocomplcache()

  let sources = get(a:000, 0,
        \ keys(neocomplcache#available_sources()))
  let neocomplcache.manual_sources = neocomplcache#helper#get_sources_list(
        \ neocomplcache#util#convert2list(sources))

  " Set function.
  let &l:completefunc = 'neocomplcache#complete#sources_manual_complete'

  " Start complete.
  return "\<C-x>\<C-u>\<C-p>"
endfunction"}}}

function! neocomplcache#mappings#start_manual_complete_list(complete_pos, complete_str, candidates) "{{{
  let neocomplcache = neocomplcache#get_current_neocomplcache()
  let [neocomplcache.complete_pos,
        \ neocomplcache.complete_str, neocomplcache.candidates] =
        \ [a:complete_pos, a:complete_str, a:candidates]

  " Set function.
  let &l:completefunc = 'neocomplcache#complete#auto_complete'

  " Start complete.
  return "\<C-x>\<C-u>\<C-p>"
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/buffer_complete.vim
================================================
"=============================================================================
" FILE: buffer_complete.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 26 Sep 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

" Important variables.
if !exists('s:buffer_sources')
  let s:buffer_sources = {}
  let s:async_dictionary_list = {}
endif

let s:source = {
      \ 'name' : 'buffer_complete',
      \ 'kind' : 'manual',
      \ 'mark' : '[B]',
      \ 'rank' : 5,
      \ 'min_pattern_length' :
      \     g:neocomplcache_auto_completion_start_length,
      \ 'hooks' : {},
      \}

function! s:source.hooks.on_init(context) "{{{
  let s:buffer_sources = {}

  augroup neocomplcache "{{{
    " Caching events
    autocmd BufEnter,BufRead,BufWinEnter *
          \ call s:check_source()
    autocmd CursorHold,CursorHoldI *
          \ call s:check_cache()
    autocmd BufWritePost *
          \ call s:check_recache()
    autocmd InsertEnter,InsertLeave *
          \ call neocomplcache#sources#buffer_complete#caching_current_line()
  augroup END"}}}

  " Create cache directory.
  if !isdirectory(neocomplcache#get_temporary_directory() . '/buffer_cache')
     \ && !neocomplcache#util#is_sudo()
    call mkdir(neocomplcache#get_temporary_directory() . '/buffer_cache', 'p')
  endif

  " Initialize script variables. "{{{
  let s:buffer_sources = {}
  let s:cache_line_count = 70
  let s:rank_cache_count = 1
  let s:disable_caching_list = {}
  let s:async_dictionary_list = {}
  "}}}

  call s:check_source()
endfunction
"}}}

function! s:source.hooks.on_final(context) "{{{
  delcommand NeoComplCacheCachingBuffer
  delcommand NeoComplCachePrintSource
  delcommand NeoComplCacheOutputKeyword
  delcommand NeoComplCacheDisableCaching
  delcommand NeoComplCacheEnableCaching

  let s:buffer_sources = {}
endfunction"}}}

function! s:source.gather_candidates(context) "{{{
  call s:check_source()

  let keyword_list = []
  for [key, source] in s:get_sources_list()
    call neocomplcache#cache#check_cache_list('buffer_cache',
          \ source.path, s:async_dictionary_list, source.keyword_cache, 1)

    let keyword_list += neocomplcache#dictionary_filter(
          \ source.keyword_cache, a:context.complete_str)
    if key == bufnr('%')
      let source.accessed_time = localtime()
    endif
  endfor

  return keyword_list
endfunction"}}}

function! neocomplcache#sources#buffer_complete#define() "{{{
  return s:source
endfunction"}}}

function! neocomplcache#sources#buffer_complete#get_frequencies() "{{{
  " Current line caching.
  return get(get(s:buffer_sources, bufnr('%'), {}), 'frequencies', {})
endfunction"}}}
function! neocomplcache#sources#buffer_complete#caching_current_line() "{{{
  " Current line caching.
  return s:caching_current_buffer(
        \ max([1, line('.') - 10]), min([line('.') + 10, line('$')]))
endfunction"}}}
function! neocomplcache#sources#buffer_complete#caching_current_block() "{{{
  " Current line caching.
  return s:caching_current_buffer(
          \ max([1, line('.') - 500]), min([line('.') + 500, line('$')]))
endfunction"}}}
function! s:caching_current_buffer(start, end) "{{{
  " Current line caching.

  if !s:exists_current_source()
    call s:word_caching(bufnr('%'))
  endif

  let source = s:buffer_sources[bufnr('%')]
  let keyword_pattern = source.keyword_pattern
  let keyword_pattern2 = '^\%('.keyword_pattern.'\m\)'
  let keywords = source.keyword_cache

  let completion_length = 2
  let line = join(getline(a:start, a:end))
  let match = match(line, keyword_pattern)
  while match >= 0 "{{{
    let match_str = matchstr(line, keyword_pattern2, match)

    " Ignore too short keyword.
    if len(match_str) >= g:neocomplcache_min_keyword_length "{{{
      " Check dup.
      let key = tolower(match_str[: completion_length-1])
      if !has_key(keywords, key)
        let keywords[key] = {}
      endif
      if !has_key(keywords[key], match_str)
        " Append list.
        let keywords[key][match_str] = match_str
        let source.frequencies[match_str] = 30
      endif
    endif"}}}

    " Next match.
    let match = match(line, keyword_pattern, match + len(match_str))
  endwhile"}}}
endfunction"}}}

function! s:get_sources_list() "{{{
  let sources_list = []

  let filetypes_dict = {}
  for filetype in neocomplcache#get_source_filetypes(
        \ neocomplcache#get_context_filetype())
    let filetypes_dict[filetype] = 1
  endfor

  for [key, source] in items(s:buffer_sources)
    if has_key(filetypes_dict, source.filetype)
          \ || has_key(filetypes_dict, '_')
          \ || bufnr('%') == key
          \ || (source.name ==# '[Command Line]' && bufnr('#') == key)
      call add(sources_list, [key, source])
    endif
  endfor

  return sources_list
endfunction"}}}

function! s:initialize_source(srcname) "{{{
  let path = fnamemodify(bufname(a:srcname), ':p')
  let filename = fnamemodify(path, ':t')
  if filename == ''
    let filename = '[No Name]'
    let path .= '/[No Name]'
  endif

  let ft = getbufvar(a:srcname, '&filetype')
  if ft == ''
    let ft = 'nothing'
  endif

  let buflines = getbufline(a:srcname, 1, '$')
  let keyword_pattern = neocomplcache#get_keyword_pattern(ft)

  let s:buffer_sources[a:srcname] = {
        \ 'keyword_cache' : {},
        \ 'frequencies' : {},
        \ 'name' : filename, 'filetype' : ft,
        \ 'keyword_pattern' : keyword_pattern,
        \ 'end_line' : len(buflines),
        \ 'accessed_time' : 0,
        \ 'cached_time' : 0,
        \ 'path' : path, 'loaded_cache' : 0,
        \ 'cache_name' : neocomplcache#cache#encode_name(
        \   'buffer_cache', path),
        \}
endfunction"}}}

function! s:word_caching(srcname) "{{{
  " Initialize source.
  call s:initialize_source(a:srcname)

  let source = s:buffer_sources[a:srcname]

  if !filereadable(source.path)
        \ || getbufvar(a:srcname, '&buftype') =~ 'nofile'
    return
  endif

  let source.cache_name =
        \ neocomplcache#cache#async_load_from_file(
        \     'buffer_cache', source.path,
        \     source.keyword_pattern, 'B')
  let source.cached_time = localtime()
  let source.end_line = len(getbufline(a:srcname, 1, '$'))
  let s:async_dictionary_list[source.path] = [{
        \ 'filename' : source.path,
        \ 'cachename' : source.cache_name,
        \ }]
endfunction"}}}

function! s:check_changed_buffer(bufnumber) "{{{
  let source = s:buffer_sources[a:bufnumber]

  let ft = getbufvar(a:bufnumber, '&filetype')
  if ft == ''
    let ft = 'nothing'
  endif

  let filename = fnamemodify(bufname(a:bufnumber), ':t')
  if filename == ''
    let filename = '[No Name]'
  endif

  return s:buffer_sources[a:bufnumber].name != filename
        \ || s:buffer_sources[a:bufnumber].filetype != ft
endfunction"}}}

function! s:check_source() "{{{
  if !s:exists_current_source()
    call neocomplcache#sources#buffer_complete#caching_current_block()
    return
  endif

  for bufnumber in range(1, bufnr('$'))
    " Check new buffer.
    let bufname = fnamemodify(bufname(bufnumber), ':p')
    if (!has_key(s:buffer_sources, bufnumber)
          \ || s:check_changed_buffer(bufnumber))
          \ && !has_key(s:disable_caching_list, bufnumber)
          \ && (!neocomplcache#is_locked(bufnumber) ||
          \    g:neocomplcache_disable_auto_complete)
          \ && !getwinvar(bufwinnr(bufnumber), '&previewwindow')
          \ && getfsize(bufname) <
          \      g:neocomplcache_caching_limit_file_size
      " Caching.
      call s:word_caching(bufnumber)
    endif

    if has_key(s:buffer_sources, bufnumber)
      let source = s:buffer_sources[bufnumber]
      call neocomplcache#cache#check_cache_list('buffer_cache',
            \ source.path, s:async_dictionary_list, source.keyword_cache, 1)
    endif
  endfor
endfunction"}}}
function! s:check_cache() "{{{
  let release_accessd_time =
        \ localtime() - g:neocomplcache_release_cache_time

  for [key, source] in items(s:buffer_sources)
    " Check deleted buffer and access time.
    if !bufloaded(str2nr(key))
          \ || (source.accessed_time > 0 &&
          \ source.accessed_time < release_accessd_time)
      " Remove item.
      call remove(s:buffer_sources, key)
    endif
  endfor
endfunction"}}}
function! s:check_recache() "{{{
  if !s:exists_current_source()
    return
  endif

  let release_accessd_time =
        \ localtime() - g:neocomplcache_release_cache_time

  let source = s:buffer_sources[bufnr('%')]

  " Check buffer access time.
  if (source.cached_time > 0 && source.cached_time < release_accessd_time)
        \  || (neocomplcache#util#has_vimproc() && line('$') != source.end_line)
    " Buffer recache.
    if g:neocomplcache_enable_debug
      echomsg 'Caching buffer: ' . bufname('%')
    endif

    call neocomplcache#sources#buffer_complete#caching_current_block()
  endif
endfunction"}}}

function! s:exists_current_source() "{{{
  return has_key(s:buffer_sources, bufnr('%'))
endfunction"}}}

" Command functions. "{{{
function! neocomplcache#sources#buffer_complete#caching_buffer(name) "{{{
  if a:name == ''
    let number = bufnr('%')
  else
    let number = bufnr(a:name)

    if number < 0
      let bufnr = bufnr('%')

      " No swap warning.
      let save_shm = &shortmess
      set shortmess+=A

      " Open new buffer.
      execute 'silent! edit' fnameescape(a:name)

      let &shortmess = save_shm

      if bufnr('%') != bufnr
        setlocal nobuflisted
        execute 'buffer' bufnr
      endif
    endif

    let number = bufnr(a:name)
  endif

  " Word recaching.
  call s:word_caching(number)
  call s:caching_current_buffer(1, line('$'))
endfunction"}}}
function! neocomplcache#sources#buffer_complete#print_source(name) "{{{
  if a:name == ''
    let number = bufnr('%')
  else
    let number = bufnr(a:name)

    if number < 0
      call neocomplcache#print_error('Invalid buffer name.')
      return
    endif
  endif

  if !has_key(s:buffer_sources, number)
    return
  endif

  silent put=printf('Print neocomplcache %d source.', number)
  for key in keys(s:buffer_sources[number])
    silent put =printf('%s => %s', key, string(s:buffer_sources[number][key]))
  endfor
endfunction"}}}
function! neocomplcache#sources#buffer_complete#output_keyword(name) "{{{
  if a:name == ''
    let number = bufnr('%')
  else
    let number = bufnr(a:name)

    if number < 0
      call neocomplcache#print_error('Invalid buffer name.')
      return
    endif
  endif

  if !has_key(s:buffer_sources, number)
    return
  endif

  " Output buffer.
  for keyword in neocomplcache#unpack_dictionary(
        \ s:buffer_sources[number].keyword_cache)
    silent put=string(keyword)
  endfor
endfunction "}}}
function! neocomplcache#sources#buffer_complete#disable_caching(name) "{{{
  if a:name == ''
    let number = bufnr('%')
  else
    let number = bufnr(a:name)

    if number < 0
      call neocomplcache#print_error('Invalid buffer name.')
      return
    endif
  endif

  let s:disable_caching_list[number] = 1

  if has_key(s:buffer_sources, number)
    " Delete source.
    call remove(s:buffer_sources, number)
  endif
endfunction"}}}
function! neocomplcache#sources#buffer_complete#enable_caching(name) "{{{
  if a:name == ''
    let number = bufnr('%')
  else
    let number = bufnr(a:name)

    if number < 0
      call neocomplcache#print_error('Invalid buffer name.')
      return
    endif
  endif

  if has_key(s:disable_caching_list, number)
    call remove(s:disable_caching_list, number)
  endif
endfunction"}}}
"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/dictionary_complete.vim
================================================
"=============================================================================
" FILE: dictionary_complete.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 26 Sep 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

" Important variables.
if !exists('s:dictionary_list')
  let s:dictionary_list = {}
  let s:async_dictionary_list = {}
endif

function! neocomplcache#sources#dictionary_complete#define() "{{{
  return s:source
endfunction"}}}

let s:source = {
      \ 'name' : 'dictionary_complete',
      \ 'kind' : 'keyword',
      \ 'mark' : '[D]',
      \ 'rank' : 4,
      \}

function! s:source.initialize() "{{{
  " Initialize dictionary. "{{{
  if !exists('g:neocomplcache_dictionary_filetype_lists')
    let g:neocomplcache_dictionary_filetype_lists = {}
  endif
  if !has_key(g:neocomplcache_dictionary_filetype_lists, 'default')
    let g:neocomplcache_dictionary_filetype_lists['default'] = ''
  endif
  "}}}

  " Initialize dictionary completion pattern. "{{{
  if !exists('g:neocomplcache_dictionary_patterns')
    let g:neocomplcache_dictionary_patterns = {}
  endif
  "}}}

  " Set caching event.
  autocmd neocomplcache FileType * call s:caching()

  " Create cache directory.
  if !isdirectory(neocomplcache#get_temporary_directory() . '/dictionary_cache')
     \ && !neocomplcache#util#is_sudo()
    call mkdir(neocomplcache#get_temporary_directory() . '/dictionary_cache')
  endif

  " Initialize check.
  call s:caching()
endfunction"}}}

function! s:source.finalize() "{{{
  delcommand NeoComplCacheCachingDictionary
endfunction"}}}

function! s:source.get_keyword_list(complete_str) "{{{
  let list = []

  let filetype = neocomplcache#is_text_mode() ?
        \ 'text' : neocomplcache#get_context_filetype()
  if !has_key(s:dictionary_list, filetype)
    " Caching.
    call s:caching()
  endif

  for ft in neocomplcache#get_source_filetypes(filetype)
    call neocomplcache#cache#check_cache('dictionary_cache', ft,
          \ s:async_dictionary_list, s:dictionary_list, 1)

    for dict in neocomplcache#get_sources_list(s:dictionary_list, ft)
      let list += neocomplcache#dictionary_filter(dict, a:complete_str)
    endfor
  endfor

  return list
endfunction"}}}

function! s:caching() "{{{
  if !bufloaded(bufnr('%'))
    return
  endif

  let key = neocomplcache#is_text_mode() ?
        \ 'text' : neocomplcache#get_context_filetype()
  for filetype in neocomplcache#get_source_filetypes(key)
    if !has_key(s:dictionary_list, filetype)
          \ && !has_key(s:async_dictionary_list, filetype)
      call neocomplcache#sources#dictionary_complete#recaching(filetype)
    endif
  endfor
endfunction"}}}

function! s:caching_dictionary(filetype)
  let filetype = a:filetype
  if filetype == ''
    let filetype = neocomplcache#get_context_filetype(1)
  endif

  if has_key(s:async_dictionary_list, filetype)
        \ && filereadable(s:async_dictionary_list[filetype].cache_name)
    " Delete old cache.
    call delete(s:async_dictionary_list[filetype].cache_name)
  endif

  call neocomplcache#sources#dictionary_complete#recaching(filetype)
endfunction
function! neocomplcache#sources#dictionary_complete#recaching(filetype) "{{{
  if !exists('g:neocomplcache_dictionary_filetype_lists')
    call neocomplcache#initialize()
  endif

  let filetype = a:filetype
  if filetype == ''
    let filetype = neocomplcache#get_context_filetype(1)
  endif

  " Caching.
  let dictionaries = get(
        \ g:neocomplcache_dictionary_filetype_lists, filetype, '')

  if dictionaries == ''
    if filetype != &filetype &&
          \ &l:dictionary != '' && &l:dictionary !=# &g:dictionary
      let dictionaries .= &l:dictionary
    endif
  endif

  let s:async_dictionary_list[filetype] = []

  let pattern = get(g:neocomplcache_dictionary_patterns, filetype,
        \ neocomplcache#get_keyword_pattern(filetype))
  for dictionary in split(dictionaries, ',')
    let dictionary = neocomplcache#util#substitute_path_separator(
          \ fnamemodify(dictionary, ':p'))
    if filereadable(dictionary)
      call neocomplcache#print_debug('Caching dictionary: ' . dictionary)
      call add(s:async_dictionary_list[filetype], {
            \ 'filename' : dictionary,
            \ 'cachename' : neocomplcache#cache#async_load_from_file(
            \       'dictionary_cache', dictionary, pattern, 'D')
            \ })
    endif
  endfor
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/filename_complete.vim
================================================
"=============================================================================
" FILE: filename_complete.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 20 Jun 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

let s:source = {
      \ 'name' : 'filename_complete',
      \ 'kind' : 'manual',
      \ 'mark' : '[F]',
      \ 'rank' : 3,
      \ 'min_pattern_length' :
      \        g:neocomplcache_auto_completion_start_length,
      \}

function! s:source.initialize() "{{{
endfunction"}}}
function! s:source.finalize() "{{{
endfunction"}}}

function! s:source.get_keyword_pos(cur_text) "{{{
  let filetype = neocomplcache#get_context_filetype()
  if filetype ==# 'vimshell' || filetype ==# 'unite' || filetype ==# 'int-ssh'
    return -1
  endif

  " Filename pattern.
  let pattern = neocomplcache#get_keyword_pattern_end('filename')
  let [complete_pos, complete_str] =
        \ neocomplcache#match_word(a:cur_text, pattern)
  if complete_str =~ '//' ||
        \ (neocomplcache#is_auto_complete() &&
        \    (complete_str !~ '/' ||
        \     complete_str =~#
        \          '\\[^ ;*?[]"={}'']\|\.\.\+$\|/c\%[ygdrive/]$'))
    " Not filename pattern.
    return -1
  endif

  if neocomplcache#is_sources_complete() && complete_pos < 0
    let complete_pos = len(a:cur_text)
  endif

  return complete_pos
endfunction"}}}

function! s:source.get_complete_words(complete_pos, complete_str) "{{{
  return s:get_glob_files(a:complete_str, '')
endfunction"}}}

let s:cached_files = {}

function! s:get_glob_files(complete_str, path) "{{{
  let path = ',,' . substitute(a:path, '\.\%(,\|$\)\|,,', '', 'g')

  let complete_str = neocomplcache#util#substitute_path_separator(
        \ substitute(a:complete_str, '\\\(.\)', '\1', 'g'))

  let glob = (complete_str !~ '\*$')?
        \ complete_str . '*' : complete_str

  if a:path == '' && complete_str !~ '/'
    if !has_key(s:cached_files, getcwd())
      call s:caching_current_files()
    endif

    let files = copy(s:cached_files[getcwd()])
  else
    let ftype = getftype(glob)
    if ftype != '' && ftype !=# 'dir'
      " Note: If glob() device files, Vim may freeze!
      return []
    endif

    if a:path == ''
      let files = neocomplcache#util#glob(glob)
    else
      try
        let globs = globpath(path, glob)
      catch
        return []
      endtry
      let files = split(substitute(globs, '\\', '/', 'g'), '\n')
    endif
  endif

  let files = neocomplcache#keyword_filter(map(
        \ files, '{
        \    "word" : fnamemodify(v:val, ":t"),
        \    "orig" : v:val,
        \ }'),
        \ fnamemodify(complete_str, ':t'))

  if neocomplcache#is_auto_complete()
        \ && len(files) > g:neocomplcache_max_list
    let files = files[: g:neocomplcache_max_list - 1]
  endif

  let files = map(files, '{
        \    "word" : substitute(v:val.orig, "//", "/", "g"),
        \ }')

  if a:complete_str =~ '^\$\h\w*'
    let env = matchstr(a:complete_str, '^\$\h\w*')
    let env_ev = eval(env)
    if neocomplcache#is_windows()
      let env_ev = substitute(env_ev, '\\', '/', 'g')
    endif
    let len_env = len(env_ev)
  else
    let len_env = 0
  endif

  let home_pattern = '^'.
        \ neocomplcache#util#substitute_path_separator(
        \ expand('~')).'/'
  let exts = escape(substitute($PATHEXT, ';', '\\|', 'g'), '.')

  let dir_list = []
  let file_list = []
  for dict in files
    call add(isdirectory(dict.word) ?
          \ dir_list : file_list, dict)

    let dict.orig = dict.word

    if len_env != 0 && dict.word[: len_env-1] == env_ev
      let dict.word = env . dict.word[len_env :]
    endif

    let abbr = dict.word
    if isdirectory(dict.word) && dict.word !~ '/$'
      let abbr .= '/'
      if g:neocomplcache_enable_auto_delimiter
        let dict.word .= '/'
      endif
    elseif neocomplcache#is_windows()
      if '.'.fnamemodify(dict.word, ':e') =~ exts
        let abbr .= '*'
      endif
    elseif executable(dict.word)
      let abbr .= '*'
    endif
    let dict.abbr = abbr

    if a:complete_str =~ '^\~/'
      let dict.word = substitute(dict.word, home_pattern, '\~/', '')
      let dict.abbr = substitute(dict.abbr, home_pattern, '\~/', '')
    endif

    " Escape word.
    let dict.word = escape(dict.word, ' ;*?[]"={}''')
  endfor

  return dir_list + file_list
endfunction"}}}
function! s:caching_current_files() "{{{
  let s:cached_files[getcwd()] = neocomplcache#util#glob('*')
  if !exists('vimproc#readdir')
    let s:cached_files[getcwd()] += neocomplcache#util#glob('.*')
  endif
endfunction"}}}

function! neocomplcache#sources#filename_complete#define() "{{{
  return s:source
endfunction"}}}

function! neocomplcache#sources#filename_complete#get_complete_words(complete_str, path) "{{{
  if !neocomplcache#is_enabled()
    return []
  endif

  return s:get_glob_files(a:complete_str, a:path)
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/filename_include.vim
================================================
"=============================================================================
" FILE: filename_include.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 29 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

" Global options definition. "{{{
if !exists('g:neocomplcache_include_patterns')
  let g:neocomplcache_include_patterns = {}
endif
if !exists('g:neocomplcache_include_exprs')
  let g:neocomplcache_include_exprs = {}
endif
if !exists('g:neocomplcache_include_paths')
  let g:neocomplcache_include_paths = {}
endif
if !exists('g:neocomplcache_include_suffixes')
  let g:neocomplcache_include_suffixes = {}
endif
"}}}

let s:source = {
      \ 'name' : 'filename_include',
      \ 'kind' : 'manual',
      \ 'mark' : '[FI]',
      \ 'rank' : 10,
      \ 'min_pattern_length' :
      \        g:neocomplcache_auto_completion_start_length,
      \}

function! s:source.initialize() "{{{
  " Initialize.

  " Initialize filename include expr. "{{{
  let g:neocomplcache_filename_include_exprs =
        \ get(g:, 'neocomplcache_filename_include_exprs', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exprs',
        \ 'perl',
        \ 'fnamemodify(substitute(v:fname, "/", "::", "g"), ":r")')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exprs',
        \ 'ruby,python,java,d',
        \ 'fnamemodify(substitute(v:fname, "/", ".", "g"), ":r")')
  "}}}

  " Initialize filename include extensions. "{{{
  let g:neocomplcache_filename_include_exts =
        \ get(g:, 'neocomplcache_filename_include_exts', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exts',
        \ 'c', ['h'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exts',
        \ 'cpp', ['', 'h', 'hpp', 'hxx'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exts',
        \ 'perl', ['pm'])
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_filename_include_exts',
        \ 'java', ['java'])
  "}}}
endfunction"}}}
function! s:source.finalize() "{{{
endfunction"}}}

function! s:source.get_keyword_pos(cur_text) "{{{
  let filetype = neocomplcache#get_context_filetype()

  " Not Filename pattern.
  if exists('g:neocomplcache_include_patterns')
    let pattern = get(g:neocomplcache_include_patterns, filetype,
        \      &l:include)
  else
    let pattern = ''
  endif
  if neocomplcache#is_auto_complete()
        \ && (pattern == '' || a:cur_text !~ pattern)
        \ && a:cur_text =~ '\*$\|\.\.\+$\|/c\%[ygdrive/]$'
    " Skip filename completion.
    return -1
  endif

  " Check include pattern.
  let pattern = get(g:neocomplcache_include_patterns, filetype,
        \      &l:include)
  if pattern == '' || a:cur_text !~ pattern
    return -1
  endif

  let match_end = matchend(a:cur_text, pattern)
  let complete_str = matchstr(a:cur_text[match_end :], '\f\+')

  let expr = get(g:neocomplcache_include_exprs, filetype,
        \      &l:includeexpr)
  if expr != ''
    let cur_text =
          \ substitute(eval(substitute(expr,
          \ 'v:fname', string(complete_str), 'g')),
          \  '\.\w*$', '', '')
  endif

  let complete_pos = len(a:cur_text) - len(complete_str)
  if neocomplcache#is_sources_complete() && complete_pos < 0
    let complete_pos = len(a:cur_text)
  endif

  return complete_pos
endfunction"}}}

function! s:source.get_complete_words(complete_pos, complete_str) "{{{
  return s:get_include_files(a:complete_str)
endfunction"}}}

function! s:get_include_files(complete_str) "{{{
  let filetype = neocomplcache#get_context_filetype()

  let path = neocomplcache#util#substitute_path_separator(
        \ get(g:neocomplcache_include_paths, filetype,
        \   &l:path))
  let pattern = get(g:neocomplcache_include_patterns, filetype,
        \ &l:include)
  let expr = get(g:neocomplcache_include_exprs, filetype,
        \ &l:includeexpr)
  let reverse_expr = get(g:neocomplcache_filename_include_exprs, filetype,
        \ '')
  let exts = get(g:neocomplcache_filename_include_exts, filetype,
        \ [])

  let line = neocomplcache#get_cur_text()
  if line =~ '^\s*\<require_relative\>' && &filetype =~# 'ruby'
    " For require_relative.
    let path = '.'
  endif

  let match_end = matchend(line, pattern)
  let complete_str = matchstr(line[match_end :], '\f\+')
  if expr != ''
    let complete_str =
          \ substitute(eval(substitute(expr,
          \ 'v:fname', string(complete_str), 'g')), '\.\w*$', '', '')
  endif

  " Path search.
  let glob = (complete_str !~ '\*$')?
        \ complete_str . '*' : complete_str
  let cwd = getcwd()
  let bufdirectory = neocomplcache#util#substitute_path_separator(
        \ fnamemodify(expand('%'), ':p:h'))
  let dir_list = []
  let file_list = s:get_default_include_files(filetype)
  for subpath in split(path, '[,;]')
    let dir = (subpath == '.') ? bufdirectory : subpath
    if !isdirectory(dir)
      continue
    endif

    execute 'lcd' fnameescape(dir)

    for word in split(
          \ neocomplcache#util#substitute_path_separator(
          \   glob(glob)), '\n')
      let dict = { 'word' : word }

      call add(isdirectory(word) ? dir_list : file_list, dict)

      let abbr = dict.word
      if isdirectory(word)
        let abbr .= '/'
        if g:neocomplcache_enable_auto_delimiter
          let dict.word .= '/'
        endif
      elseif !empty(exts) &&
            \ index(exts, fnamemodify(dict.word, ':e')) < 0
        " Skip.
        continue
      endif
      let dict.abbr = abbr

      if reverse_expr != ''
        " Convert filename.
        let dict.word = eval(substitute(reverse_expr,
              \ 'v:fname', string(dict.word), 'g'))
        let dict.abbr = eval(substitute(reverse_expr,
              \ 'v:fname', string(dict.abbr), 'g'))
      else
        " Escape word.
        let dict.word = escape(dict.word, ' ;*?[]"={}''')
      endif
    endfor
  endfor
  execute 'lcd' fnameescape(cwd)

  return neocomplcache#keyword_filter(dir_list, a:complete_str)
        \ + neocomplcache#keyword_filter(file_list, a:complete_str)
endfunction"}}}

function! s:get_default_include_files(filetype) "{{{
  let files = []

  if a:filetype ==# 'python' || a:filetype ==# 'python3'
    let files = ['sys']
  endif

  return map(files, "{ 'word' : v:val }")
endfunction"}}}

function! neocomplcache#sources#filename_include#define() "{{{
  return s:source
endfunction"}}}

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/include_complete.vim
================================================
"=============================================================================
" FILE: include_complete.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 26 Sep 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this software and associated documentation files (the
"     "Software"), to deal in the Software without restriction, including
"     without limitation the rights to use, copy, modify, merge, publish,
"     distribute, sublicense, and/or sell copies of the Software, and to
"     permit persons to whom the Software is furnished to do so, subject to
"     the following conditions:
"
"     The above copyright notice and this permission notice shall be included
"     in all copies or substantial portions of the Software.
"
"     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
"     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
"     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
"     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
"     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
"     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================

let s:save_cpo = &cpo
set cpo&vim

let s:source = {
      \ 'name' : 'include_complete',
      \ 'kind' : 'keyword',
      \ 'rank' : 8,
      \}

function! s:source.initialize() "{{{
  call s:initialize_variables()

  if neocomplcache#has_vimproc()
    augroup neocomplcache
      " Caching events
      autocmd BufWritePost * call s:check_buffer('', 0)
      autocmd CursorHold * call s:check_cache()
    augroup END
  endif

  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_include_max_processes', 20)

  " Create cache directory.
  if !isdirectory(neocomplcache#get_temporary_directory() . '/include_cache')
     \ && !neocomplcache#util#is_sudo()
    call mkdir(neocomplcache#get_temporary_directory()
          \ . '/include_cache', 'p')
  endif

  if neocomplcache#exists_echodoc()
    call echodoc#register('include_complete', s:doc_dict)
  endif
endfunction"}}}

function! s:source.finalize() "{{{
  delcommand NeoComplCacheCachingInclude

  if neocomplcache#exists_echodoc()
    call echodoc#unregister('include_complete')
  endif
endfunction"}}}

function! s:source.get_keyword_list(complete_str) "{{{
  if neocomplcache#within_comment()
    return []
  endif

  if !has_key(s:include_info, bufnr('%'))
    " Auto caching.
    call s:check_buffer('', 0)
  endif

  let keyword_list = []

  " Check caching.
  for include in s:include_info[bufnr('%')].include_files
    call neocomplcache#cache#check_cache(
          \ 'include_cache', include, s:async_include_cache, s:include_cache)
    if has_key(s:include_cache, include)
      let s:cache_accessed_time[include] = localtime()
      let keyword_list += neocomplcache#dictionary_filter(
            \ s:include_cache[include], a:complete_str)
    endif
  endfor

  return neocomplcache#keyword_filter(
        \ neocomplcache#dup_filter(keyword_list), a:complete_str)
endfunction"}}}

function! neocomplcache#sources#include_complete#define() "{{{
  return s:source
endfunction"}}}

function! neocomplcache#sources#include_complete#get_include_files(bufnumber) "{{{
  if has_key(s:include_info, a:bufnumber)
    return copy(s:include_info[a:bufnumber].include_files)
  else
    return s:get_buffer_include_files(a:bufnumber)
  endif
endfunction"}}}

function! neocomplcache#sources#include_complete#get_include_tags(bufnumber) "{{{
  return filter(map(
        \ neocomplcache#sources#include_complete#get_include_files(a:bufnumber),
        \ "neocomplcache#cache#encode_name('tags_output', v:val)"),
        \ 'filereadable(v:val)')
endfunction"}}}

" For Debug.
function! neocomplcache#sources#include_complete#get_current_include_files() "{{{
  return s:get_buffer_include_files(bufnr('%'))
endfunction"}}}

" For echodoc. "{{{
let s:doc_dict = {
      \ 'name' : 'include_complete',
      \ 'rank' : 5,
      \ 'filetypes' : {},
      \ }
function! s:doc_dict.search(cur_text) "{{{
  if &filetype ==# 'vim' || !has_key(s:include_info, bufnr('%'))
    return []
  endif

  let completion_length = 2

  " Collect words.
  let words = []
  let i = 0
  while i >= 0
    let word = matchstr(a:cur_text, '\k\+', i)
    if len(word) >= completion_length
      call add(words, word)
    endif

    let i = matchend(a:cur_text, '\k\+', i)
  endwhile

  for word in reverse(words)
    let key = tolower(word[: completion_length-1])

    for include in filter(copy(s:include_info[bufnr('%')].include_files),
          \ 'has_key(s:include_cache, v:val) && has_key(s:include_cache[v:val], key)')
      for matched in filter(values(s:include_cache[include][key]),
            \ 'v:val.word ==# word && has_key(v:val, "kind") && v:val.kind != ""')
        let ret = []

        let match = match(matched.abbr, neocomplcache#escape_match(word))
        if match > 0
          call add(ret, { 'text' : matched.abbr[ : match-1] })
        endif

        call add(ret, { 'text' : word, 'highlight' : 'Identifier' })
        call add(ret, { 'text' : matched.abbr[match+len(word) :] })

        if match > 0 || len(ret[-1].text) > 0
          return ret
        endif
      endfor
    endfor
  endfor

  return []
endfunction"}}}
"}}}

function! s:check_buffer(bufnumber, is_force) "{{{
  if !neocomplcache#is_enabled_source('include_complete')
    return
  endif

  let bufnumber = (a:bufnumber == '') ? bufnr('%') : a:bufnumber
  let filename = fnamemodify(bufname(bufnumber), ':p')

  if !has_key(s:include_info, bufnumber)
    " Initialize.
    let s:include_info[bufnumber] = {
          \ 'include_files' : [], 'lines' : [],
          \ 'async_files' : {},
          \ }
  endif

  if !executable(g:neocomplcache_ctags_program)
        \ || (!a:is_force && !neocomplcache#has_vimproc())
    return
  endif

  let include_info = s:include_info[bufnumber]

  if a:is_force || include_info.lines !=# getbufline(bufnumber, 1, 100)
    let include_info.lines = getbufline(bufnumber, 1, 100)

    " Check include files contained bufname.
    let include_files = s:get_buffer_include_files(bufnumber)

    " Check include files from function.
    let filetype = getbufvar(a:bufnumber, '&filetype')
    let function = get(g:neocomplcache_include_functions, filetype, '')
    if function != '' && getbufvar(bufnumber, '&buftype') !~ 'nofile'
      let path = get(g:neocomplcache_include_paths, filetype,
            \ getbufvar(a:bufnumber, '&path'))
      let include_files += call(function,
            \ [getbufline(bufnumber, 1, (a:is_force ? '$' : 1000)), path])
    endif

    if getbufvar(bufnumber, '&buftype') !~ 'nofile'
          \ && filereadable(filename)
      call add(include_files, filename)
    endif
    let include_info.include_files = neocomplcache#util#uniq(include_files)
  endif

  if g:neocomplcache_include_max_processes <= 0
    return
  endif

  let filetype = getbufvar(bufnumber, '&filetype')
  if filetype == ''
    let filetype = 'nothing'
  endif

  for filename in include_info.include_files
    if (a:is_force || !has_key(include_info.async_files, filename))
          \ && !has_key(s:include_cache, filename)
      if !a:is_force && has_key(s:async_include_cache, filename)
            \ && len(s:async_include_cache[filename])
            \            >= g:neocomplcache_include_max_processes
        break
      endif

      " Caching.
      let s:async_include_cache[filename]
            \ = [ s:initialize_include(filename, filetype) ]
      let include_info.async_files[filename] = 1
    endif
  endfor
endfunction"}}}
function! s:get_buffer_include_files(bufnumber) "{{{
  let filetype = getbufvar(a:bufnumber, '&filetype')
  if filetype == ''
    return []
  endif

  if (filetype ==# 'python' || filetype ==# 'python3')
        \ && (executable('python') || executable('python3'))
    " Initialize python path pattern.

    let path = ''
    if executable('python3')
      let path .= ',' . neocomplcache#system('python3 -',
          \ 'import sys;sys.stdout.write(",".join(sys.path))')
      call neocomplcache#util#set_default_dictionary(
            \ 'g:neocomplcache_include_paths', 'python3', path)
    endif
    if executable('python')
      let path .= ',' . neocomplcache#system('python -',
          \ 'import sys;sys.stdout.write(",".join(sys.path))')
    endif
    let path = join(neocomplcache#util#uniq(filter(
          \ split(path, ',', 1), "v:val != ''")), ',')
    call neocomplcache#util#set_default_dictionary(
          \ 'g:neocomplcache_include_paths', 'python', path)
  elseif filetype ==# 'cpp' && isdirectory('/usr/include/c++')
    " Add cpp path.
    call neocomplcache#util#set_default_dictionary(
          \ 'g:neocomplcache_include_paths', 'cpp',
          \ getbufvar(a:bufnumber, '&path') .
          \ ','.join(split(glob('/usr/include/c++/*'), '\n'), ','))
  endif

  let pattern = get(g:neocomplcache_include_patterns, filetype,
        \ getbufvar(a:bufnumber, '&include'))
  if pattern == ''
    return []
  endif
  let path = get(g:neocomplcache_include_paths, filetype,
        \ getbufvar(a:bufnumber, '&path'))
  let expr = get(g:neocomplcache_include_exprs, filetype,
        \ getbufvar(a:bufnumber, '&includeexpr'))
  if has_key(g:neocomplcache_include_suffixes, filetype)
    let suffixes = &l:suffixesadd
  endif

  " Change current directory.
  let cwd_save = getcwd()
  let buffer_dir = fnamemodify(bufname(a:bufnumber), ':p:h')
  if isdirectory(buffer_dir)
    execute 'lcd' fnameescape(buffer_dir)
  endif

  let include_files = s:get_include_files(0,
        \ getbufline(a:bufnumber, 1, 100), filetype, pattern, path, expr)

  if isdirectory(buffer_dir)
    execute 'lcd' fnameescape(cwd_save)
  endif

  " Restore option.
  if has_key(g:neocomplcache_include_suffixes, filetype)
    let &l:suffixesadd = suffixes
  endif

  return include_files
endfunction"}}}
function! s:get_include_files(nestlevel, lines, filetype, pattern, path, expr) "{{{
  let include_files = []
  for line in a:lines "{{{
    if line =~ a:pattern
      let match_end = matchend(line, a:pattern)
      if a:expr != ''
        let eval = substitute(a:expr, 'v:fname',
              \ string(matchstr(line[match_end :], '\f\+')), 'g')
        let filename = fnamemodify(findfile(eval(eval), a:path), ':p')
      else
        let filename = fnamemodify(findfile(
              \ matchstr(line[match_end :], '\f\+'), a:path), ':p')
      endif

      if filereadable(filename)
        call add(include_files, filename)

        if (a:filetype == 'c' || a:filetype == 'cpp') && a:nestlevel < 1
          let include_files += s:get_include_files(
                \ a:nestlevel + 1, readfile(filename)[:100],
                \ a:filetype, a:pattern, a:path, a:expr)
        endif
      elseif isdirectory(filename) && a:filetype ==# 'java'
        " For Java import with *.
        " Ex: import lejos.nxt.*
        let include_files +=
              \ neocomplcache#util#glob(filename . '/*.java')
      endif
    endif
  endfor"}}}

  return include_files
endfunction"}}}

function! s:check_cache() "{{{
  if neocomplcache#is_disabled_source('include_complete')
    return
  endif

  let release_accessd_time = localtime() - g:neocomplcache_release_cache_time

  for key in keys(s:include_cache)
    if has_key(s:cache_accessed_time, key)
          \ && s:cache_accessed_time[key] < release_accessd_time
      call remove(s:include_cache, key)
    endif
  endfor
endfunction"}}}

function! s:initialize_include(filename, filetype) "{{{
  " Initialize include list from tags.
  return {
        \ 'filename' : a:filename,
        \ 'cachename' : neocomplcache#cache#async_load_from_tags(
        \              'include_cache', a:filename, a:filetype, 'I', 1)
        \ }
endfunction"}}}
function! neocomplcache#sources#include_complete#caching_include(bufname) "{{{
  let bufnumber = (a:bufname == '') ? bufnr('%') : bufnr(a:bufname)
  if has_key(s:async_include_cache, bufnumber)
        \ && filereadable(s:async_include_cache[bufnumber].cache_name)
    " Delete old cache.
    call delete(s:async_include_cache[bufnumber].cache_name)
  endif

  " Initialize.
  if has_key(s:include_info, bufnumber)
    call remove(s:include_info, bufnumber)
  endif

  call s:check_buffer(bufnumber, 1)
endfunction"}}}

" Analyze include files functions.
function! neocomplcache#sources#include_complete#analyze_vim_include_files(lines, path) "{{{
  let include_files = []
  let dup_check = {}
  for line in a:lines
    if line =~ '\<\h\w*#' && line !~ '\<function!\?\>'
      let filename = 'autoload/' . substitute(matchstr(line, '\<\%(\h\w*#\)*\h\w*\ze#'),
            \ '#', '/', 'g') . '.vim'
      if filename == '' || has_key(dup_check, filename)
        continue
      endif
      let dup_check[filename] = 1

      let filename = fnamemodify(findfile(filename, &runtimepath), ':p')
      if filereadable(filename)
        call add(include_files, filename)
      endif
    endif
  endfor

  return include_files
endfunction"}}}
function! neocomplcache#sources#include_complete#analyze_ruby_include_files(lines, path) "{{{
  let include_files = []
  let dup_check = {}
  for line in a:lines
    if line =~ '\<autoload\>'
      let args = split(line, ',')
      if len(args) < 2
        continue
      endif
      let filename = substitute(matchstr(args[1], '["'']\zs\f\+\ze["'']'),
            \ '\.', '/', 'g') . '.rb'
      if filename == '' || has_key(dup_check, filename)
        continue
      endif
      let dup_check[filename] = 1

      let filename = fnamemodify(findfile(filename, a:path), ':p')
      if filereadable(filename)
        call add(include_files, filename)
      endif
    endif
  endfor

  return include_files
endfunction"}}}

function! s:initialize_variables() "{{{
  let s:include_info = {}
  let s:include_cache = {}
  let s:cache_accessed_time = {}
  let s:async_include_cache = {}
  let s:cached_pattern = {}

  " Initialize include pattern. "{{{
  let g:neocomplcache_include_patterns =
        \ get(g:, 'neocomplcache_include_patterns', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_patterns',
        \ 'java,haskell', '^\s*\<import')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_patterns',
        \ 'cs', '^\s*\<using')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_patterns',
        \ 'ruby', '^\s*\<\%(load\|require\|require_relative\)\>')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_patterns',
        \ 'c,cpp', '^\s*#\s*include')
  "}}}
  " Initialize expr pattern. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_include_exprs', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_exprs',
        \ 'haskell,cs',
        \ "substitute(v:fname, '\\.', '/', 'g')")
  "}}}
  " Initialize path pattern. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_include_paths', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_paths', 'c,cpp',
        \ &path)
  "}}}
  " Initialize include suffixes. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_include_suffixes', {})
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_suffixes',
        \ 'haskell', '.hs')
  "}}}
  " Initialize include functions. "{{{
  call neocomplcache#util#set_default(
        \ 'g:neocomplcache_include_functions', {})
  " call neocomplcache#util#set_default_dictionary(
  "       \ 'g:neocomplcache_include_functions', 'vim',
  "       \ 'neocomplcache#sources#include_complete#analyze_vim_include_files')
  call neocomplcache#util#set_default_dictionary(
        \ 'g:neocomplcache_include_functions', 'ruby',
        \ 'neocomplcache#sources#include_complete#analyze_ruby_include_files')
  "}}}
endfunction"}}}

if !exists('s:include_info')
  call s:initialize_variables()
endif

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: foldmethod=marker


================================================
FILE: autoload/neocomplcache/sources/member_complete.vim
================================================
"=============================================================================
" FILE: member_complete.vim
" AUTHOR:  Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 01 May 2013.
" License: MIT license  {{{
"     Permission is hereby granted, free of charge, to any person obtaining
"     a copy of this softwa
Download .txt
gitextract_6vmgprjt/

├── .gitignore
├── README.md
├── autoload/
│   ├── neocomplcache/
│   │   ├── async_cache.vim
│   │   ├── cache.vim
│   │   ├── commands.vim
│   │   ├── complete.vim
│   │   ├── context_filetype.vim
│   │   ├── filters/
│   │   │   ├── converter_abbr.vim
│   │   │   ├── converter_case.vim
│   │   │   ├── converter_delimiter.vim
│   │   │   ├── converter_nothing.vim
│   │   │   ├── converter_remove_next_keyword.vim
│   │   │   ├── matcher_fuzzy.vim
│   │   │   ├── matcher_head.vim
│   │   │   ├── matcher_old.vim
│   │   │   ├── sorter_length.vim
│   │   │   ├── sorter_nothing.vim
│   │   │   └── sorter_rank.vim
│   │   ├── filters.vim
│   │   ├── handler.vim
│   │   ├── helper.vim
│   │   ├── init.vim
│   │   ├── mappings.vim
│   │   ├── sources/
│   │   │   ├── buffer_complete.vim
│   │   │   ├── dictionary_complete.vim
│   │   │   ├── filename_complete.vim
│   │   │   ├── filename_include.vim
│   │   │   ├── include_complete.vim
│   │   │   ├── member_complete.vim
│   │   │   ├── omni_complete.vim
│   │   │   ├── syntax_complete.vim
│   │   │   ├── tags_complete.vim
│   │   │   ├── vim_complete/
│   │   │   │   ├── autocmds.dict
│   │   │   │   ├── command_args.dict
│   │   │   │   ├── command_completions.dict
│   │   │   │   ├── command_prototypes.dict
│   │   │   │   ├── command_replaces.dict
│   │   │   │   ├── commands.dict
│   │   │   │   ├── features.dict
│   │   │   │   ├── functions.dict
│   │   │   │   ├── helper.vim
│   │   │   │   ├── mappings.dict
│   │   │   │   ├── options.dict
│   │   │   │   └── variables.dict
│   │   │   └── vim_complete.vim
│   │   ├── util.vim
│   │   └── variables.vim
│   ├── neocomplcache.vim
│   └── unite/
│       └── sources/
│           ├── file_include.vim
│           └── neocomplcache.vim
├── doc/
│   └── neocomplcache.txt
├── plugin/
│   ├── neocomplcache/
│   │   ├── buffer_complete.vim
│   │   ├── dictionary_complete.vim
│   │   ├── include_complete.vim
│   │   ├── syntax_complete.vim
│   │   └── tags_complete.vim
│   └── neocomplcache.vim
└── vest/
    └── test-neocomplcache.vim
Condensed preview — 58 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (501K chars).
[
  {
    "path": ".gitignore",
    "chars": 16,
    "preview": "doc/tags*\n*.swp\n"
  },
  {
    "path": "README.md",
    "chars": 5745,
    "preview": "**neocomplcache**\n=================\n\n**Note**: The development of this plugin is finished. Accepts minor patches and\niss"
  },
  {
    "path": "autoload/neocomplcache/async_cache.vim",
    "chars": 9094,
    "preview": "\"=============================================================================\n\" FILE: async_cache.vim\n\" AUTHOR: Shougo "
  },
  {
    "path": "autoload/neocomplcache/cache.vim",
    "chars": 13160,
    "preview": "\"=============================================================================\n\" FILE: cache.vim\n\" AUTHOR: Shougo Matsus"
  },
  {
    "path": "autoload/neocomplcache/commands.vim",
    "chars": 7118,
    "preview": "\"=============================================================================\n\" FILE: commands.vim\n\" AUTHOR: Shougo Mat"
  },
  {
    "path": "autoload/neocomplcache/complete.vim",
    "chars": 12362,
    "preview": "\"=============================================================================\n\" FILE: complete.vim\n\" AUTHOR: Shougo Mat"
  },
  {
    "path": "autoload/neocomplcache/context_filetype.vim",
    "chars": 7449,
    "preview": "\"=============================================================================\n\" FILE: context_filetype.vim\n\" AUTHOR: Sh"
  },
  {
    "path": "autoload/neocomplcache/filters/converter_abbr.vim",
    "chars": 2364,
    "preview": "\"=============================================================================\n\" FILE: converter_abbr.vim\n\" AUTHOR:  Sho"
  },
  {
    "path": "autoload/neocomplcache/filters/converter_case.vim",
    "chars": 2945,
    "preview": "\"=============================================================================\n\" FILE: converter_case.vim\n\" AUTHOR:  Sho"
  },
  {
    "path": "autoload/neocomplcache/filters/converter_delimiter.vim",
    "chars": 3542,
    "preview": "\"=============================================================================\n\" FILE: converter_delimiter.vim\n\" AUTHOR:"
  },
  {
    "path": "autoload/neocomplcache/filters/converter_nothing.vim",
    "chars": 1846,
    "preview": "\"=============================================================================\n\" FILE: converter_nothing.vim\n\" AUTHOR:  "
  },
  {
    "path": "autoload/neocomplcache/filters/converter_remove_next_keyword.vim",
    "chars": 3108,
    "preview": "\"=============================================================================\n\" FILE: converter_remove_next_keyword.vim"
  },
  {
    "path": "autoload/neocomplcache/filters/matcher_fuzzy.vim",
    "chars": 1803,
    "preview": "\"=============================================================================\n\" FILE: matcher_fuzzy.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/neocomplcache/filters/matcher_head.vim",
    "chars": 1799,
    "preview": "\"=============================================================================\n\" FILE: matcher_head.vim\n\" AUTHOR:  Shoug"
  },
  {
    "path": "autoload/neocomplcache/filters/matcher_old.vim",
    "chars": 2117,
    "preview": "\"=============================================================================\n\" FILE: matcher_old.vim\n\" AUTHOR:  Shougo"
  },
  {
    "path": "autoload/neocomplcache/filters/sorter_length.vim",
    "chars": 2002,
    "preview": "\"=============================================================================\n\" FILE: sorter_length.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/neocomplcache/filters/sorter_nothing.vim",
    "chars": 1817,
    "preview": "\"=============================================================================\n\" FILE: sorter_nothing.vim\n\" AUTHOR:  Sho"
  },
  {
    "path": "autoload/neocomplcache/filters/sorter_rank.vim",
    "chars": 1999,
    "preview": "\"=============================================================================\n\" FILE: sorter_rank.vim\n\" AUTHOR:  Shougo"
  },
  {
    "path": "autoload/neocomplcache/filters.vim",
    "chars": 4449,
    "preview": "\"=============================================================================\n\" FILE: filters.vim\n\" AUTHOR: Shougo Mats"
  },
  {
    "path": "autoload/neocomplcache/handler.vim",
    "chars": 9215,
    "preview": "\"=============================================================================\n\" FILE: handler.vim\n\" AUTHOR: Shougo Mats"
  },
  {
    "path": "autoload/neocomplcache/helper.vim",
    "chars": 14542,
    "preview": "\"=============================================================================\n\" FILE: helper.vim\n\" AUTHOR: Shougo Matsu"
  },
  {
    "path": "autoload/neocomplcache/init.vim",
    "chars": 31632,
    "preview": "\"=============================================================================\n\" FILE: init.vim\n\" AUTHOR: Shougo Matsush"
  },
  {
    "path": "autoload/neocomplcache/mappings.vim",
    "chars": 6294,
    "preview": "\"=============================================================================\n\" FILE: mappings.vim\n\" AUTHOR: Shougo Mat"
  },
  {
    "path": "autoload/neocomplcache/sources/buffer_complete.vim",
    "chars": 12820,
    "preview": "\"=============================================================================\n\" FILE: buffer_complete.vim\n\" AUTHOR:  Sh"
  },
  {
    "path": "autoload/neocomplcache/sources/dictionary_complete.vim",
    "chars": 5698,
    "preview": "\"=============================================================================\n\" FILE: dictionary_complete.vim\n\" AUTHOR:"
  },
  {
    "path": "autoload/neocomplcache/sources/filename_complete.vim",
    "chars": 6189,
    "preview": "\"=============================================================================\n\" FILE: filename_complete.vim\n\" AUTHOR:  "
  },
  {
    "path": "autoload/neocomplcache/sources/filename_include.vim",
    "chars": 7870,
    "preview": "\"=============================================================================\n\" FILE: filename_include.vim\n\" AUTHOR:  S"
  },
  {
    "path": "autoload/neocomplcache/sources/include_complete.vim",
    "chars": 16353,
    "preview": "\"=============================================================================\n\" FILE: include_complete.vim\n\" AUTHOR:  S"
  },
  {
    "path": "autoload/neocomplcache/sources/member_complete.vim",
    "chars": 8295,
    "preview": "\"=============================================================================\n\" FILE: member_complete.vim\n\" AUTHOR:  Sh"
  },
  {
    "path": "autoload/neocomplcache/sources/omni_complete.vim",
    "chars": 9136,
    "preview": "\"=============================================================================\n\" FILE: omni_complete.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/neocomplcache/sources/syntax_complete.vim",
    "chars": 9538,
    "preview": "\"=============================================================================\n\" FILE: syntax_complete.vim\n\" AUTHOR:  Sh"
  },
  {
    "path": "autoload/neocomplcache/sources/tags_complete.vim",
    "chars": 3859,
    "preview": "\"=============================================================================\n\" FILE: tags_complete.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/autocmds.dict",
    "chars": 4436,
    "preview": "BufNewFile ; starting to edit a file that doesn't exist\nBufReadPre ; starting to edit a new buffer, before reading the f"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/command_args.dict",
    "chars": 2048,
    "preview": "-bang ; the command can take a ! modifier (like :q or :w)\n-bar ; the command can be followed by a \"|\" and another comman"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/command_completions.dict",
    "chars": 8834,
    "preview": "N[ext]\nP[rint]\na[ppend]\nab[breviate]    abbreviation\nabc[lear]\nabo[veleft]     command\nal[l]           \nam[enu]\nan[oreme"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/command_prototypes.dict",
    "chars": 12249,
    "preview": "N[ext]          [count] [++opt] [+cmd]\nP[rint]         [count] [flags]\na[ppend]\nab[breviate]\nabc[lear]\nabo[veleft]     {"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/command_replaces.dict",
    "chars": 624,
    "preview": "<line1> ; the starting line of the command range\n<line2> ; the final line of the command range\n<count> ; any count suppl"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/commands.dict",
    "chars": 20355,
    "preview": "Next\t; go to previous file in the argument list\nPrint\t; print lines\nabbreviate\t; enter abbreviation\nabclear\t; remove all"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/features.dict",
    "chars": 8223,
    "preview": "all_builtin_terms ; Compiled with all builtin terminals enabled.\namiga ; Amiga version of Vim.\narabic ; Compiled with Ar"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/functions.dict",
    "chars": 5854,
    "preview": "abs({expr})\nacos({expr})\nadd({list}, {item})\nappend({lnum}, {list})\nappend({lnum}, {string})\nargc()\nargidx()\nargv()\nargv"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/helper.vim",
    "chars": 34400,
    "preview": "\"=============================================================================\n\" FILE: helper.vim\n\" AUTHOR:  Shougo Mats"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/mappings.dict",
    "chars": 2541,
    "preview": "<buffer> ; the mapping will be effective in the current buffer only\n<expr> ; the argument is an expression evaluated to "
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/options.dict",
    "chars": 18271,
    "preview": "aleph ; ASCII code of the letter Aleph (Hebrew)\nallowrevins ; allow CTRL-_ in Insert and Command-line mode\naltkeymap ; f"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete/variables.dict",
    "chars": 3624,
    "preview": "v:beval_col ; the number of the column, over which the mouse pointer is\nv:beval_bufnr ; the number of the buffer, over w"
  },
  {
    "path": "autoload/neocomplcache/sources/vim_complete.vim",
    "chars": 7097,
    "preview": "\"=============================================================================\n\" FILE: vim_complete.vim\n\" AUTHOR:  Shoug"
  },
  {
    "path": "autoload/neocomplcache/util.vim",
    "chars": 12022,
    "preview": "\"=============================================================================\n\" FILE: util.vim\n\" AUTHOR: Shougo Matsush"
  },
  {
    "path": "autoload/neocomplcache/variables.vim",
    "chars": 2414,
    "preview": "\"=============================================================================\n\" FILE: variables.vim\n\" AUTHOR: Shougo Ma"
  },
  {
    "path": "autoload/neocomplcache.vim",
    "chars": 14567,
    "preview": "\"=============================================================================\n\" FILE: neocomplcache.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/unite/sources/file_include.vim",
    "chars": 2771,
    "preview": "\"=============================================================================\n\" FILE: neocomplcache.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "autoload/unite/sources/neocomplcache.vim",
    "chars": 4682,
    "preview": "\"=============================================================================\n\" FILE: neocomplcache.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "doc/neocomplcache.txt",
    "chars": 68365,
    "preview": "*neocomplcache.txt*\tUltimate auto completion system for Vim\n\nVersion: 8.2\nAuthor : Shougo <Shougo.Matsu@gmail.com>\nLicen"
  },
  {
    "path": "plugin/neocomplcache/buffer_complete.vim",
    "chars": 1265,
    "preview": "\"=============================================================================\n\" FILE: buffer_complete.vim\n\" AUTHOR:  Sh"
  },
  {
    "path": "plugin/neocomplcache/dictionary_complete.vim",
    "chars": 711,
    "preview": "\"=============================================================================\n\" FILE: dictionary_complete.vim\n\" AUTHOR:"
  },
  {
    "path": "plugin/neocomplcache/include_complete.vim",
    "chars": 658,
    "preview": "\"=============================================================================\n\" FILE: include_complete.vim\n\" AUTHOR:  S"
  },
  {
    "path": "plugin/neocomplcache/syntax_complete.vim",
    "chars": 691,
    "preview": "\"=============================================================================\n\" FILE: syntax_complete.vim\n\" AUTHOR:  Sh"
  },
  {
    "path": "plugin/neocomplcache/tags_complete.vim",
    "chars": 629,
    "preview": "\"=============================================================================\n\" FILE: tags_complete.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "plugin/neocomplcache.vim",
    "chars": 8816,
    "preview": "\"=============================================================================\n\" FILE: neocomplcache.vim\n\" AUTHOR:  Shou"
  },
  {
    "path": "vest/test-neocomplcache.vim",
    "chars": 490,
    "preview": "scriptencoding utf-8\n\n\" Saving 'cpoptions' {{{\nlet s:save_cpo = &cpo\nset cpo&vim\n\" }}}\n\nContext types\n  It tests compare"
  }
]

About this extraction

This page contains the full source code of the Shougo/neocomplcache GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 58 files (461.7 KB), approximately 132.0k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!