mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 07:09:11 +08:00
Fix lint (#3727)
This commit is contained in:
parent
bf67dcf987
commit
4e4ca32f4a
@ -6,11 +6,26 @@ function install_vim($name)
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.2.0129/gvim_8.2.0129_x86.zip'
|
||||
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim82\vim.exe'
|
||||
}
|
||||
elseif ($ver -eq "8.0.0069")
|
||||
elseif ($ver -eq "8.1.2269")
|
||||
{
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.0.0069/gvim_8.0.0069_x86.zip'
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.1.2269/gvim_8.1.2269_x86.zip'
|
||||
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim81\vim.exe'
|
||||
}
|
||||
elseif ($ver -eq "8.0.1453")
|
||||
{
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.0.1453/gvim_8.0.1453_x86.zip'
|
||||
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim80\vim.exe'
|
||||
}
|
||||
elseif ($ver -eq "8.0.0027")
|
||||
{
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.0.0027/gvim_8.0.0027_x86.zip'
|
||||
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim80\vim.exe'
|
||||
}
|
||||
elseif ($ver -eq "7.4.1689")
|
||||
{
|
||||
$url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v7.4.1689/gvim_7.4.1689_x86.zip'
|
||||
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim74\vim.exe'
|
||||
}
|
||||
$zip1 = $Env:APPVEYOR_BUILD_FOLDER + '\vim.zip'
|
||||
(New-Object Net.WebClient).DownloadFile($url1, $zip1)
|
||||
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
|
||||
@ -63,6 +78,22 @@ function install_nvim($name)
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/nightly/nvim-win64.zip'
|
||||
}
|
||||
elseif ($ver -eq "0.4.3-32")
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/v0.4.3/nvim-win32.zip'
|
||||
}
|
||||
elseif ($ver -eq "0.4.3-64")
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/v0.4.3/nvim-win64.zip'
|
||||
}
|
||||
elseif ($ver -eq "0.4.2-32")
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/v0.4.2/nvim-win32.zip'
|
||||
}
|
||||
elseif ($ver -eq "0.4.2-64")
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/v0.4.2/nvim-win64.zip'
|
||||
}
|
||||
elseif ($ver -eq "0.3.8-32")
|
||||
{
|
||||
$url = 'https://github.com/neovim/neovim/releases/download/v0.3.8/nvim-win32.zip'
|
||||
|
@ -12,7 +12,8 @@ if [ "${LINT#vimlint}" != "$LINT" ]; then
|
||||
git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint
|
||||
git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser
|
||||
elif [ "${LINT#vint}" != "$LINT" ]; then
|
||||
pip install vim-vint pathlib enum34 typing
|
||||
pip install --pre vim-vint pathlib enum34 typing
|
||||
vint --version
|
||||
elif [ "${LINT#vader}" != "$LINT" ]; then
|
||||
if [[ ! -d "$HOME/.cache/vimfiles/repos/github.com/Shougo/dein.vim" ]]; then
|
||||
git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim
|
||||
|
@ -5,16 +5,15 @@ install_vim() {
|
||||
local tmp="$(mktemp -d)"
|
||||
local out="${DEPS}/_vim/$tag"
|
||||
mkdir -p $out
|
||||
local ncpu=$(awk '/^processor/{n+=1}END{print n}' /proc/cpuinfo)
|
||||
git clone --depth 1 --single-branch $ext $URL $tmp
|
||||
cd $tmp
|
||||
./configure --enable-fail-if-missing \
|
||||
./configure \
|
||||
--with-features=huge \
|
||||
--enable-pythoninterp \
|
||||
--enable-python3interp \
|
||||
--enable-luainterp \
|
||||
--prefix=${out}
|
||||
make -j$ncpu
|
||||
make
|
||||
make install
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ elif [ "$LINT" = "file-encoding" ]; then
|
||||
exit 2
|
||||
fi
|
||||
elif [ "$LINT" = "vint" ]; then
|
||||
vint .
|
||||
vint --enable-neovim .
|
||||
elif [ "$LINT" = "vint-errors" ]; then
|
||||
vint --error .
|
||||
vint --enable-neovim --error .
|
||||
elif [ "$LINT" = "vader" ]; then
|
||||
if [ "$VIM_BIN" = "nvim" ]; then
|
||||
export PATH="${DEPS}/_neovim/${VIM_TAG}/bin:${PATH}"
|
||||
|
28
.travis.yml
28
.travis.yml
@ -54,38 +54,38 @@ jobs:
|
||||
include:
|
||||
- env: LINT=jekyll
|
||||
- env: LINT=file-encoding
|
||||
- env: LINT=vimlint-errors VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vimlint VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vint-errors VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vint VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vimlint-errors VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vimlint VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vint-errors VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vint VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=nightly
|
||||
addons: { apt: { packages: [python2.7-dev, lua5.2] } }
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.4.2
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.4.1
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.4.0
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.8
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.7
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.6
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.5
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.4
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.3
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.2
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.1
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.3.0
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.2.2
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=v0.1.7
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v7.4.052 #ubuntu 14.04
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v7.4.052 #Ubuntu 14.04
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v7.4.629 #CentOS 6/7
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v7.4.1689 #ubuntu 16.04
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v8.0.0027
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v8.0.1453 #ubuntu 18.04
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v8.1.0320 #ubuntu 19.04
|
||||
- env: LINT=vader VIM_BIN=vim VIM_TAG=v8.1.2269 #ubuntu 20.04
|
||||
addons: { apt: { packages: [libncurses5-dev, libncursesw5-dev] } }
|
||||
allow_failures:
|
||||
- env: LINT=vimlint VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vint VIM_BIN=nvim VIM_TAG=v0.2.0
|
||||
- env: LINT=vimlint VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vint VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vint-errors VIM_BIN=nvim VIM_TAG=v0.4.3
|
||||
- env: LINT=vader VIM_BIN=nvim VIM_TAG=nightly
|
||||
addons: { apt: { packages: [python2.7-dev, lua5.2] } }
|
||||
|
||||
|
@ -6,6 +6,8 @@ clone_depth: 1
|
||||
environment:
|
||||
matrix:
|
||||
- CONDITION: Neovim latest-32
|
||||
- CONDITION: Neovim 0.4.3-32
|
||||
- CONDITION: Neovim 0.4.2-32
|
||||
- CONDITION: Neovim 0.3.8-32
|
||||
- CONDITION: Neovim 0.3.7-32
|
||||
- CONDITION: Neovim 0.3.5-32
|
||||
@ -15,7 +17,10 @@ environment:
|
||||
- CONDITION: Neovim 0.3.1-32
|
||||
- CONDITION: Neovim 0.3.0-32
|
||||
- CONDITION: Vim latest-32
|
||||
- CONDITION: Vim 8.0.0069
|
||||
- CONDITION: Vim 7.4.1689
|
||||
- CONDITION: Vim 8.0.0027
|
||||
- CONDITION: Vim 8.0.1453
|
||||
- CONDITION: Vim 8.1.2269
|
||||
install:
|
||||
- 'reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:32'
|
||||
- 'reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64'
|
||||
|
@ -218,6 +218,10 @@ let g:spacevim_data_dir
|
||||
\ : expand($HOME. join(['', '.cache', ''],
|
||||
\ SpaceVim#api#import('file').separator))
|
||||
|
||||
if !isdirectory(g:spacevim_data_dir)
|
||||
call mkdir(g:spacevim_data_dir, 'p')
|
||||
endif
|
||||
|
||||
""
|
||||
" @section plugin_bundle_dir, options-plugin_bundle_dir
|
||||
" @parentsection options
|
||||
|
@ -6,51 +6,69 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
let s:json = {}
|
||||
let s:self = {}
|
||||
let s:self._vim = SpaceVim#api#import('vim')
|
||||
let s:self._iconv = SpaceVim#api#import('iconv')
|
||||
|
||||
function! s:self._json_null() abort
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:self._json_true() abort
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:self._json_false() abort
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
if exists('*json_decode')
|
||||
let g:_spacevim_api_json_trus = v:true
|
||||
let g:_spacevim_api_json_trus = v:false
|
||||
let g:_spacevim_api_json_trus = v:null
|
||||
function! s:json_decode(json) abort
|
||||
function! s:self.json_decode(json) abort
|
||||
if a:json ==# ''
|
||||
return []
|
||||
" instead of throw error, if json is empty string, just return an empty
|
||||
" string
|
||||
return ''
|
||||
endif
|
||||
return json_decode(a:json)
|
||||
endfunction
|
||||
else
|
||||
function! s:json_null() abort
|
||||
endfunction
|
||||
|
||||
function! s:json_true() abort
|
||||
function! s:self._fixvar(val) abort
|
||||
if self._vim.is_number(a:val)
|
||||
\ || self._vim.is_string(a:val)
|
||||
\ || empty(a:val)
|
||||
return a:val
|
||||
elseif self._vim.is_list(a:val) && len(a:val) ==# 1
|
||||
if string(a:val[0]) == string(self._json_true)
|
||||
return get(v:, 'true', 1)
|
||||
elseif string(a:val[0]) ==# string(self._json_false)
|
||||
return get(v:, 'false', 0)
|
||||
elseif string(a:val[0]) ==# string(self._json_null)
|
||||
return get(v:, 'null', 0)
|
||||
else
|
||||
return a:val
|
||||
endif
|
||||
elseif self._vim.is_list(a:val) && len(a:val) > 1
|
||||
return map(a:val, 'self._fixvar(v:val)')
|
||||
elseif self._vim.is_dict(a:val)
|
||||
return map(a:val, 'self._fixvar(v:val)')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:json_false() abort
|
||||
endfunction
|
||||
|
||||
let g:_spacevim_api_json_trus = [function('s:json_true')]
|
||||
let g:_spacevim_api_json_falss = [function('s:json_false')]
|
||||
let g:_spacevim_api_json_nuls = [function('s:json_null')]
|
||||
" @vimlint(EVL102, 1, l:true)
|
||||
" @vimlint(EVL102, 1, l:false)
|
||||
" @vimlint(EVL102, 1, l:null)
|
||||
function! s:json_decode(json) abort
|
||||
let true = g:_spacevim_api_json_trus
|
||||
let false = g:_spacevim_api_json_falss
|
||||
let null = g:_spacevim_api_json_nuls
|
||||
if substitute(a:json, '\v\"%(\\.|[^"\\])*\"|true|false|null|[+-]?\d+%(\.\d+%([Ee][+-]?\d+)?)?', '', 'g') !~# "[^,:{}[\\] \t]"
|
||||
|
||||
try
|
||||
let object = eval(a:json)
|
||||
catch
|
||||
" malformed JSON
|
||||
let object = ''
|
||||
endtry
|
||||
else
|
||||
function! s:self.json_decode(json) abort
|
||||
let true = [self._json_true]
|
||||
let false = [self._json_false]
|
||||
let null = [self._json_null]
|
||||
" we need to remove \n, because eval() do not work
|
||||
let json = join(split(a:json, "\n"), '')
|
||||
try
|
||||
let object = eval(json)
|
||||
catch
|
||||
let object = ''
|
||||
endif
|
||||
|
||||
endtry
|
||||
call self._fixvar(object)
|
||||
return object
|
||||
endfunction
|
||||
" @vimlint(EVL102, 0, l:true)
|
||||
@ -58,18 +76,12 @@ else
|
||||
" @vimlint(EVL102, 0, l:null)
|
||||
endif
|
||||
|
||||
lockvar g:_spacevim_api_json_trus
|
||||
lockvar g:_spacevim_api_json_falss
|
||||
lockvar g:_spacevim_api_json_nuls
|
||||
|
||||
let s:json['json_decode'] = function('s:json_decode')
|
||||
|
||||
if exists('*json_encode')
|
||||
function! s:json_encode(val) abort
|
||||
function! s:self.json_encode(val) abort
|
||||
return json_encode(a:val)
|
||||
endfunction
|
||||
else
|
||||
function! s:json_encode(val) abort
|
||||
function! s:self.json_encode(val) abort
|
||||
if type(a:val) == type(0)
|
||||
return a:val
|
||||
elseif type(a:val) == type('')
|
||||
@ -78,37 +90,28 @@ else
|
||||
let json = substitute(json, "\n", '\\n', 'g')
|
||||
let json = substitute(json, "\t", '\\t', 'g')
|
||||
let json = substitute(json, '\([[:cntrl:]]\)', '\=printf("\x%02d", char2nr(submatch(1)))', 'g')
|
||||
return iconv(json, &encoding, 'utf-8')
|
||||
elseif type(a:val) == 2
|
||||
return self._iconv.iconv(json, &encoding, 'utf-8')
|
||||
elseif self._vim.is_func(a:val)
|
||||
let s = string(a:val)
|
||||
if s == string(g:_spacevim_api_json_nuls)
|
||||
if s ==# string(self._json_null)
|
||||
return 'null'
|
||||
elseif s == string(g:_spacevim_api_json_trus)
|
||||
elseif s ==# string(self._json_true)
|
||||
return 'true'
|
||||
elseif s == string(g:_spacevim_api_json_falss)
|
||||
elseif s ==# string(self._json_false)
|
||||
return 'false'
|
||||
endif
|
||||
elseif type(a:val) == type([])
|
||||
if len(a:val) == 1 && a:val[0] == g:_spacevim_api_json_falss[0]
|
||||
return 'false'
|
||||
elseif len(a:val) == 1 && a:val[0] == g:_spacevim_api_json_trus[0]
|
||||
return 'true'
|
||||
elseif len(a:val) == 1 && a:val[0] == g:_spacevim_api_json_nuls[0]
|
||||
return 'null'
|
||||
endif
|
||||
return '[' . join(map(copy(a:val), 's:json_encode(v:val)'), ',') . ']'
|
||||
elseif type(a:val) == 4
|
||||
return '{' . join(map(keys(a:val), "s:json_encode(v:val) . ':' . s:json_encode(a:val[v:val])"), ',') . '}'
|
||||
elseif self._vim.is_list(a:val)
|
||||
return '[' . join(map(copy(a:val), 'self.json_encode(v:val)'), ',') . ']'
|
||||
elseif self._vim.is_dict(a:val)
|
||||
return '{' . join(map(keys(a:val), "self.json_encode(v:val) . ':' . self.json_encode(a:val[v:val])"), ',') . '}'
|
||||
else
|
||||
return string(a:val)
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
let s:json['json_encode'] = function('s:json_encode')
|
||||
|
||||
function! SpaceVim#api#data#json#get() abort
|
||||
return deepcopy(s:json)
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2:
|
||||
|
@ -31,15 +31,29 @@ function! s:self.trim(str) abort
|
||||
return substitute(str, '^\s*', '', 'g')
|
||||
endfunction
|
||||
|
||||
" strcharpart is added in v7.4.1761
|
||||
"
|
||||
|
||||
if exists('*strcharpart')
|
||||
function! s:self.strcharpart(str, start, ...) abort
|
||||
return call('strcharpart', [a:str, a:start] + a:000)
|
||||
endfunction
|
||||
else
|
||||
function! s:self.strcharpart(str, start, ...) abort
|
||||
let chars = self.string2chars(a:str)
|
||||
return join(chars[a:start : get(a:000, 0, -1)], '')
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:self.fill(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
let l:string = a:str
|
||||
else
|
||||
let l:rightmost = 0
|
||||
while strwidth(strcharpart(a:str, 0, l:rightmost)) < a:length
|
||||
while strwidth(self.strcharpart(a:str, 0, l:rightmost)) < a:length
|
||||
let l:rightmost += 1
|
||||
endwhile
|
||||
let l:string = strcharpart(a:str, 0, l:rightmost)
|
||||
let l:string = self.strcharpart(a:str, 0, l:rightmost)
|
||||
endif
|
||||
let char = get(a:000, 0, ' ')
|
||||
if type(char) !=# 1 || len(char) > 1
|
||||
@ -67,7 +81,7 @@ function! s:self.fill_left(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
let l:string = a:str
|
||||
else
|
||||
let l:string = strcharpart(a:str, strwidth(a:str) - a:length, a:length)
|
||||
let l:string = self.strcharpart(a:str, strwidth(a:str) - a:length, a:length)
|
||||
endif
|
||||
let char = get(a:000, 0, ' ')
|
||||
if type(char) !=# 1 || len(char) > 1
|
||||
@ -81,7 +95,7 @@ function! s:self.fill_middle(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
let l:string = a:str
|
||||
else
|
||||
let l:string = strcharpart(a:str, (a:length/2 < 1 ? 1 : a:length/2), a:length)
|
||||
let l:string = self.strcharpart(a:str, (a:length/2 < 1 ? 1 : a:length/2), a:length)
|
||||
endif
|
||||
let l:numofspaces = a:length - strwidth(l:string)
|
||||
let char = get(a:000, 0, ' ')
|
||||
@ -110,21 +124,31 @@ endfunction
|
||||
function! s:self.string2chars(str) abort
|
||||
let save_enc = &encoding
|
||||
let &encoding = 'utf-8'
|
||||
let chars = []
|
||||
for i in range(strchars(a:str))
|
||||
call add(chars, strcharpart(a:str, i , 1))
|
||||
endfor
|
||||
let chars = split(a:str, '\zs')
|
||||
let &encoding = save_enc
|
||||
return chars
|
||||
endfunction
|
||||
|
||||
if exists('*strcharpart') && 0
|
||||
function! s:self.matchstrpos(str, need, ...) abort
|
||||
return call('matchstrpos', [a:str, a:need] + a:000)
|
||||
endfunction
|
||||
else
|
||||
function! s:self.matchstrpos(str, need, ...) abort
|
||||
let matchedstr = call('matchstr', [a:str, a:need] + a:000)
|
||||
let matchbegin = call('match', [a:str, a:need] + a:000)
|
||||
let matchend = call('matchend', [a:str, a:need] + a:000)
|
||||
return [matchedstr, matchbegin, matchend]
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:self.strAllIndex(str, need, use_expr) abort
|
||||
if a:use_expr
|
||||
let rst = []
|
||||
let idx = matchstrpos(a:str, a:need)
|
||||
let idx = self.matchstrpos(a:str, a:need)
|
||||
while idx[1] != -1
|
||||
call add(rst, [idx[1], idx[2]])
|
||||
let idx = matchstrpos(a:str, a:need, idx[2])
|
||||
let idx = self.matchstrpos(a:str, a:need, idx[2])
|
||||
endwhile
|
||||
return rst
|
||||
else
|
||||
@ -176,7 +200,7 @@ function! s:self.strB2Q(str) abort
|
||||
endfor
|
||||
let &encoding = save_enc
|
||||
return join(bchars, '')
|
||||
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -103,6 +103,7 @@ function! s:self.warp_nvim(argv, opts) abort dict
|
||||
let obj._argv = a:argv
|
||||
let obj._opts = a:opts
|
||||
" @vimlint(EVL103, 1, a:job_id)
|
||||
" @vimlint(EVL103, 1, a:event)
|
||||
function! obj.__on_stdout(id, data, event) abort dict
|
||||
if has_key(self._opts, 'on_stdout')
|
||||
if a:data[-1] == ''
|
||||
@ -133,6 +134,7 @@ function! s:self.warp_nvim(argv, opts) abort dict
|
||||
endif
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:job_id)
|
||||
" @vimlint(EVL103, 0, a:event)
|
||||
|
||||
let obj = {
|
||||
\ 'argv': a:argv,
|
||||
@ -165,7 +167,7 @@ function! s:self.start(argv, ...) abort dict
|
||||
return -1
|
||||
endtry
|
||||
if job > 0
|
||||
let msg = ['process '. jobpid(job), ' run']
|
||||
let msg = ['process '. jobpid(job), 'run']
|
||||
call extend(self.jobs, {job : msg})
|
||||
else
|
||||
if job == -1
|
||||
|
@ -8,11 +8,12 @@
|
||||
|
||||
|
||||
let s:self = {}
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
let s:self.__cmp = SpaceVim#api#import('vim#compatible')
|
||||
let s:self.__string = SpaceVim#api#import('data#string')
|
||||
|
||||
function! s:self.jumps() abort
|
||||
let result = []
|
||||
for jump in split(s:CMP.execute('jumps'), '\n')[1:]
|
||||
for jump in split(self.__cmp.execute('jumps'), '\n')[1:]
|
||||
let list = split(jump)
|
||||
if len(list) < 4
|
||||
continue
|
||||
@ -51,7 +52,7 @@ function! s:self.parse_string(line) abort
|
||||
let i = 0
|
||||
let line = []
|
||||
while i < strlen(a:line) || i != -1
|
||||
let [rst, m, n] = matchstrpos(a:line, expr, i)
|
||||
let [rst, m, n] = self.__string.matchstrpos(a:line, expr, i)
|
||||
if m == -1
|
||||
call add(line, a:line[ i : -1 ])
|
||||
break
|
||||
@ -91,6 +92,8 @@ elseif exists('*win_execute')
|
||||
call win_execute(a:win, ':normal! g"')
|
||||
endfunction
|
||||
elseif has('lua')
|
||||
" @vimlint(EVL103, 1, a:win)
|
||||
" @vimlint(EVL103, 1, a:pos)
|
||||
function! s:self.win_set_cursor(win, pos) abort
|
||||
lua local winindex = vim.eval("win_id2win(a:win) - 1")
|
||||
lua local w = vim.window(winindex)
|
||||
@ -101,6 +104,8 @@ else
|
||||
function! s:self.win_set_cursor(win, pos) abort
|
||||
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:win)
|
||||
" @vimlint(EVL103, 0, a:pos)
|
||||
endif
|
||||
|
||||
if exists('*nvim_buf_line_count')
|
||||
@ -108,10 +113,12 @@ if exists('*nvim_buf_line_count')
|
||||
return nvim_buf_line_count(a:buf)
|
||||
endfunction
|
||||
elseif has('lua')
|
||||
" @vimlint(EVL103, 1, a:buf)
|
||||
function! s:self.buf_line_count(buf) abort
|
||||
" lua numbers are floats, so use float2nr
|
||||
return float2nr(luaeval('#vim.buffer(vim.eval("a:buf"))'))
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:buf)
|
||||
else
|
||||
function! s:self.buf_line_count(buf) abort
|
||||
return len(getbufline(a:buf, 1, '$'))
|
||||
|
@ -63,7 +63,7 @@ endfunction
|
||||
function! s:self.bufadd(name) abort
|
||||
if exists('*bufadd')
|
||||
return bufadd(a:name)
|
||||
elseif has('lua') && empty(a:name)
|
||||
elseif get(g:, '_spacevim_if_lua', 0) && empty(a:name)
|
||||
let nr = float2nr(luaeval('vim.open().number'))
|
||||
call setbufvar(nr, '&buflisted', 0)
|
||||
return nr
|
||||
@ -149,11 +149,13 @@ if exists('*nvim_buf_line_count')
|
||||
function! s:self.line_count(buf) abort
|
||||
return nvim_buf_line_count(a:buf)
|
||||
endfunction
|
||||
elseif has('lua')
|
||||
elseif get(g:, '_spacevim_if_lua', 0)
|
||||
" @vimlint(EVL103, 1, a:buf)
|
||||
function! s:self.line_count(buf) abort
|
||||
" lua numbers are floats, so use float2nr
|
||||
return float2nr(luaeval('#vim.buffer(vim.eval("a:buf"))'))
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:buf)
|
||||
else
|
||||
function! s:self.line_count(buf) abort
|
||||
return len(getbufline(a:buf, 1, '$'))
|
||||
@ -232,9 +234,9 @@ if end_line < 0:
|
||||
lines = vim.eval("a:replacement")
|
||||
vim.buffers[bufnr][start_line:end_line] = lines
|
||||
EOF
|
||||
elseif has('lua')
|
||||
elseif get(g:, '_spacevim_if_lua', 0) == 1
|
||||
" @todo add lua support
|
||||
noautocmd lua require("spacevim.api.vim.buffer").set_lines(
|
||||
silent! noautocmd lua require("spacevim.api.vim.buffer").set_lines(
|
||||
\ vim.eval("a:buffer"),
|
||||
\ vim.eval("a:start"),
|
||||
\ vim.eval("a:end"),
|
||||
|
@ -43,8 +43,8 @@ function! s:self.group2dict(name) abort
|
||||
\ 'italic' : synIDattr(id, 'italic'),
|
||||
\ 'reverse' : synIDattr(id, 'reverse'),
|
||||
\ 'underline' : synIDattr(id, 'underline'),
|
||||
\ 'guibg' : synIDattr(id, 'bg#'),
|
||||
\ 'guifg' : synIDattr(id, 'fg#'),
|
||||
\ 'guibg' : tolower(synIDattr(id, 'bg#', 'gui')),
|
||||
\ 'guifg' : tolower(synIDattr(id, 'fg#', 'gui')),
|
||||
\ }
|
||||
return rst
|
||||
endfunction
|
||||
|
@ -44,7 +44,10 @@ endfunction
|
||||
augroup spacevim_api_vim_tab
|
||||
autocmd!
|
||||
autocmd TabLeave * let s:previous_tabpagenr = tabpagenr()
|
||||
autocmd TabClosed * call <SID>tab_closed_handle()
|
||||
if exists('#TabClosed')
|
||||
" TabClosed event is added in patch-7.4.2027
|
||||
autocmd TabClosed * call <SID>tab_closed_handle()
|
||||
endif
|
||||
augroup END
|
||||
|
||||
function! s:self.previous_tabpagenr() abort
|
||||
|
@ -57,7 +57,20 @@ function! SpaceVim#plugins#a#set_config_name(path, name) abort
|
||||
endfunction
|
||||
|
||||
function! s:get_project_config(conf_file) abort
|
||||
let conf = s:JSON.json_decode(join(readfile(a:conf_file), "\n"))
|
||||
call s:LOGGER.info('read context from: '. a:conf_file)
|
||||
let context = join(readfile(a:conf_file), "\n")
|
||||
call s:LOGGER.info(context)
|
||||
let g:wsdjson = context
|
||||
let conf = s:JSON.json_decode(context)
|
||||
call s:LOGGER.info('decode result is: '. string(conf))
|
||||
if type(conf) !=# type({})
|
||||
" in Old vim we get E706
|
||||
" Variable type mismatch for conf, so we need to unlet conf first
|
||||
" ref: patch-7.4.1546
|
||||
" https://github.com/vim/vim/commit/f6f32c38bf3319144a84a01a154c8c91939e7acf
|
||||
unlet conf
|
||||
let conf = {}
|
||||
endif
|
||||
let root = s:FILE.unify_path(a:conf_file, ':p:h')
|
||||
return {
|
||||
\ 'root' : root,
|
||||
@ -89,10 +102,12 @@ function! s:paser(alt_config_json) abort
|
||||
call s:LOGGER.info('Start to paser alternate files for: ' . a:alt_config_json.root)
|
||||
let s:project_config[a:alt_config_json.root] = {}
|
||||
for key in keys(a:alt_config_json.config)
|
||||
call s:LOGGER.info('start paser key:' . key)
|
||||
let searchpath = key
|
||||
if match(searchpath, '/\*')
|
||||
let searchpath = substitute(searchpath, '*', '**/*', 'g')
|
||||
endif
|
||||
call s:LOGGER.info('run globpath for: '. searchpath)
|
||||
for file in s:CMP.globpath('.', searchpath)
|
||||
let file = s:FILE.unify_path(file, ':.')
|
||||
let s:project_config[a:alt_config_json.root][file] = {}
|
||||
@ -162,22 +177,37 @@ function! SpaceVim#plugins#a#get_alt(file, conf_path, request_paser,...) abort
|
||||
else
|
||||
call s:paser(alt_config_json)
|
||||
endif
|
||||
try
|
||||
" try
|
||||
" This will throw error in vim7.4.629 and 7.4.052
|
||||
" @quection why can not catch the errors?
|
||||
" return s:project_config[alt_config_json.root][a:file][get(a:000, 0, 'alternate')]
|
||||
" catch
|
||||
" return ''
|
||||
" endtry
|
||||
if has_key(s:project_config, alt_config_json.root)
|
||||
\ && has_key(s:project_config[alt_config_json.root], a:file)
|
||||
\ && has_key(s:project_config[alt_config_json.root][a:file], get(a:000, 0, 'alternate'))
|
||||
return s:project_config[alt_config_json.root][a:file][get(a:000, 0, 'alternate')]
|
||||
catch
|
||||
else
|
||||
return ''
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" @vimlint(EVL103, 1, a:file)
|
||||
function! s:get_alternate(file) abort
|
||||
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:file)
|
||||
|
||||
|
||||
function! SpaceVim#plugins#a#getConfigPath() abort
|
||||
return s:FILE.unify_path(get(s:alternate_conf, getcwd(), '_'), ':p')
|
||||
endfunction
|
||||
|
||||
|
||||
" @vimlint(EVL103, 1, a:ArgLead)
|
||||
" @vimlint(EVL103, 1, a:CmdLine)
|
||||
" @vimlint(EVL103, 1, a:CursorPos)
|
||||
function! SpaceVim#plugins#a#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
let file = s:FILE.unify_path(bufname('%'), ':.')
|
||||
let conf_file_path = s:FILE.unify_path(get(s:alternate_conf, getcwd(), '_'), ':p')
|
||||
@ -191,6 +221,9 @@ function! SpaceVim#plugins#a#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
endtry
|
||||
return join(keys(a), "\n")
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:ArgLead)
|
||||
" @vimlint(EVL103, 0, a:CmdLine)
|
||||
" @vimlint(EVL103, 0, a:CursorPos)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
@ -18,7 +18,7 @@ let g:ctrlp_show_hidden = get(g:, 'ctrlp_show_hidden', 1)
|
||||
"for caching
|
||||
let g:ctrlp_use_caching = get(g:, 'ctrlp_use_caching', 500)
|
||||
let g:ctrlp_clear_cache_on_exit = get(g:, 'ctrlp_clear_cache_on_exit', 1)
|
||||
let g:ctrlp_cache_dir = get(g:, 'ctrlp_cache_dir', g:spacevim_data_dir.'/ctrlp')
|
||||
let g:ctrlp_cache_dir = get(g:, 'ctrlp_cache_dir', get(g:, 'spacevim_data_dir', '~') . '/ctrlp')
|
||||
"let g:ctrlp_map = ',,'
|
||||
"let g:ctrlp_open_multiple_files = 'v'
|
||||
"if you have install ag, the g:ctrlp_custom_ignore will not work
|
||||
@ -31,7 +31,7 @@ if executable('rg') && !exists('g:ctrlp_user_command')
|
||||
let g:ctrlp_user_command = 'rg %s --hidden --files -g "" '
|
||||
\ . join(SpaceVim#util#Generate_ignore(get(g:, 'spacevim_wildignore', ''),'rg', SpaceVim#api#import('system').isWindows ? 0 : 1))
|
||||
elseif executable('ag') && !exists('g:ctrlp_user_command')
|
||||
let g:ctrlp_user_command = 'ag --hidden -i -g "" ' . join(SpaceVim#util#Generate_ignore(g:spacevim_wildignore,'ag')) . ' %s'
|
||||
let g:ctrlp_user_command = 'ag --hidden -i -g "" ' . join(SpaceVim#util#Generate_ignore(get(g:, 'spacevim_wildignore', &wildignore),'ag')) . ' %s'
|
||||
elseif s:SYS.isWindows
|
||||
let g:ctrlp_user_command =
|
||||
\ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows
|
||||
|
@ -251,14 +251,13 @@
|
||||
{% if page.lang == "zh" %}
|
||||
<p align="center">
|
||||
<span class="credits right"
|
||||
>网站源码位于 Github,
|
||||
>由Jekyll强力驱动,
|
||||
<a
|
||||
href="https://github.com/SpaceVim/SpaceVim/edit/master/docs/{{ page.path }}"
|
||||
>帮助改进本页面</a
|
||||
>
|
||||
— 网站主题:
|
||||
<a href="https://twitter.com/michigangraham">mattgraham</a>,
|
||||
</span>
|
||||
<br>
|
||||
<input
|
||||
id="textbox"
|
||||
type="text"
|
||||
@ -269,14 +268,13 @@
|
||||
{% else %}
|
||||
<p align="center">
|
||||
<span class="credits right"
|
||||
>Hosted on GitHub,
|
||||
>Powered by Jekyll,
|
||||
<a
|
||||
href="https://github.com/SpaceVim/SpaceVim/edit/master/docs/{{ page.path }}"
|
||||
>Help improve this page</a
|
||||
>
|
||||
— Theme by
|
||||
<a href="https://twitter.com/michigangraham">mattgraham</a>,
|
||||
</span>
|
||||
<br>
|
||||
<input
|
||||
id="textbox"
|
||||
type="text"
|
||||
|
@ -75,10 +75,12 @@ With layers feature, this version of Vim distribution try to turn Vim/Neovim int
|
||||
|
||||
- Which version of Vim/Neovim is needed?
|
||||
|
||||
SpaceVim has been tested in following version of vim/neovim:
|
||||
SpaceVim has been tested in [travis-ci](https://travis-ci.org/SpaceVim/SpaceVim) and
|
||||
[appveyor](https://ci.appveyor.com/project/wsdjeg/spacevim/branch/master) with following
|
||||
versions of neovim and vim:
|
||||
|
||||
1. vim `7.4.1689`,`8.0.0027`,`8.0.1453`
|
||||
2. neovim ~~`0.2.0`~~,`0.2.2`,`0.3.0`,`0.3.1`,`0.3.2`,`0.3.3`,`0.3.4`,`0.3.5`,`0.3.7`,`0.3.8`,`0.4.2`,`0.4.3`
|
||||
1. vim: ~~`7.4.052`~~, `7.4.629`, `7.4.1689`,`8.0.0027`,`8.0.1453`, `8.1.2269`
|
||||
2. neovim: `0.3.0`,`0.3.1`,`0.3.2`,`0.3.3`,`0.3.4`,`0.3.5`,`0.3.7`,`0.3.8`,`0.4.2`,`0.4.3`
|
||||
|
||||
For more general questions, please read SpaceVim [FAQ](faq/).
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
Execute ( SpaceVim api: data#json ):
|
||||
let json = SpaceVim#api#import('data#json')
|
||||
let context = '{"java" : "hello world"}'
|
||||
AssertEqual json.json_decode(context).java, 'hello world'
|
||||
let context = '{"java" : true}'
|
||||
AssertEqual json.json_decode(context).java, get(v:, 'true', 1)
|
||||
AssertEqual json.json_decode(json.json_encode({'foo' : 'zaa'})), {'foo' : 'zaa'}
|
||||
|
@ -2,6 +2,8 @@ Execute ( SpaceVim api: data#string ):
|
||||
let str = SpaceVim#api#import('data#string')
|
||||
Log 'test trim()'
|
||||
AssertEqual str.trim(' s b '), 's b'
|
||||
Log 'test strcharpart()'
|
||||
AssertEqual str.strcharpart('abcd', 1, 2), 'bc'
|
||||
Log 'test fill()'
|
||||
AssertEqual str.fill('s b', 10), 's b '
|
||||
Log 'test fill() len < strlen'
|
||||
|
@ -31,7 +31,7 @@ Execute ( SpaceVim api: job ):
|
||||
call job.send(jobid, 'foo')
|
||||
sleep 10m
|
||||
AssertEqual stdout, 'foo'
|
||||
AssertEqual job.status(jobid), ' run'
|
||||
AssertEqual job.status(jobid), 'run'
|
||||
call job.stop(jobid)
|
||||
AssertEqual exit_data, 1
|
||||
else
|
||||
|
@ -9,6 +9,7 @@ Execute ( SpaceVim api: vim#buffer buf_set_lines):
|
||||
let nr = buffer.bufadd('')
|
||||
call setbufvar(nr, '&buftype', 'nofile')
|
||||
call setbufvar(nr, '&buflisted', 0)
|
||||
Log 'The value of g:_spacevim_if_lua is ' . get(g:, '_spacevim_if_lua', 0)
|
||||
call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4'])
|
||||
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'line 2', 'line 3', 'line 4']
|
||||
call buffer.buf_set_lines(nr, 1, 3, 0, ['replace 1', 'replace 2', 'replace 3'])
|
||||
|
@ -1,11 +1,17 @@
|
||||
Execute ( SpaceVim api: vim#highlight ):
|
||||
let hi = SpaceVim#api#import('vim#highlight')
|
||||
set termguicolors
|
||||
let cmp =SpaceVim#api#import('vim#compatible')
|
||||
highlight TestAPIVimHighlight ctermfg=11 guifg=#89DDFF guibg=#212121
|
||||
|
||||
let test_api_hi = hi.group2dict('TestAPIVimHighlight')
|
||||
AssertEqual test_api_hi.guibg, '#212121'
|
||||
AssertEqual test_api_hi.guifg, '#89ddff'
|
||||
if !empty(test_api_hi.guifg)
|
||||
Log test_api_hi
|
||||
let id = hlID('TestAPIVimHighlight')
|
||||
Log 'guifg is: ' . synIDattr(id, 'fg#', 'gui')
|
||||
Log 'guibg is: ' . synIDattr(id, 'bg#', 'gui')
|
||||
Log cmp.execute('hi TestAPIVimHighlight')
|
||||
AssertEqual test_api_hi.guibg, '#212121'
|
||||
AssertEqual test_api_hi.guifg, '#89ddff'
|
||||
endif
|
||||
AssertEqual test_api_hi.ctermfg, '11'
|
||||
|
||||
let unknown_hi = hi.group2dict('UnknownHighlightGroup')
|
||||
@ -18,3 +24,4 @@ Execute ( SpaceVim api: vim#highlight ):
|
||||
AssertEqual unknown_hi.underline, ''
|
||||
AssertEqual unknown_hi.guibg, ''
|
||||
AssertEqual unknown_hi.guifg, ''
|
||||
unlet hi cmp test_api_hi unknown_hi
|
||||
|
@ -1,7 +1,11 @@
|
||||
Execute ( SpaceVim colorscheme ):
|
||||
let g:current_colors = get(g:, 'colors_name', '')
|
||||
colorscheme SpaceVim
|
||||
AssertEqual g:colors_name, 'SpaceVim'
|
||||
if !empty(g:current_colors)
|
||||
exe 'colorscheme ' . g:current_colors
|
||||
if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256
|
||||
Log 'SpaceVim colorscheme only support termguicolors'
|
||||
else
|
||||
colorscheme SpaceVim
|
||||
AssertEqual get(g:, 'colors_name', ''), 'SpaceVim'
|
||||
if !empty(g:current_colors)
|
||||
exe 'colorscheme ' . g:current_colors
|
||||
endif
|
||||
endif
|
||||
|
@ -1,4 +1,7 @@
|
||||
Execute ( SpaceVim syntax file ):
|
||||
for sfile in globpath(getcwd(), "syntax/*.vim", 0, 1)
|
||||
let cmp = SpaceVim#api#import('vim#compatible')
|
||||
for sfile in cmp.globpath(getcwd(), "syntax/*.vim")
|
||||
exe 'so ' . sfile
|
||||
unlet sfile
|
||||
endfor
|
||||
unlet cmp
|
||||
|
Loading…
x
Reference in New Issue
Block a user