- Vitalized.

This commit is contained in:
Shougo Matsushita
2012-09-30 17:06:28 +09:00
parent cb51dd674d
commit c07fdec557
6 changed files with 547 additions and 85 deletions

View File

@@ -1,7 +1,7 @@
"=============================================================================
" FILE: util.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 28 Sep 2012.
" Last Modified: 30 Sep 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -27,108 +27,34 @@
let s:save_cpo = &cpo
set cpo&vim
let s:V = vital#of('neocomplcache')
let s:List = vital#of('neocomplcache').import('Data.List')
let s:V = vital#of('neosnippet')
function! neocomplcache#util#truncate_smart(...)"{{{
return call(s:V.truncate_smart, a:000)
endfunction"}}}
function! neocomplcache#util#truncate(...)"{{{
return call(s:V.truncate, a:000)
endfunction"}}}
function! neocomplcache#util#strchars(...)"{{{
return call(s:V.strchars, a:000)
endfunction"}}}
function! neocomplcache#util#wcswidth(...)"{{{
return call(s:V.wcswidth, a:000)
endfunction"}}}
function! neocomplcache#util#strwidthpart(...)"{{{
return call(s:V.strwidthpart, a:000)
endfunction"}}}
function! neocomplcache#util#strwidthpart_reverse(...)"{{{
return call(s:V.strwidthpart_reverse, a:000)
endfunction"}}}
function! neocomplcache#util#substitute_path_separator(...)"{{{
function! neosnippet#util#substitute_path_separator(...)"{{{
return call(s:V.substitute_path_separator, a:000)
endfunction"}}}
function! neocomplcache#util#mb_strlen(...)"{{{
return call(s:V.strchars, a:000)
endfunction"}}}
function! neocomplcache#util#uniq(list)"{{{
let dict = {}
for item in a:list
if !has_key(dict, item)
let dict[item] = item
endif
endfor
return values(dict)
endfunction"}}}
function! neocomplcache#util#system(...)"{{{
function! neosnippet#util#system(...)"{{{
return call(s:V.system, a:000)
endfunction"}}}
function! neocomplcache#util#has_vimproc(...)"{{{
function! neosnippet#util#has_vimproc(...)"{{{
return call(s:V.has_vimproc, a:000)
endfunction"}}}
function! neocomplcache#util#is_windows(...)"{{{
function! neosnippet#util#is_windows(...)"{{{
return call(s:V.is_windows, a:000)
endfunction"}}}
function! neocomplcache#util#is_mac(...)"{{{
function! neosnippet#util#is_mac(...)"{{{
return call(s:V.is_mac, a:000)
endfunction"}}}
function! neocomplcache#util#get_last_status(...)"{{{
function! neosnippet#util#get_last_status(...)"{{{
return call(s:V.get_last_status, a:000)
endfunction"}}}
function! neocomplcache#util#escape_pattern(...)"{{{
function! neosnippet#util#escape_pattern(...)"{{{
return call(s:V.escape_pattern, a:000)
endfunction"}}}
function! neocomplcache#util#iconv(...)"{{{
function! neosnippet#util#iconv(...)"{{{
return call(s:V.iconv, a:000)
endfunction"}}}
function! neocomplcache#util#uniq(...)"{{{
return call(s:List.uniq, a:000)
endfunction"}}}
function! neocomplcache#util#glob(pattern, ...)"{{{
if a:pattern =~ "'"
" Use glob('*').
let cwd = getcwd()
let base = neocomplcache#util#substitute_path_separator(
\ fnamemodify(a:pattern, ':h'))
lcd `=base`
let files = map(split(neocomplcache#util#substitute_path_separator(
\ glob('*')), '\n'), "base . '/' . v:val")
lcd `=cwd`
return files
endif
" let is_force_glob = get(a:000, 0, 0)
let is_force_glob = get(a:000, 0, 1)
if !is_force_glob && a:pattern =~ '^[^\\*]\+/\*'
\ && neocomplcache#util#has_vimproc() && exists('*vimproc#readdir')
return filter(vimproc#readdir(a:pattern[: -2]), 'v:val !~ "/\\.\\.\\?$"')
else
" Escape [.
if neocomplcache#util#is_windows()
let glob = substitute(a:pattern, '\[', '\\[[]', 'g')
else
let glob = escape(a:pattern, '[')
endif
return split(neocomplcache#util#substitute_path_separator(glob(glob)), '\n')
endif
endfunction"}}}
function! neocomplcache#util#expand(path)"{{{
return expand(escape(a:path, '*?[]"={}'), 1)
endfunction"}}}
function! neocomplcache#util#set_dictionary_helper(...)"{{{
function! neosnippet#util#set_dictionary_helper(...)"{{{
return call(s:V.set_dictionary_helper, a:000)
endfunction"}}}