mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -1,70 +1,82 @@
|
||||
" PathSep returns the appropriate OS specific path separator.
|
||||
function! go#util#PathSep()
|
||||
if go#util#IsWin()
|
||||
return '\'
|
||||
endif
|
||||
return '/'
|
||||
if go#util#IsWin()
|
||||
return '\'
|
||||
endif
|
||||
return '/'
|
||||
endfunction
|
||||
|
||||
" PathListSep returns the appropriate OS specific path list separator.
|
||||
function! go#util#PathListSep()
|
||||
if go#util#IsWin()
|
||||
return ";"
|
||||
endif
|
||||
return ":"
|
||||
if go#util#IsWin()
|
||||
return ";"
|
||||
endif
|
||||
return ":"
|
||||
endfunction
|
||||
|
||||
" LineEnding returns the correct line ending, based on the current fileformat
|
||||
function! go#util#LineEnding()
|
||||
if &fileformat == 'dos'
|
||||
return "\r\n"
|
||||
elseif &fileformat == 'mac'
|
||||
return "\r"
|
||||
endif
|
||||
if &fileformat == 'dos'
|
||||
return "\r\n"
|
||||
elseif &fileformat == 'mac'
|
||||
return "\r"
|
||||
endif
|
||||
|
||||
return "\n"
|
||||
return "\n"
|
||||
endfunction
|
||||
|
||||
" IsWin returns 1 if current OS is Windows or 0 otherwise
|
||||
function! go#util#IsWin()
|
||||
let win = ['win16', 'win32', 'win64', 'win95']
|
||||
for w in win
|
||||
if (has(w))
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
let win = ['win16', 'win32', 'win64', 'win95']
|
||||
for w in win
|
||||
if (has(w))
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" StripPath strips the path's last character if it's a path separator.
|
||||
" example: '/foo/bar/' -> '/foo/bar'
|
||||
function! go#util#StripPathSep(path)
|
||||
let last_char = strlen(a:path) - 1
|
||||
if a:path[last_char] == go#util#PathSep()
|
||||
return strpart(a:path, 0, last_char)
|
||||
endif
|
||||
let last_char = strlen(a:path) - 1
|
||||
if a:path[last_char] == go#util#PathSep()
|
||||
return strpart(a:path, 0, last_char)
|
||||
endif
|
||||
|
||||
return a:path
|
||||
return a:path
|
||||
endfunction
|
||||
|
||||
" Shelljoin returns a shell-safe string representation of arglist. The
|
||||
" {special} argument of shellescape() may optionally be passed.
|
||||
function! go#util#Shelljoin(arglist, ...)
|
||||
if a:0
|
||||
return join(map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')'), ' ')
|
||||
endif
|
||||
try
|
||||
let ssl_save = &shellslash
|
||||
set noshellslash
|
||||
if a:0
|
||||
return join(map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')'), ' ')
|
||||
endif
|
||||
|
||||
return join(map(copy(a:arglist), 'shellescape(v:val)'), ' ')
|
||||
return join(map(copy(a:arglist), 'shellescape(v:val)'), ' ')
|
||||
finally
|
||||
let &shellslash = ssl_save
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Shelljoin returns a shell-safe representation of the items in the given
|
||||
" Shelllist returns a shell-safe representation of the items in the given
|
||||
" arglist. The {special} argument of shellescape() may optionally be passed.
|
||||
function! go#util#Shelllist(arglist, ...)
|
||||
if a:0
|
||||
return map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')')
|
||||
endif
|
||||
return map(copy(a:arglist), 'shellescape(v:val)')
|
||||
try
|
||||
let ssl_save = &shellslash
|
||||
set noshellslash
|
||||
if a:0
|
||||
return map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')')
|
||||
endif
|
||||
return map(copy(a:arglist), 'shellescape(v:val)')
|
||||
finally
|
||||
let &shellslash = ssl_save
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" TODO(arslan): I couldn't parameterize the highlight types. Check if we can
|
||||
|
Reference in New Issue
Block a user