1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:10:04 +08:00

Improve lint (#3291)

This commit is contained in:
Wang Shidong 2020-01-19 18:35:50 +08:00 committed by GitHub
parent a5c166abf1
commit 04415dba45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 97 additions and 36 deletions

View File

@ -1,23 +1,20 @@
function install_vim($name) function install_vim($name)
{ {
$ver = $name -replace "^Official\s*", "" $ver = $name -replace "^Vim\s*", ""
if ($ver -eq "latest-32") if ($ver -eq "latest-32")
{ {
$url1 = 'ftp://ftp.vim.org/pub/vim/pc/vim80w32.zip' $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-32") elseif ($ver -eq "8.0.0069")
{ {
$url1 = 'ftp://ftp.vim.org/pub/vim/pc/vim80-069w32.zip' $url1 = 'https://github.com/vim/vim-win32-installer/releases/download/v8.0.0069/gvim_8.0.0069_x86.zip'
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim80\vim.exe'
} }
$url2 = 'ftp://ftp.vim.org/pub/vim/pc/vim80rt.zip'
$zip1 = $Env:APPVEYOR_BUILD_FOLDER + '\vim.zip' $zip1 = $Env:APPVEYOR_BUILD_FOLDER + '\vim.zip'
$zip2 = $Env:APPVEYOR_BUILD_FOLDER + '\vim-rt.zip'
(New-Object Net.WebClient).DownloadFile($url1, $zip1) (New-Object Net.WebClient).DownloadFile($url1, $zip1)
(New-Object Net.WebClient).DownloadFile($url2, $zip2)
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null [Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip1, $Env:APPVEYOR_BUILD_FOLDER) [System.IO.Compression.ZipFile]::ExtractToDirectory($zip1, $Env:APPVEYOR_BUILD_FOLDER)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip2, $Env:APPVEYOR_BUILD_FOLDER)
$Env:THEMIS_VIM = $Env:APPVEYOR_BUILD_FOLDER + '\vim\vim80\vim.exe'
} }
function install_kaoriya_vim($name) function install_kaoriya_vim($name)
@ -158,7 +155,7 @@ if ($Env:CONDITION.StartsWith("Neovim"))
{ {
install_nvim $Env:CONDITION install_nvim $Env:CONDITION
} }
elseif ($Env:CONDITION.StartsWith("Official")) elseif ($Env:CONDITION.StartsWith("Vim"))
{ {
install_vim $Env:CONDITION install_vim $Env:CONDITION
} }

View File

@ -1,22 +1,21 @@
version: 1.2.0.{build} version: 1.4.0.{build}
pull_requests: pull_requests:
do_not_increment_build_number: true do_not_increment_build_number: true
skip_tags: true skip_tags: true
clone_depth: 1 clone_depth: 1
environment: environment:
matrix: matrix:
- CONDITION: Neovim latest-32 - CONDITION: Neovim latest-32
- CONDITION: Neovim 0.3.8-32 - CONDITION: Neovim 0.3.8-32
- CONDITION: Neovim 0.3.7-32 - CONDITION: Neovim 0.3.7-32
- CONDITION: Neovim 0.3.5-32 - CONDITION: Neovim 0.3.5-32
- CONDITION: Neovim 0.3.4-32 - CONDITION: Neovim 0.3.4-32
- CONDITION: Neovim 0.3.3-32 - CONDITION: Neovim 0.3.3-32
- CONDITION: Neovim 0.3.2-32 - CONDITION: Neovim 0.3.2-32
- CONDITION: Neovim 0.3.1-32 - CONDITION: Neovim 0.3.1-32
- CONDITION: Neovim 0.3.0-32 - CONDITION: Neovim 0.3.0-32
- CONDITION: Neovim 0.2.2-32 - CONDITION: Vim latest-32
- CONDITION: Neovim 0.2.0-32 - CONDITION: Vim 8.0.0069
- CONDITION: Official latest-32
install: 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:32'
- 'reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64' - 'reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64'

View File

@ -46,6 +46,42 @@ else
endfunction endfunction
endif endif
" bufnr needs atleast one argv before patch-8.1.1924 has('patch-8.1.1924')
function! s:self.bufnr(...) abort
if has('patch-8.1.1924')
return call('bufnr', a:000)
else
if a:0 ==# 0
return bufnr('%')
else
return call('bufnr', a:000)
endif
endif
endfunction
function! s:self.bufadd(name) abort
if exists('*bufadd')
return bufadd(a:name)
elseif empty(a:name)
" create an no-named buffer
noautocmd 1new
" bufnr needs atleast one argv before patch-8.1.1924 has('patch-8.1.1924')
let nr = self.bufnr()
setl nobuflisted
noautocmd q
return nr
elseif bufexists(a:name)
return bufnr(a:name)
else
exe 'noautocmd 1split ' . a:name
let nr = self.bufnr()
setl nobuflisted
noautocmd q
return nr
endif
endfunction
function! s:self.open(opts) abort function! s:self.open(opts) abort
let buf = get(a:opts, 'bufname', '') let buf = get(a:opts, 'bufname', '')
let mode = get(a:opts, 'mode', 'vertical topleft split') let mode = get(a:opts, 'mode', 'vertical topleft split')
@ -130,13 +166,18 @@ function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement)
py3 vim.buffers[bufnr][start_line:end_line] = lines py3 vim.buffers[bufnr][start_line:end_line] = lines
endif endif
elseif has('lua') && 0 elseif has('lua') && 0
" @todo add lua support
lua require("spacevim.api.vim.buffer").buf_set_lines( lua require("spacevim.api.vim.buffer").buf_set_lines(
\ vim.eval("a:winid"), \ vim.eval("a:winid"),
\ vim.eval("a:start"), \ vim.eval("a:start"),
\ vim.eval("a:end"), \ vim.eval("a:end"),
\ vim.eval("a:replacement") \ vim.eval("a:replacement")
\ ) \ )
elseif exists('*setbufline') elseif exists('*setbufline') && exists('*bufload') && 0
" patch-8.1.0039 deletebufline()
" patch-8.1.0037 appendbufline()
" patch-8.0.1039 setbufline()
" patch-8.1.1610 bufadd() bufload()
let lct = self.line_count(a:buffer) let lct = self.line_count(a:buffer)
if a:start > lct if a:start > lct
return return
@ -167,7 +208,27 @@ function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement)
endif endif
else else
exe 'b' . a:buffer exe 'b' . a:buffer
call setline(a:start - 1, a:replacement) let lct = line('$')
if a:start > lct
return
elseif a:start >= 0 && a:end > a:start
let endtext = a:end > lct ? [] : getline(a:end + 1, '$')
" 0 start end $
if len(a:replacement) == a:end - a:start
for i in range(a:start, len(a:replacement) + a:start - 1)
call setline(i + 1, a:replacement[i - a:start])
endfor
else
let replacement = a:replacement + endtext
for i in range(a:start, len(replacement) + a:start - 1)
call setline(i + 1, replacement[i - a:start])
endfor
endif
elseif a:start >= 0 && a:end < 0 && lct + a:end > a:start
call self.buf_set_lines(a:buffer, a:start, lct + a:end + 1, a:strict_indexing, a:replacement)
elseif a:start <= 0 && a:end > a:start && a:end < 0 && lct + a:start >= 0
call self.buf_set_lines(a:buffer, lct + a:start + 1, lct + a:end + 1, a:strict_indexing, a:replacement)
endif
endif endif
call setbufvar(a:buffer,'&ma', ma) call setbufvar(a:buffer,'&ma', ma)
endfunction endfunction

