mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 08:00:05 +08:00
Remove func
This commit is contained in:
parent
3ea4db4768
commit
651aeb6dd5
@ -7,6 +7,8 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
let s:SYSTEM = SpaceVim#api#import('system')
|
||||||
" Default options {{{
|
" Default options {{{
|
||||||
function! SpaceVim#default#options() abort
|
function! SpaceVim#default#options() abort
|
||||||
" basic vim settiing
|
" basic vim settiing
|
||||||
@ -18,10 +20,10 @@ function! SpaceVim#default#options() abort
|
|||||||
set guioptions-=b " Hide bottom scrollbar
|
set guioptions-=b " Hide bottom scrollbar
|
||||||
set showtabline=0 " Hide tabline
|
set showtabline=0 " Hide tabline
|
||||||
set guioptions-=e " Hide tab
|
set guioptions-=e " Hide tab
|
||||||
if WINDOWS()
|
if s:SYSTEM.isWindows
|
||||||
" please install the font in 'Dotfiles\font'
|
" please install the font in 'Dotfiles\font'
|
||||||
set guifont=DejaVu_Sans_Mono_for_Powerline:h11:cANSI:qDRAFT
|
set guifont=DejaVu_Sans_Mono_for_Powerline:h11:cANSI:qDRAFT
|
||||||
elseif OSX()
|
elseif s:SYSTEM.isOSX
|
||||||
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11
|
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11
|
||||||
else
|
else
|
||||||
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11
|
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
" URL: https://spacevim.org
|
" URL: https://spacevim.org
|
||||||
" License: GPLv3
|
" License: GPLv3
|
||||||
"=============================================================================
|
"=============================================================================
|
||||||
|
|
||||||
|
let s:SYSTEM = SpaceVim#api#import('system')
|
||||||
|
|
||||||
function! SpaceVim#health#python#check() abort
|
function! SpaceVim#health#python#check() abort
|
||||||
let result = ['SpaceVim python support check report:']
|
let result = ['SpaceVim python support check report:']
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
@ -25,7 +28,7 @@ function! SpaceVim#health#python#check() abort
|
|||||||
if has('python3')
|
if has('python3')
|
||||||
call add(result, ' SUCCEED!')
|
call add(result, ' SUCCEED!')
|
||||||
else
|
else
|
||||||
if !WINDOWS()
|
if !s:SYSTEM.isWindows
|
||||||
call add(result, ' Failed : to support +python3, Please install vim-gik, or build from sources.')
|
call add(result, ' Failed : to support +python3, Please install vim-gik, or build from sources.')
|
||||||
else
|
else
|
||||||
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')
|
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')
|
||||||
@ -36,7 +39,7 @@ function! SpaceVim#health#python#check() abort
|
|||||||
if has('python')
|
if has('python')
|
||||||
call add(result, ' SUCCEED!')
|
call add(result, ' SUCCEED!')
|
||||||
else
|
else
|
||||||
if !WINDOWS()
|
if !s:SYSTEM.isWindows
|
||||||
call add(result, ' Failed : to support +python, Please install vim-gik, or build from sources.')
|
call add(result, ' Failed : to support +python, Please install vim-gik, or build from sources.')
|
||||||
else
|
else
|
||||||
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')
|
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')
|
||||||
|
@ -1,295 +1,296 @@
|
|||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
let s:SYSTEM = SpaceVim#api#import('system')
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
let g:unite_source_menu_menus =
|
let g:unite_source_menu_menus =
|
||||||
\ get(g:,'unite_source_menu_menus',{})
|
\ get(g:,'unite_source_menu_menus',{})
|
||||||
let g:unite_source_menu_menus.CustomKeyMaps = {'description':
|
let g:unite_source_menu_menus.CustomKeyMaps = {'description':
|
||||||
\ 'Custom mapped keyboard shortcuts [unite]<SPACE>'}
|
\ 'Custom mapped keyboard shortcuts [unite]<SPACE>'}
|
||||||
let g:unite_source_menu_menus.CustomKeyMaps.command_candidates =
|
let g:unite_source_menu_menus.CustomKeyMaps.command_candidates =
|
||||||
\ get(g:unite_source_menu_menus.CustomKeyMaps,'command_candidates', [])
|
\ get(g:unite_source_menu_menus.CustomKeyMaps,'command_candidates', [])
|
||||||
let g:unite_source_menu_menus.MyStarredrepos = {'description':
|
let g:unite_source_menu_menus.MyStarredrepos = {'description':
|
||||||
\ 'All github repos starred by me <leader>ls'}
|
\ 'All github repos starred by me <leader>ls'}
|
||||||
let g:unite_source_menu_menus.MyStarredrepos.command_candidates =
|
let g:unite_source_menu_menus.MyStarredrepos.command_candidates =
|
||||||
\ get(g:unite_source_menu_menus.MyStarredrepos,'command_candidates', [])
|
\ get(g:unite_source_menu_menus.MyStarredrepos,'command_candidates', [])
|
||||||
let g:unite_source_menu_menus.MpvPlayer = {'description':
|
let g:unite_source_menu_menus.MpvPlayer = {'description':
|
||||||
\ 'Musics list <leader>lm'}
|
\ 'Musics list <leader>lm'}
|
||||||
let g:unite_source_menu_menus.MpvPlayer.command_candidates =
|
let g:unite_source_menu_menus.MpvPlayer.command_candidates =
|
||||||
\ get(g:unite_source_menu_menus.MpvPlayer,'command_candidates', [])
|
\ get(g:unite_source_menu_menus.MpvPlayer,'command_candidates', [])
|
||||||
fu! zvim#util#defineMap(type,key,value,desc,...) abort
|
fu! zvim#util#defineMap(type,key,value,desc,...) abort
|
||||||
exec a:type . ' ' . a:key . ' ' . a:value
|
exec a:type . ' ' . a:key . ' ' . a:value
|
||||||
let description = '➤ '
|
let description = '➤ '
|
||||||
\. a:desc
|
\. a:desc
|
||||||
\. repeat(' ', 80 - len(a:desc) - len(a:key))
|
\. repeat(' ', 80 - len(a:desc) - len(a:key))
|
||||||
\. a:key
|
\. a:key
|
||||||
let cmd = len(a:000) > 0 ? a:000[0] : a:value
|
let cmd = len(a:000) > 0 ? a:000[0] : a:value
|
||||||
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
|
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
|
||||||
|
|
||||||
endf
|
endf
|
||||||
fu! zvim#util#source_rc(file) abort
|
fu! zvim#util#source_rc(file) abort
|
||||||
if filereadable(g:_spacevim_root_dir. '/' . a:file)
|
if filereadable(g:_spacevim_root_dir. '/' . a:file)
|
||||||
execute 'source ' . g:_spacevim_root_dir . '/' . a:file
|
execute 'source ' . g:_spacevim_root_dir . '/' . a:file
|
||||||
endif
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! zvim#util#SmartClose() abort
|
fu! zvim#util#SmartClose() abort
|
||||||
let ignorewin = get(g:,'spacevim_smartcloseignorewin',[])
|
let ignorewin = get(g:,'spacevim_smartcloseignorewin',[])
|
||||||
let ignoreft = get(g:, 'spacevim_smartcloseignoreft',[])
|
let ignoreft = get(g:, 'spacevim_smartcloseignoreft',[])
|
||||||
let win_count = winnr('$')
|
let win_count = winnr('$')
|
||||||
let num = win_count
|
let num = win_count
|
||||||
for i in range(1,win_count)
|
for i in range(1,win_count)
|
||||||
if index(ignorewin , bufname(winbufnr(i))) != -1 || index(ignoreft, getbufvar(bufname(winbufnr(i)),'&filetype')) != -1
|
if index(ignorewin , bufname(winbufnr(i))) != -1 || index(ignoreft, getbufvar(bufname(winbufnr(i)),'&filetype')) != -1
|
||||||
let num = num - 1
|
let num = num - 1
|
||||||
endif
|
|
||||||
if getbufvar(winbufnr(i),'&buftype') ==# 'quickfix'
|
|
||||||
let num = num - 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if num == 1
|
|
||||||
else
|
|
||||||
quit
|
|
||||||
endif
|
endif
|
||||||
|
if getbufvar(winbufnr(i),'&buftype') ==# 'quickfix'
|
||||||
|
let num = num - 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
if num == 1
|
||||||
|
else
|
||||||
|
quit
|
||||||
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:findFileInParent(what, where) abort " {{{2
|
fu! s:findFileInParent(what, where) abort " {{{2
|
||||||
let old_suffixesadd = &suffixesadd
|
let old_suffixesadd = &suffixesadd
|
||||||
let &suffixesadd = ''
|
let &suffixesadd = ''
|
||||||
let file = findfile(a:what, escape(a:where, ' ') . ';')
|
let file = findfile(a:what, escape(a:where, ' ') . ';')
|
||||||
let &suffixesadd = old_suffixesadd
|
let &suffixesadd = old_suffixesadd
|
||||||
return file
|
return file
|
||||||
endf " }}}2
|
endf " }}}2
|
||||||
fu! s:findDirInParent(what, where) abort " {{{2
|
fu! s:findDirInParent(what, where) abort " {{{2
|
||||||
let old_suffixesadd = &suffixesadd
|
let old_suffixesadd = &suffixesadd
|
||||||
let &suffixesadd = ''
|
let &suffixesadd = ''
|
||||||
let dir = finddir(a:what, escape(a:where, ' ') . ';')
|
let dir = finddir(a:what, escape(a:where, ' ') . ';')
|
||||||
let &suffixesadd = old_suffixesadd
|
let &suffixesadd = old_suffixesadd
|
||||||
return dir
|
return dir
|
||||||
endf " }}}2
|
endf " }}}2
|
||||||
fu! zvim#util#CopyToClipboard(...) abort
|
fu! zvim#util#CopyToClipboard(...) abort
|
||||||
if a:0
|
if a:0
|
||||||
if executable('git')
|
if executable('git')
|
||||||
let repo_home = fnamemodify(s:findDirInParent('.git', expand('%:p')), ':p:h:h')
|
let repo_home = fnamemodify(s:findDirInParent('.git', expand('%:p')), ':p:h:h')
|
||||||
if repo_home !=# '' || !isdirectory(repo_home)
|
if repo_home !=# '' || !isdirectory(repo_home)
|
||||||
let branch = split(systemlist('git -C '. repo_home. ' branch -a |grep "*"')[0],' ')[1]
|
let branch = split(systemlist('git -C '. repo_home. ' branch -a |grep "*"')[0],' ')[1]
|
||||||
let remotes = filter(systemlist('git -C '. repo_home. ' remote -v'),"match(v:val,'^origin') >= 0 && match(v:val,'fetch') > 0")
|
let remotes = filter(systemlist('git -C '. repo_home. ' remote -v'),"match(v:val,'^origin') >= 0 && match(v:val,'fetch') > 0")
|
||||||
if len(remotes) > 0
|
if len(remotes) > 0
|
||||||
let remote = remotes[0]
|
let remote = remotes[0]
|
||||||
if stridx(remote, '@') > -1
|
if stridx(remote, '@') > -1
|
||||||
let repo_url = 'https://github.com/'. split(split(remote,' ')[0],':')[1]
|
let repo_url = 'https://github.com/'. split(split(remote,' ')[0],':')[1]
|
||||||
let repo_url = strpart(repo_url, 0, len(repo_url) - 4)
|
let repo_url = strpart(repo_url, 0, len(repo_url) - 4)
|
||||||
else
|
else
|
||||||
let repo_url = split(remote,' ')[0]
|
let repo_url = split(remote,' ')[0]
|
||||||
let repo_url = strpart(repo_url, stridx(repo_url, 'http'),len(repo_url) - 4 - stridx(repo_url, 'http'))
|
let repo_url = strpart(repo_url, stridx(repo_url, 'http'),len(repo_url) - 4 - stridx(repo_url, 'http'))
|
||||||
endif
|
endif
|
||||||
let f_url =repo_url. '/blob/'. branch. '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
|
let f_url =repo_url. '/blob/'. branch. '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
|
||||||
if WINDOWS()
|
if s:SYSTEM.isWindows
|
||||||
let f_url = substitute(f_url, '\', '/', 'g')
|
let f_url = substitute(f_url, '\', '/', 'g')
|
||||||
endif
|
endif
|
||||||
if a:1 == 2
|
if a:1 == 2
|
||||||
let current_line = line('.')
|
let current_line = line('.')
|
||||||
let f_url .= '#L' . current_line
|
let f_url .= '#L' . current_line
|
||||||
elseif a:1 == 3
|
elseif a:1 == 3
|
||||||
let f_url .= '#L' . getpos("'<")[1] . '-L' . getpos("'>")[1]
|
let f_url .= '#L' . getpos("'<")[1] . '-L' . getpos("'>")[1]
|
||||||
endif
|
endif
|
||||||
try
|
try
|
||||||
let @+=f_url
|
let @+=f_url
|
||||||
echo 'Copied to clipboard'
|
echo 'Copied to clipboard'
|
||||||
catch /^Vim\%((\a\+)\)\=:E354/
|
catch /^Vim\%((\a\+)\)\=:E354/
|
||||||
if has('nvim')
|
|
||||||
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
|
|
||||||
else
|
|
||||||
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
|
|
||||||
endif
|
|
||||||
endtry
|
|
||||||
else
|
|
||||||
echohl WarningMsg | echom 'This git repo has no remote host' | echohl None
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
echohl WarningMsg | echom 'This file is not in a git repo' | echohl None
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
echohl WarningMsg | echom 'You need install git!' | echohl None
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
try
|
|
||||||
let @+=expand('%:p')
|
|
||||||
echo 'Copied to clipboard ' . @+
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E354/
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
|
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
|
||||||
else
|
else
|
||||||
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
|
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
|
||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
|
else
|
||||||
|
echohl WarningMsg | echom 'This git repo has no remote host' | echohl None
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
echohl WarningMsg | echom 'This file is not in a git repo' | echohl None
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
echohl WarningMsg | echom 'You need install git!' | echohl None
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
try
|
||||||
|
let @+=expand('%:p')
|
||||||
|
echo 'Copied to clipboard ' . @+
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E354/
|
||||||
|
if has('nvim')
|
||||||
|
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
|
||||||
|
else
|
||||||
|
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! zvim#util#check_if_expand_tab() abort
|
fu! zvim#util#check_if_expand_tab() abort
|
||||||
let has_noexpandtab = search('^\t','wn')
|
let has_noexpandtab = search('^\t','wn')
|
||||||
let has_expandtab = search('^ ','wn')
|
let has_expandtab = search('^ ','wn')
|
||||||
if has_noexpandtab && has_expandtab
|
if has_noexpandtab && has_expandtab
|
||||||
let idx = inputlist ( ['ERROR: current file exists both expand and noexpand TAB, python can only use one of these two mode in one file.\nSelect Tab Expand Type:',
|
let idx = inputlist ( ['ERROR: current file exists both expand and noexpand TAB, python can only use one of these two mode in one file.\nSelect Tab Expand Type:',
|
||||||
\ '1. expand (tab=space, recommended)',
|
\ '1. expand (tab=space, recommended)',
|
||||||
\ '2. noexpand (tab=\t, currently have risk)',
|
\ '2. noexpand (tab=\t, currently have risk)',
|
||||||
\ '3. do nothing (I will handle it by myself)'])
|
\ '3. do nothing (I will handle it by myself)'])
|
||||||
let tab_space = printf('%*s',&tabstop,'')
|
let tab_space = printf('%*s',&tabstop,'')
|
||||||
if idx == 1
|
if idx == 1
|
||||||
let has_noexpandtab = 0
|
let has_noexpandtab = 0
|
||||||
let has_expandtab = 1
|
let has_expandtab = 1
|
||||||
silent exec '%s/\t/' . tab_space . '/g'
|
silent exec '%s/\t/' . tab_space . '/g'
|
||||||
elseif idx == 2
|
elseif idx == 2
|
||||||
let has_noexpandtab = 1
|
let has_noexpandtab = 1
|
||||||
let has_expandtab = 0
|
let has_expandtab = 0
|
||||||
silent exec '%s/' . tab_space . '/\t/g'
|
silent exec '%s/' . tab_space . '/\t/g'
|
||||||
else
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if has_noexpandtab == 1 && has_expandtab == 0
|
|
||||||
echomsg 'substitute space to TAB...'
|
|
||||||
set noexpandtab
|
|
||||||
echomsg 'done!'
|
|
||||||
elseif has_noexpandtab == 0 && has_expandtab == 1
|
|
||||||
echomsg 'substitute TAB to space...'
|
|
||||||
set expandtab
|
|
||||||
echomsg 'done!'
|
|
||||||
else
|
else
|
||||||
" it may be a new file
|
return
|
||||||
" we use original vim setting
|
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
if has_noexpandtab == 1 && has_expandtab == 0
|
||||||
|
echomsg 'substitute space to TAB...'
|
||||||
|
set noexpandtab
|
||||||
|
echomsg 'done!'
|
||||||
|
elseif has_noexpandtab == 0 && has_expandtab == 1
|
||||||
|
echomsg 'substitute TAB to space...'
|
||||||
|
set expandtab
|
||||||
|
echomsg 'done!'
|
||||||
|
else
|
||||||
|
" it may be a new file
|
||||||
|
" we use original vim setting
|
||||||
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! zvim#util#BufferEmpty() abort
|
function! zvim#util#BufferEmpty() abort
|
||||||
let l:current = bufnr('%')
|
let l:current = bufnr('%')
|
||||||
if ! getbufvar(l:current, '&modified')
|
if ! getbufvar(l:current, '&modified')
|
||||||
enew
|
enew
|
||||||
silent! execute 'bdelete '.l:current
|
silent! execute 'bdelete '.l:current
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#loadMusics() abort
|
function! zvim#util#loadMusics() abort
|
||||||
let musics = SpaceVim#util#globpath('~/Musics', '*.mp3')
|
let musics = SpaceVim#util#globpath('~/Musics', '*.mp3')
|
||||||
let g:unite_source_menu_menus.MpvPlayer.command_candidates = []
|
let g:unite_source_menu_menus.MpvPlayer.command_candidates = []
|
||||||
for m in musics
|
for m in musics
|
||||||
call add(g:unite_source_menu_menus.MpvPlayer.command_candidates,
|
call add(g:unite_source_menu_menus.MpvPlayer.command_candidates,
|
||||||
\ [fnamemodify(m, ':t'),
|
\ [fnamemodify(m, ':t'),
|
||||||
\ "call zvim#mpv#play('" . m . "')"])
|
\ "call zvim#mpv#play('" . m . "')"])
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#listDirs(dir) abort
|
function! zvim#util#listDirs(dir) abort
|
||||||
let dir = fnamemodify(a:dir, ':p')
|
let dir = fnamemodify(a:dir, ':p')
|
||||||
if isdirectory(dir)
|
if isdirectory(dir)
|
||||||
let cmd = printf('ls -F %s | grep /$', dir)
|
let cmd = printf('ls -F %s | grep /$', dir)
|
||||||
return map(systemlist(cmd), 'v:val[:-2]')
|
return map(systemlist(cmd), 'v:val[:-2]')
|
||||||
endif
|
endif
|
||||||
return []
|
return []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#OpenVimfiler() abort
|
function! zvim#util#OpenVimfiler() abort
|
||||||
if bufnr('vimfiler') == -1
|
if bufnr('vimfiler') == -1
|
||||||
silent VimFiler
|
silent VimFiler
|
||||||
if exists(':AirlineRefresh')
|
if exists(':AirlineRefresh')
|
||||||
AirlineRefresh
|
AirlineRefresh
|
||||||
endif
|
|
||||||
wincmd p
|
|
||||||
if &filetype !=# 'startify'
|
|
||||||
IndentLinesToggle
|
|
||||||
IndentLinesToggle
|
|
||||||
endif
|
|
||||||
wincmd p
|
|
||||||
else
|
|
||||||
silent VimFiler
|
|
||||||
doautocmd WinEnter
|
|
||||||
if exists(':AirlineRefresh')
|
|
||||||
AirlineRefresh
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
wincmd p
|
||||||
|
if &filetype !=# 'startify'
|
||||||
|
IndentLinesToggle
|
||||||
|
IndentLinesToggle
|
||||||
|
endif
|
||||||
|
wincmd p
|
||||||
|
else
|
||||||
|
silent VimFiler
|
||||||
|
doautocmd WinEnter
|
||||||
|
if exists(':AirlineRefresh')
|
||||||
|
AirlineRefresh
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:plugins_argv = ['-update', '-openurl']
|
let s:plugins_argv = ['-update', '-openurl']
|
||||||
|
|
||||||
function! zvim#util#complete_plugs(ArgLead, CmdLine, CursorPos) abort
|
function! zvim#util#complete_plugs(ArgLead, CmdLine, CursorPos) abort
|
||||||
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
|
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
if a:CmdLine =~# 'Plugin\s*$' || a:ArgLead =~# '^-[a-zA-Z]*'
|
if a:CmdLine =~# 'Plugin\s*$' || a:ArgLead =~# '^-[a-zA-Z]*'
|
||||||
return join(s:plugins_argv, "\n")
|
return join(s:plugins_argv, "\n")
|
||||||
endif
|
endif
|
||||||
return join(plugins#list(), "\n")
|
return join(plugins#list(), "\n")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#Plugin(...) abort
|
function! zvim#util#Plugin(...) abort
|
||||||
let adds = []
|
let adds = []
|
||||||
let updates = []
|
let updates = []
|
||||||
let flag = 0
|
let flag = 0
|
||||||
for a in a:000
|
for a in a:000
|
||||||
if flag == 1
|
if flag == 1
|
||||||
call add(adds, a)
|
call add(adds, a)
|
||||||
elseif flag == 2
|
elseif flag == 2
|
||||||
call add(updates, a)
|
call add(updates, a)
|
||||||
endif
|
endif
|
||||||
if a ==# '-update'
|
if a ==# '-update'
|
||||||
let flag = 1
|
let flag = 1
|
||||||
elseif a ==# '-openurl'
|
elseif a ==# '-openurl'
|
||||||
let flag = 2
|
let flag = 2
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
echo string(adds) . "\n" . string(updates)
|
echo string(adds) . "\n" . string(updates)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#complete_project(ArgLead, CmdLine, CursorPos) abort
|
function! zvim#util#complete_project(ArgLead, CmdLine, CursorPos) abort
|
||||||
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
|
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
let dir = get(g:,'spacevim_src_root', '~')
|
let dir = get(g:,'spacevim_src_root', '~')
|
||||||
"return globpath(dir, '*')
|
"return globpath(dir, '*')
|
||||||
let result = split(globpath(dir, '*'), "\n")
|
let result = split(globpath(dir, '*'), "\n")
|
||||||
let ps = []
|
let ps = []
|
||||||
for p in result
|
for p in result
|
||||||
if isdirectory(p) && isdirectory(p. '\' . '.git')
|
if isdirectory(p) && isdirectory(p. '\' . '.git')
|
||||||
call add(ps, fnamemodify(p, ':t'))
|
call add(ps, fnamemodify(p, ':t'))
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return join(ps, "\n")
|
return join(ps, "\n")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#OpenProject(p) abort
|
function! zvim#util#OpenProject(p) abort
|
||||||
let dir = get(g:, 'spacevim_src_root', '~') . a:p
|
let dir = get(g:, 'spacevim_src_root', '~') . a:p
|
||||||
exe 'CtrlP '. dir
|
exe 'CtrlP '. dir
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#util#UpdateHosts(...) abort
|
function! zvim#util#UpdateHosts(...) abort
|
||||||
if len(a:000) == 0
|
if len(a:000) == 0
|
||||||
let url = get(g:,'spacevim_hosts_url', '')
|
let url = get(g:,'spacevim_hosts_url', '')
|
||||||
else
|
else
|
||||||
let url = a:1
|
let url = a:1
|
||||||
endif
|
endif
|
||||||
let hosts = systemlist('curl -s ' . url)
|
let hosts = systemlist('curl -s ' . url)
|
||||||
if WINDOWS()
|
if s:SYSTEM.isWindows
|
||||||
let local_hosts = $SystemRoot . expand('\System32\drivers\etc\hosts')
|
let local_hosts = $SystemRoot . expand('\System32\drivers\etc\hosts')
|
||||||
else
|
else
|
||||||
let local_hosts = '/etc/hosts'
|
let local_hosts = '/etc/hosts'
|
||||||
endif
|
endif
|
||||||
if writefile(hosts, local_hosts, 'a') == -1
|
if writefile(hosts, local_hosts, 'a') == -1
|
||||||
echo 'failed!'
|
echo 'failed!'
|
||||||
else
|
else
|
||||||
echo 'successfully!'
|
echo 'successfully!'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
fu! zvim#util#Generate_ignore(ignore,tool, ...) abort
|
fu! zvim#util#Generate_ignore(ignore,tool, ...) abort
|
||||||
let ignore = []
|
let ignore = []
|
||||||
if a:tool ==# 'ag'
|
if a:tool ==# 'ag'
|
||||||
for ig in split(a:ignore,',')
|
for ig in split(a:ignore,',')
|
||||||
call add(ignore, '--ignore')
|
call add(ignore, '--ignore')
|
||||||
call add(ignore, "'" . ig . "'")
|
call add(ignore, "'" . ig . "'")
|
||||||
endfor
|
endfor
|
||||||
elseif a:tool ==# 'rg'
|
elseif a:tool ==# 'rg'
|
||||||
for ig in split(a:ignore,',')
|
for ig in split(a:ignore,',')
|
||||||
call add(ignore, '-g')
|
call add(ignore, '-g')
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
call add(ignore, "'!" . ig . "'")
|
call add(ignore, "'!" . ig . "'")
|
||||||
else
|
else
|
||||||
call add(ignore, '!' . ig)
|
call add(ignore, '!' . ig)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
return ignore
|
return ignore
|
||||||
endf
|
endf
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
@ -14,6 +14,8 @@ if has('vim_starting')
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let s:SYSTEM = SpaceVim#api#import('system')
|
||||||
|
|
||||||
" Fsep && Psep
|
" Fsep && Psep
|
||||||
if has('win16') || has('win32') || has('win64')
|
if has('win16') || has('win32') || has('win64')
|
||||||
let s:Psep = ';'
|
let s:Psep = ';'
|
||||||
@ -24,9 +26,9 @@ else
|
|||||||
endif
|
endif
|
||||||
"Use English for anything in vim
|
"Use English for anything in vim
|
||||||
try
|
try
|
||||||
if WINDOWS()
|
if s:SYSTEM.isWindows
|
||||||
silent exec 'lan mes en_US.UTF-8'
|
silent exec 'lan mes en_US.UTF-8'
|
||||||
elseif OSX()
|
elseif s:SYSTEM.isOSX
|
||||||
silent exec 'language en_US'
|
silent exec 'language en_US'
|
||||||
else
|
else
|
||||||
let s:uname = system('uname -s')
|
let s:uname = system('uname -s')
|
||||||
@ -46,7 +48,7 @@ catch /^Vim\%((\a\+)\)\=:E197/
|
|||||||
endtry
|
endtry
|
||||||
|
|
||||||
" try to set encoding to utf-8
|
" try to set encoding to utf-8
|
||||||
if WINDOWS()
|
if s:SYSTEM.isWindows
|
||||||
" Be nice and check for multi_byte even if the config requires
|
" Be nice and check for multi_byte even if the config requires
|
||||||
" multi_byte support most of the time
|
" multi_byte support most of the time
|
||||||
if has('multi_byte')
|
if has('multi_byte')
|
||||||
|
Loading…
Reference in New Issue
Block a user