Update vital
This commit is contained in:
parent
d23ee02b49
commit
7502b06be0
@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" FILE: util.vim
|
" FILE: util.vim
|
||||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||||
" Last Modified: 13 Nov 2013.
|
" Last Modified: 15 Feb 2014.
|
||||||
" License: MIT license {{{
|
" License: MIT license {{{
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining
|
" Permission is hereby granted, free of charge, to any person obtaining
|
||||||
" a copy of this software and associated documentation files (the
|
" a copy of this software and associated documentation files (the
|
||||||
@ -28,36 +28,57 @@ let s:save_cpo = &cpo
|
|||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let s:V = vital#of('neosnippet')
|
let s:V = vital#of('neosnippet')
|
||||||
|
function! neosnippet#util#get_vital() "{{{
|
||||||
|
return s:V
|
||||||
|
endfunction"}}}
|
||||||
|
function! s:get_prelude() "{{{
|
||||||
|
if !exists('s:Prelude')
|
||||||
|
let s:Prelude = neosnippet#util#get_vital().import('Prelude')
|
||||||
|
endif
|
||||||
|
return s:Prelude
|
||||||
|
endfunction"}}}
|
||||||
|
function! s:get_list() "{{{
|
||||||
|
if !exists('s:List')
|
||||||
|
let s:List = neosnippet#util#get_vital().import('Data.List')
|
||||||
|
endif
|
||||||
|
return s:List
|
||||||
|
endfunction"}}}
|
||||||
|
function! s:get_process() "{{{
|
||||||
|
if !exists('s:Process')
|
||||||
|
let s:Process = neosnippet#util#get_vital().import('Process')
|
||||||
|
endif
|
||||||
|
return s:Process
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#substitute_path_separator(...) "{{{
|
function! neosnippet#util#substitute_path_separator(...) "{{{
|
||||||
return call(s:V.substitute_path_separator, a:000)
|
return call(s:get_prelude().substitute_path_separator, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#system(...) "{{{
|
function! neosnippet#util#system(...) "{{{
|
||||||
return call(s:V.system, a:000)
|
return call(s:get_process().system, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#has_vimproc(...) "{{{
|
function! neosnippet#util#has_vimproc(...) "{{{
|
||||||
return call(s:V.has_vimproc, a:000)
|
return call(s:get_process().has_vimproc, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#is_windows(...) "{{{
|
function! neosnippet#util#is_windows(...) "{{{
|
||||||
return call(s:V.is_windows, a:000)
|
return call(s:get_prelude().is_windows, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#is_mac(...) "{{{
|
function! neosnippet#util#is_mac(...) "{{{
|
||||||
return call(s:V.is_mac, a:000)
|
return call(s:get_prelude().is_mac, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#get_last_status(...) "{{{
|
function! neosnippet#util#get_last_status(...) "{{{
|
||||||
return call(s:V.get_last_status, a:000)
|
return call(s:get_process().get_last_status, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#escape_pattern(...) "{{{
|
function! neosnippet#util#escape_pattern(...) "{{{
|
||||||
return call(s:V.escape_pattern, a:000)
|
return call(s:get_prelude().escape_pattern, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#iconv(...) "{{{
|
function! neosnippet#util#iconv(...) "{{{
|
||||||
return call(s:V.iconv, a:000)
|
return call(s:get_process().iconv, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#truncate(...) "{{{
|
function! neosnippet#util#truncate(...) "{{{
|
||||||
return call(s:V.truncate, a:000)
|
return call(s:get_prelude().truncate, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#strwidthpart(...) "{{{
|
function! neosnippet#util#strwidthpart(...) "{{{
|
||||||
return call(s:V.strwidthpart, a:000)
|
return call(s:get_prelude().strwidthpart, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#expand(path) "{{{
|
function! neosnippet#util#expand(path) "{{{
|
||||||
@ -70,7 +91,7 @@ function! neosnippet#util#set_default(var, val, ...) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#set_dictionary_helper(...) "{{{
|
function! neosnippet#util#set_dictionary_helper(...) "{{{
|
||||||
return call(s:V.set_dictionary_helper, a:000)
|
return call(s:get_prelude().set_dictionary_helper, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#get_cur_text() "{{{
|
function! neosnippet#util#get_cur_text() "{{{
|
||||||
|
@ -199,5 +199,5 @@ function! s:_redir(cmd)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vital#{s:self_version}#new()
|
function! vital#{s:self_version}#new()
|
||||||
return s:_import('').load(['Prelude', ''])
|
return s:_import('')
|
||||||
endfunction
|
endfunction
|
@ -24,18 +24,22 @@ function! s:cons(x, xs)
|
|||||||
return [a:x] + a:xs
|
return [a:x] + a:xs
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" TODO spec
|
|
||||||
function! s:conj(xs, x)
|
function! s:conj(xs, x)
|
||||||
return a:xs + [a:x]
|
return a:xs + [a:x]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Removes duplicates from a list.
|
" Removes duplicates from a list.
|
||||||
function! s:uniq(list, ...)
|
function! s:uniq(list)
|
||||||
let list = a:0 ? map(copy(a:list), printf('[v:val, %s]', a:1)) : copy(a:list)
|
return s:uniq_by(a:list, 'v:val')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Removes duplicates from a list.
|
||||||
|
function! s:uniq_by(list, f)
|
||||||
|
let list = map(copy(a:list), printf('[v:val, %s]', a:f))
|
||||||
let i = 0
|
let i = 0
|
||||||
let seen = {}
|
let seen = {}
|
||||||
while i < len(list)
|
while i < len(list)
|
||||||
let key = string(a:0 ? list[i][1] : list[i])
|
let key = string(list[i][1])
|
||||||
if has_key(seen, key)
|
if has_key(seen, key)
|
||||||
call remove(list, i)
|
call remove(list, i)
|
||||||
else
|
else
|
||||||
@ -43,7 +47,7 @@ function! s:uniq(list, ...)
|
|||||||
let i += 1
|
let i += 1
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
return a:0 ? map(list, 'v:val[0]') : list
|
return map(list, 'v:val[0]')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:clear(list)
|
function! s:clear(list)
|
||||||
@ -56,30 +60,29 @@ endfunction
|
|||||||
" Concatenates a list of lists.
|
" Concatenates a list of lists.
|
||||||
" XXX: Should we verify the input?
|
" XXX: Should we verify the input?
|
||||||
function! s:concat(list)
|
function! s:concat(list)
|
||||||
let list = []
|
let memo = []
|
||||||
for Value in a:list
|
for Value in a:list
|
||||||
let list += Value
|
let memo += Value
|
||||||
endfor
|
endfor
|
||||||
return list
|
return memo
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Flattens a list.
|
" Take each elements from lists to a new list.
|
||||||
function! s:flatten(list, ...)
|
function! s:flatten(list, ...)
|
||||||
let limit = a:0 > 0 ? a:1 : -1
|
let limit = a:0 > 0 ? a:1 : -1
|
||||||
let list = []
|
let memo = []
|
||||||
if limit == 0
|
if limit == 0
|
||||||
return a:list
|
return a:list
|
||||||
endif
|
endif
|
||||||
let limit -= 1
|
let limit -= 1
|
||||||
for Value in a:list
|
for Value in a:list
|
||||||
if type(Value) == type([])
|
let memo +=
|
||||||
let list += s:flatten(Value, limit)
|
\ type(Value) == type([]) ?
|
||||||
else
|
\ s:flatten(Value, limit) :
|
||||||
call add(list, Value)
|
\ [Value]
|
||||||
endif
|
|
||||||
unlet! Value
|
unlet! Value
|
||||||
endfor
|
endfor
|
||||||
return list
|
return memo
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Sorts a list with expression to compare each two values.
|
" Sorts a list with expression to compare each two values.
|
||||||
@ -105,11 +108,6 @@ function! s:sort_by(list, expr)
|
|||||||
\ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'), 'v:val[0]')
|
\ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'), 'v:val[0]')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:max(list, expr)
|
|
||||||
echoerr 'Data.List.max() is obsolete. Use its max_by() instead.'
|
|
||||||
return s:max_by(a:list, a:expr)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Returns a maximum value in {list} through given {expr}.
|
" Returns a maximum value in {list} through given {expr}.
|
||||||
" Returns 0 if {list} is empty.
|
" Returns 0 if {list} is empty.
|
||||||
" v:val is used in {expr}
|
" v:val is used in {expr}
|
||||||
@ -121,11 +119,6 @@ function! s:max_by(list, expr)
|
|||||||
return a:list[index(list, max(list))]
|
return a:list[index(list, max(list))]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:min(list, expr)
|
|
||||||
echoerr 'Data.List.min() is obsolete. Use its min_by() instead.'
|
|
||||||
return s:min_by(a:list, a:expr)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Returns a minimum value in {list} through given {expr}.
|
" Returns a minimum value in {list} through given {expr}.
|
||||||
" Returns 0 if {list} is empty.
|
" Returns 0 if {list} is empty.
|
||||||
" v:val is used in {expr}
|
" v:val is used in {expr}
|
@ -49,11 +49,6 @@ function! s:is_numeric(Value)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Number
|
" Number
|
||||||
function! s:is_integer(Value)
|
|
||||||
echoerr 'Prelude.is_integer() is obsolete. Use its is_number() instead; they are equivalent.'
|
|
||||||
return s:is_number(a:Value)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:is_number(Value)
|
function! s:is_number(Value)
|
||||||
return type(a:Value) ==# s:__TYPE_NUMBER
|
return type(a:Value) ==# s:__TYPE_NUMBER
|
||||||
endfunction
|
endfunction
|
||||||
@ -220,7 +215,14 @@ function! s:is_unix()
|
|||||||
return s:is_unix
|
return s:is_unix
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:_deprecated(fname, newname)
|
||||||
|
echomsg printf("Vital.Prelude.%s is deprecated! Please use %s instead.",
|
||||||
|
\ a:fname, a:newname)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:print_error(message)
|
function! s:print_error(message)
|
||||||
|
call s:_deprecated('print_error', 'Vital.Vim.Message.error')
|
||||||
|
|
||||||
echohl ErrorMsg
|
echohl ErrorMsg
|
||||||
for m in split(a:message, "\n")
|
for m in split(a:message, "\n")
|
||||||
echomsg m
|
echomsg m
|
||||||
@ -240,47 +242,32 @@ function! s:escape_pattern(str)
|
|||||||
return escape(a:str, '~"\.^$[]*')
|
return escape(a:str, '~"\.^$[]*')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" iconv() wrapper for safety.
|
|
||||||
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
|
|
||||||
|
|
||||||
" Like builtin getchar() but returns string always.
|
|
||||||
function! s:getchar(...)
|
function! s:getchar(...)
|
||||||
let c = call('getchar', a:000)
|
let c = call('getchar', a:000)
|
||||||
return type(c) == type(0) ? nr2char(c) : c
|
return type(c) == type(0) ? nr2char(c) : c
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Like builtin getchar() but returns string always.
|
|
||||||
" and do inputsave()/inputrestore() before/after getchar().
|
|
||||||
function! s:getchar_safe(...)
|
function! s:getchar_safe(...)
|
||||||
let c = s:input_helper('getchar', a:000)
|
let c = s:input_helper('getchar', a:000)
|
||||||
return type(c) == type("") ? c : nr2char(c)
|
return type(c) == type("") ? c : nr2char(c)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Like builtin getchar() but
|
|
||||||
" do inputsave()/inputrestore() before/after input().
|
|
||||||
function! s:input_safe(...)
|
function! s:input_safe(...)
|
||||||
return s:input_helper('input', a:000)
|
return s:input_helper('input', a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Do inputsave()/inputrestore() before/after calling a:funcname.
|
|
||||||
function! s:input_helper(funcname, args)
|
function! s:input_helper(funcname, args)
|
||||||
let success = 0
|
let success = 0
|
||||||
if inputsave() !=# success
|
if inputsave() !=# success
|
||||||
throw 'inputsave() failed'
|
throw 'inputsave() failed'
|
||||||
|
endif
|
||||||
|
try
|
||||||
|
return call(a:funcname, a:args)
|
||||||
|
finally
|
||||||
|
if inputrestore() !=# success
|
||||||
|
throw 'inputrestore() failed'
|
||||||
endif
|
endif
|
||||||
try
|
endtry
|
||||||
return call(a:funcname, a:args)
|
|
||||||
finally
|
|
||||||
if inputrestore() !=# success
|
|
||||||
throw 'inputrestore() failed'
|
|
||||||
endif
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:set_default(var, val)
|
function! s:set_default(var, val)
|
||||||
@ -380,8 +367,9 @@ function! s:path2project_directory(path, ...)
|
|||||||
|
|
||||||
" Search project file.
|
" Search project file.
|
||||||
if directory == ''
|
if directory == ''
|
||||||
for d in ['build.xml', 'prj.el', '.project', 'pom.xml',
|
for d in ['build.xml', 'prj.el', '.project', 'pom.xml', 'package.json',
|
||||||
\ 'Makefile', 'configure', 'Rakefile', 'NAnt.build', 'tags', 'gtags']
|
\ 'Makefile', 'configure', 'Rakefile', 'NAnt.build',
|
||||||
|
\ 'P4CONFIG', 'tags', 'gtags']
|
||||||
let d = findfile(d, s:escape_file_searching(search_directory) . ';')
|
let d = findfile(d, s:escape_file_searching(search_directory) . ';')
|
||||||
if d != ''
|
if d != ''
|
||||||
let directory = fnamemodify(d, ':p:h')
|
let directory = fnamemodify(d, ':p:h')
|
||||||
@ -406,47 +394,6 @@ function! s:path2project_directory(path, ...)
|
|||||||
return s:substitute_path_separator(directory)
|
return s:substitute_path_separator(directory)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Check vimproc.
|
|
||||||
function! s:has_vimproc()
|
|
||||||
if !exists('s:exists_vimproc')
|
|
||||||
try
|
|
||||||
call vimproc#version()
|
|
||||||
let s:exists_vimproc = 1
|
|
||||||
catch
|
|
||||||
let s:exists_vimproc = 0
|
|
||||||
endtry
|
|
||||||
endif
|
|
||||||
return s:exists_vimproc
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:system(str, ...)
|
|
||||||
let command = a:str
|
|
||||||
let input = a:0 >= 1 ? a:1 : ''
|
|
||||||
let command = s:iconv(command, &encoding, 'char')
|
|
||||||
let input = s:iconv(input, &encoding, 'char')
|
|
||||||
|
|
||||||
if a:0 == 0
|
|
||||||
let output = s:has_vimproc() ?
|
|
||||||
\ vimproc#system(command) : system(command)
|
|
||||||
elseif a:0 == 1
|
|
||||||
let output = s:has_vimproc() ?
|
|
||||||
\ vimproc#system(command, input) : system(command, input)
|
|
||||||
else
|
|
||||||
" ignores 3rd argument unless you have vimproc.
|
|
||||||
let output = s:has_vimproc() ?
|
|
||||||
\ vimproc#system(command, input, a:2) : system(command, input)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let output = s:iconv(output, 'char', &encoding)
|
|
||||||
|
|
||||||
return output
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:get_last_status()
|
|
||||||
return s:has_vimproc() ?
|
|
||||||
\ vimproc#get_last_status() : v:shell_error
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
|
154
autoload/vital/_neosnippet/Process.vim
Normal file
154
autoload/vital/_neosnippet/Process.vim
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
" TODO: move all comments to doc file.
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" FIXME: This module name should be Vital.System ?
|
||||||
|
" But the name has been already taken.
|
||||||
|
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
|
||||||
|
" FIXME: Unfortunately, can't use s:_vital_loaded() for this purpose.
|
||||||
|
" Because these variables are used when this script file is loaded.
|
||||||
|
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95')
|
||||||
|
let s:is_unix = has('unix')
|
||||||
|
|
||||||
|
|
||||||
|
" Execute program in the background from Vim.
|
||||||
|
" Return an empty string always.
|
||||||
|
"
|
||||||
|
" If a:expr is a List, shellescape() each argument.
|
||||||
|
" If a:expr is a String, the arguments are passed as-is.
|
||||||
|
"
|
||||||
|
" Windows:
|
||||||
|
" Using :!start , execute program without via cmd.exe.
|
||||||
|
" Spawning 'expr' with 'noshellslash'
|
||||||
|
" keep special characters from unwanted expansion.
|
||||||
|
" (see :help shellescape())
|
||||||
|
"
|
||||||
|
" Unix:
|
||||||
|
" using :! , execute program in the background by shell.
|
||||||
|
function! s:spawn(expr, ...)
|
||||||
|
if s:is_windows
|
||||||
|
let shellslash = &l:shellslash
|
||||||
|
setlocal noshellslash
|
||||||
|
endif
|
||||||
|
try
|
||||||
|
if type(a:expr) is type([])
|
||||||
|
let special = 1
|
||||||
|
let cmdline = join(map(a:expr, 'shellescape(v:val, special)'), ' ')
|
||||||
|
elseif type(a:expr) is type("")
|
||||||
|
let cmdline = a:expr
|
||||||
|
if a:0 && a:1
|
||||||
|
" for :! command
|
||||||
|
let cmdline = substitute(cmdline, '\([!%#]\|<[^<>]\+>\)', '\\\1', 'g')
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
throw 'Process.spawn(): invalid argument (value type:'.type(a:expr).')'
|
||||||
|
endif
|
||||||
|
if s:is_windows
|
||||||
|
silent execute '!start' cmdline
|
||||||
|
else
|
||||||
|
silent execute '!' cmdline '&'
|
||||||
|
endif
|
||||||
|
finally
|
||||||
|
if s:is_windows
|
||||||
|
let &l:shellslash = shellslash
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" iconv() wrapper for safety.
|
||||||
|
function! s:iconv(expr, from, to)
|
||||||
|
if a:from == '' || a:to == '' || a:from ==? a:to
|
||||||
|
return a:expr
|
||||||
|
endif
|
||||||
|
let result = iconv(a:expr, a:from, a:to)
|
||||||
|
return result != '' ? result : a:expr
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Check vimproc.
|
||||||
|
function! s:has_vimproc()
|
||||||
|
if !exists('s:exists_vimproc')
|
||||||
|
try
|
||||||
|
call vimproc#version()
|
||||||
|
let s:exists_vimproc = 1
|
||||||
|
catch
|
||||||
|
let s:exists_vimproc = 0
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
return s:exists_vimproc
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" * {command} [, {input} [, {timeout}]]
|
||||||
|
" * {command} [, {dict}]
|
||||||
|
" {dict} = {
|
||||||
|
" use_vimproc: bool,
|
||||||
|
" input: string,
|
||||||
|
" timeout: bool,
|
||||||
|
" }
|
||||||
|
function! s:system(str, ...)
|
||||||
|
if type(a:str) is type([])
|
||||||
|
let command = join(map(copy(a:str), 's:shellescape(v:val)'), ' ')
|
||||||
|
elseif type(a:str) is type("")
|
||||||
|
let command = a:str
|
||||||
|
else
|
||||||
|
throw 'Process.system(): invalid argument (value type:'.type(a:str).')'
|
||||||
|
endif
|
||||||
|
let command = s:iconv(command, &encoding, 'char')
|
||||||
|
let input = ''
|
||||||
|
let use_vimproc = s:has_vimproc()
|
||||||
|
let args = [command]
|
||||||
|
if a:0 ==# 1
|
||||||
|
if type(a:1) is type({})
|
||||||
|
if has_key(a:1, 'use_vimproc')
|
||||||
|
let use_vimproc = a:1.use_vimproc
|
||||||
|
endif
|
||||||
|
if has_key(a:1, 'input')
|
||||||
|
let args += [s:iconv(a:1.input, &encoding, 'char')]
|
||||||
|
endif
|
||||||
|
if use_vimproc && has_key(a:1, 'timeout')
|
||||||
|
" ignores timeout unless you have vimproc.
|
||||||
|
let args += [a:1.timeout]
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
elseif a:0 >= 2
|
||||||
|
let [input; rest] = a:000
|
||||||
|
let input = s:iconv(a:1, &encoding, 'char')
|
||||||
|
let args += [input] + rest
|
||||||
|
endif
|
||||||
|
|
||||||
|
if use_vimproc
|
||||||
|
" vimproc's parser seems to treat # as a comment
|
||||||
|
let args[0] = escape(args[0], '#')
|
||||||
|
let funcname = 'vimproc#system'
|
||||||
|
else
|
||||||
|
let funcname = 'system'
|
||||||
|
endif
|
||||||
|
let output = call(funcname, args)
|
||||||
|
let output = s:iconv(output, 'char', &encoding)
|
||||||
|
|
||||||
|
return output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_last_status()
|
||||||
|
return s:has_vimproc() ?
|
||||||
|
\ vimproc#get_last_status() : v:shell_error
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if s:is_windows
|
||||||
|
function! s:shellescape(command)
|
||||||
|
return substitute(a:command, '[&()[\]{}^=;!''+,`~]', '^\0', 'g')
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:shellescape(...)
|
||||||
|
return call('shellescape', a:000)
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
||||||
|
|
||||||
|
" vim:set et ts=2 sts=2 sw=2 tw=0:
|
@ -1,3 +1,6 @@
|
|||||||
9bfba96
|
neosnippet
|
||||||
|
450727f
|
||||||
|
|
||||||
|
Prelude
|
||||||
Data.List
|
Data.List
|
||||||
|
Process
|
||||||
|
Loading…
Reference in New Issue
Block a user