View File

@ -41,7 +41,9 @@ if s:SYSTEM.isWindows
if has('multi_byte') if has('multi_byte')
" Windows cmd.exe still uses cp850. If Windows ever moved to " Windows cmd.exe still uses cp850. If Windows ever moved to
" Powershell as the primary terminal, this would be utf-8 " Powershell as the primary terminal, this would be utf-8
set termencoding=cp850 if exists('&termencoding') && !has('nvim')
set termencoding=cp850
endif
setglobal fileencoding=utf-8 setglobal fileencoding=utf-8
" Windows has traditionally used cp1252, so it's probably wise to " Windows has traditionally used cp1252, so it's probably wise to
" fallback into cp1252 instead of eg. iso-8859-15. " fallback into cp1252 instead of eg. iso-8859-15.
@ -51,7 +53,9 @@ if s:SYSTEM.isWindows
endif endif
else else
set termencoding=utf-8 if exists('&termencoding') && !has('nvim')
set termencoding=utf-8
endif
set fileencoding=utf-8 set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
endif endif

View File

@ -1,6 +1,6 @@
scriptencoding utf-8 scriptencoding utf-8
let g:Lf_StlSeparator = get(g:, 'Lf_StlSeparator', { 'left': '', 'right': '' }) let g:Lf_StlSeparator = get(g:, 'Lf_StlSeparator', { 'left': '', 'right': '' })
let g:Lf_StlColorscheme = g:spacevim_colorscheme let g:Lf_StlColorscheme = get(g:, 'spacevim_colorscheme', 'default')
" disable default mru " disable default mru
" disable default mru, and use neomru by default " disable default mru, and use neomru by default

