mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:30:05 +08:00
Improve lint (#3291)
This commit is contained in:
parent
a5c166abf1
commit
04415dba45
@ -1,23 +1,20 @@
|
||||
function install_vim($name)
|
||||
{
|
||||
$ver = $name -replace "^Official\s*", ""
|
||||
$ver = $name -replace "^Vim\s*", ""
|
||||
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'
|
||||
$zip2 = $Env:APPVEYOR_BUILD_FOLDER + '\vim-rt.zip'
|
||||
(New-Object Net.WebClient).DownloadFile($url1, $zip1)
|
||||
(New-Object Net.WebClient).DownloadFile($url2, $zip2)
|
||||
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
|
||||
[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)
|
||||
@ -158,7 +155,7 @@ if ($Env:CONDITION.StartsWith("Neovim"))
|
||||
{
|
||||
install_nvim $Env:CONDITION
|
||||
}
|
||||
elseif ($Env:CONDITION.StartsWith("Official"))
|
||||
elseif ($Env:CONDITION.StartsWith("Vim"))
|
||||
{
|
||||
install_vim $Env:CONDITION
|
||||
}
|
||||
|
29
appveyor.yml
29
appveyor.yml
@ -1,22 +1,21 @@
|
||||
version: 1.2.0.{build}
|
||||
version: 1.4.0.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
do_not_increment_build_number: true
|
||||
skip_tags: true
|
||||
clone_depth: 1
|
||||
environment:
|
||||
matrix:
|
||||
- CONDITION: Neovim latest-32
|
||||
- CONDITION: Neovim 0.3.8-32
|
||||
- CONDITION: Neovim 0.3.7-32
|
||||
- CONDITION: Neovim 0.3.5-32
|
||||
- CONDITION: Neovim 0.3.4-32
|
||||
- CONDITION: Neovim 0.3.3-32
|
||||
- CONDITION: Neovim 0.3.2-32
|
||||
- CONDITION: Neovim 0.3.1-32
|
||||
- CONDITION: Neovim 0.3.0-32
|
||||
- CONDITION: Neovim 0.2.2-32
|
||||
- CONDITION: Neovim 0.2.0-32
|
||||
- CONDITION: Official latest-32
|
||||
matrix:
|
||||
- CONDITION: Neovim latest-32
|
||||
- CONDITION: Neovim 0.3.8-32
|
||||
- CONDITION: Neovim 0.3.7-32
|
||||
- CONDITION: Neovim 0.3.5-32
|
||||
- CONDITION: Neovim 0.3.4-32
|
||||
- CONDITION: Neovim 0.3.3-32
|
||||
- CONDITION: Neovim 0.3.2-32
|
||||
- CONDITION: Neovim 0.3.1-32
|
||||
- CONDITION: Neovim 0.3.0-32
|
||||
- CONDITION: Vim latest-32
|
||||
- CONDITION: Vim 8.0.0069
|
||||
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'
|
||||
|
@ -46,6 +46,42 @@ else
|
||||
endfunction
|
||||
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
|
||||
let buf = get(a:opts, 'bufname', '')
|
||||
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
|
||||
endif
|
||||
elseif has('lua') && 0
|
||||
" @todo add lua support
|
||||
lua require("spacevim.api.vim.buffer").buf_set_lines(
|
||||
\ vim.eval("a:winid"),
|
||||
\ vim.eval("a:start"),
|
||||
\ vim.eval("a:end"),
|
||||
\ 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)
|
||||
if a:start > lct
|
||||
return
|
||||
@ -167,7 +208,27 @@ function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement)
|
||||
endif
|
||||
else
|
||||
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
|
||||
call setbufvar(a:buffer,'&ma', ma)
|
||||
endfunction
|
||||
|
@ -41,7 +41,9 @@ if s:SYSTEM.isWindows
|
||||
if has('multi_byte')
|
||||
" Windows cmd.exe still uses cp850. If Windows ever moved to
|
||||
" 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
|
||||
" Windows has traditionally used cp1252, so it's probably wise to
|
||||
" fallback into cp1252 instead of eg. iso-8859-15.
|
||||
@ -51,7 +53,9 @@ if s:SYSTEM.isWindows
|
||||
endif
|
||||
|
||||
else
|
||||
set termencoding=utf-8
|
||||
if exists('&termencoding') && !has('nvim')
|
||||
set termencoding=utf-8
|
||||
endif
|
||||
set fileencoding=utf-8
|
||||
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
|
||||
endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
scriptencoding utf-8
|
||||
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, and use neomru by default
|
||||
|
@ -6,7 +6,7 @@ Execute ( SpaceVim api: vim#buffer open ):
|
||||
|
||||
Execute ( SpaceVim api: vim#buffer buf_set_lines):
|
||||
let buffer = SpaceVim#api#import('vim#buffer')
|
||||
let nr = bufadd('')
|
||||
let nr = buffer.bufadd('')
|
||||
call setbufvar(nr, '&buftype', 'nofile')
|
||||
call setbufvar(nr, '&buflisted', 0)
|
||||
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']
|
||||
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']
|
||||
exe 'bd!' nr
|
||||
unlet nr
|
||||
unlet buffer
|
||||
|
@ -5,6 +5,3 @@ Execute ( SpaceVim api: SpaceVim main code ):
|
||||
else
|
||||
source vimrc
|
||||
endif
|
||||
let g:spacevim_update_retry_cnt = 0
|
||||
SPInstall
|
||||
AssertEqual fnamemodify(g:_spacevim_root_dir, ':.'), ''
|
||||
|
@ -3,8 +3,8 @@ Execute ( SpaceVim plugin: a.vim ):
|
||||
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/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/cn/api/job.md', root), 'docs/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('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('docs/_posts/2018-09-28-use-vim-as-ide.md', root), 'docs/_posts/2018-09-27-use-vim-as-ide.md'
|
||||
|
Loading…
Reference in New Issue
Block a user