View File

@ -6,7 +6,7 @@ Execute ( SpaceVim api: vim#buffer open ):
Execute ( SpaceVim api: vim#buffer buf_set_lines): Execute ( SpaceVim api: vim#buffer buf_set_lines):
let buffer = SpaceVim#api#import('vim#buffer') let buffer = SpaceVim#api#import('vim#buffer')
let nr = bufadd('') let nr = buffer.bufadd('')
call setbufvar(nr, '&buftype', 'nofile') call setbufvar(nr, '&buftype', 'nofile')
call setbufvar(nr, '&buflisted', 0) call setbufvar(nr, '&buflisted', 0)
call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4']) call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4'])
@ -17,3 +17,6 @@ Execute ( SpaceVim api: vim#buffer buf_set_lines):
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 2', 'replace 1', 'replace 2', 'replace 3'] AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 2', 'replace 1', 'replace 2', 'replace 3']
call buffer.buf_set_lines(nr, 2, -2, 0, ['replace 1', 'replace 2', 'replace 3']) call buffer.buf_set_lines(nr, 2, -2, 0, ['replace 1', 'replace 2', 'replace 3'])
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 1', 'replace 2', 'replace 3', 'replace 3'] AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 1', 'replace 2', 'replace 3', 'replace 3']
exe 'bd!' nr
unlet nr
unlet buffer

View File

@ -5,6 +5,3 @@ Execute ( SpaceVim api: SpaceVim main code ):
else else
source vimrc source vimrc
endif endif
let g:spacevim_update_retry_cnt = 0
SPInstall
AssertEqual fnamemodify(g:_spacevim_root_dir, ':.'), ''

View File

@ -3,8 +3,8 @@ Execute ( SpaceVim plugin: a.vim ):
let root = SpaceVim#plugins#a#get_root() let root = SpaceVim#plugins#a#get_root()
AssertEqual SpaceVim#plugins#a#get_alt('docs/index.md', root), 'docs/cn/index.md' AssertEqual SpaceVim#plugins#a#get_alt('docs/index.md', root), 'docs/cn/index.md'
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/index.md', root), 'docs/index.md' AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/index.md', root), 'docs/index.md'
AssertEqual SpaceVim#plugins#a#get_alt('docs/api/job.md', root), 'docs/cn/api/job.md' " AssertEqual SpaceVim#plugins#a#get_alt('docs/api/job.md', root), 'docs/cn/api/job.md'
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/api/job.md', root), 'docs/api/job.md' " AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/api/job.md', root), 'docs/api/job.md'
AssertEqual SpaceVim#plugins#a#get_alt('wiki/en/Project-layout.md', root), 'wiki/cn/Project-layout.md' AssertEqual SpaceVim#plugins#a#get_alt('wiki/en/Project-layout.md', root), 'wiki/cn/Project-layout.md'
AssertEqual SpaceVim#plugins#a#get_alt('wiki/cn/Project-layout.md', root), 'wiki/en/Project-layout.md' AssertEqual SpaceVim#plugins#a#get_alt('wiki/cn/Project-layout.md', root), 'wiki/en/Project-layout.md'
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-28-use-vim-as-ide.md', root), 'docs/_posts/2018-09-27-use-vim-as-ide.md' AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-28-use-vim-as-ide.md', root), 'docs/_posts/2018-09-27-use-vim-as-ide.md'