mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-24 08:05:51 +08:00
[adopt] vim-themis
This commit is contained in:
parent
5d7e656081
commit
8681d4d49e
52
.github/workflows/ci.yml
vendored
52
.github/workflows/ci.yml
vendored
|
@ -3,10 +3,10 @@ name: CI
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
@ -14,38 +14,26 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
vim_version:
|
||||
- 'v8.2.2000'
|
||||
- 'v8.2.1000'
|
||||
- 'v8.2.0000'
|
||||
- 'v8.1.0000'
|
||||
- 'v8.0.0000'
|
||||
- 'v7.4'
|
||||
|
||||
vim:
|
||||
- v8.2.1000
|
||||
- v8.2.0000
|
||||
- v8.1.0000
|
||||
- v8.0.0000
|
||||
- v7.4
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout vim-themis
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ruby-version: '3.0'
|
||||
|
||||
- name: Setup Bundle
|
||||
run: |
|
||||
gem install bundler
|
||||
bundle install --jobs 4 --retry 3
|
||||
|
||||
repository: thinca/vim-themis
|
||||
path: vim-themis
|
||||
- name: Setup Vim
|
||||
uses: thinca/action-setup-vim@v1
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
id: vim
|
||||
with:
|
||||
vim_version: ${{ matrix.vim_version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
curl -f -L "https://raw.githubusercontent.com/vim-airline/vim-airline-themes/master/autoload/airline/themes/simple.vim" -o autoload/airline/themes/simple.vim
|
||||
curl -f -L "https://raw.githubusercontent.com/vim-airline/vim-airline-themes/master/autoload/airline/themes/molokai.vim" -o autoload/airline/themes/molokai.vim
|
||||
mkdir colors && curl -f -L 'https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim' -o colors/molokai.vim
|
||||
|
||||
- name: Run Test
|
||||
run: rake ci
|
||||
version: ${{ matrix.vim }}
|
||||
- name: Test
|
||||
env:
|
||||
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
|
||||
run: ./vim-themis/bin/themis --reporter spec
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,4 +5,4 @@ doc/tags
|
|||
*.swp
|
||||
.bundle
|
||||
vendor
|
||||
|
||||
test/.deps
|
||||
|
|
28
test/.themisrc
Normal file
28
test/.themisrc
Normal file
|
@ -0,0 +1,28 @@
|
|||
let s:helper = themis#helper('assert')
|
||||
let s:deps = themis#helper('deps')
|
||||
|
||||
call themis#helper('command').with(s:helper)
|
||||
call s:deps.git('vim-airline/vim-airline-themes')
|
||||
call s:deps.git('tomasr/molokai')
|
||||
|
||||
function! MyFuncref(...)
|
||||
call a:1.add_raw('hello world')
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! MyIgnoreFuncref(...)
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! MyAppend1(...)
|
||||
call a:1.add_raw('hello')
|
||||
endfunction
|
||||
|
||||
function! MyAppend2(...)
|
||||
call a:1.add_raw('world')
|
||||
endfunction
|
||||
|
||||
let g:airline#extensions#default#layout = [
|
||||
\ [ 'c', 'a', 'b', 'warning' ],
|
||||
\ [ 'x', 'z', 'y' ]
|
||||
\ ]
|
64
test/airline.vimspec
Normal file
64
test/airline.vimspec
Normal file
|
@ -0,0 +1,64 @@
|
|||
Describe airline.vim
|
||||
Before
|
||||
let g:airline_statusline_funcrefs = []
|
||||
End
|
||||
|
||||
It should run user funcrefs first
|
||||
call airline#add_statusline_func('MyFuncref')
|
||||
let &statusline = ''
|
||||
call airline#update_statusline()
|
||||
Assert Match(airline#statusline(1), 'hello world')
|
||||
End
|
||||
|
||||
It should not change the statusline with -1
|
||||
call airline#add_statusline_funcref(function('MyIgnoreFuncref'))
|
||||
let &statusline = 'foo'
|
||||
call airline#update_statusline()
|
||||
Assert Equals(&statusline, 'foo')
|
||||
End
|
||||
|
||||
It should support multiple chained funcrefs
|
||||
call airline#add_statusline_func('MyAppend1')
|
||||
call airline#add_statusline_func('MyAppend2')
|
||||
call airline#update_statusline()
|
||||
Assert Match(airline#statusline(1), 'helloworld')
|
||||
End
|
||||
|
||||
It should allow users to redefine sections
|
||||
let g:airline_section_a = airline#section#create(['mode', 'mode'])
|
||||
call airline#update_statusline()
|
||||
Assert Match(airline#statusline(1), '%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#%#airline_a_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#')
|
||||
End
|
||||
|
||||
It should remove funcrefs properly
|
||||
let c = len(g:airline_statusline_funcrefs)
|
||||
call airline#add_statusline_func('MyIgnoreFuncref')
|
||||
call airline#remove_statusline_func('MyIgnoreFuncref')
|
||||
Assert Equals(len(g:airline_statusline_funcrefs), c)
|
||||
End
|
||||
|
||||
It should overwrite the statusline with active and inactive splits
|
||||
wincmd s
|
||||
Assert NotMatch(airline#statusline(1), 'inactive')
|
||||
Assert Match(airline#statusline(2), 'inactive')
|
||||
wincmd c
|
||||
End
|
||||
|
||||
It should collapse the inactive split if the variable is set true
|
||||
let g:airline_inactive_collapse = 1
|
||||
wincmd s
|
||||
Assert NotMatch(getwinvar(2, '&statusline'), 'airline#parts#mode')
|
||||
wincmd c
|
||||
end
|
||||
|
||||
It should collapse the inactive split if the variable is set false
|
||||
let g:airline_inactive_collapse = 0
|
||||
wincmd s
|
||||
Assert NotEquals(getwinvar(2, '&statusline'), 'airline#parts#mode')
|
||||
wincmd c
|
||||
End
|
||||
|
||||
It should include check_mode
|
||||
Assert Match(airline#statusline(1), 'airline#check_mode')
|
||||
End
|
||||
End
|
107
test/builder.vimspec
Normal file
107
test/builder.vimspec
Normal file
|
@ -0,0 +1,107 @@
|
|||
Describe builder.vim
|
||||
Describe active builder
|
||||
Before each
|
||||
let s:builder = airline#builder#new({'active': 1})
|
||||
End
|
||||
|
||||
It should start with an empty statusline
|
||||
let stl = s:builder.build()
|
||||
Assert Equals(stl, '')
|
||||
End
|
||||
|
||||
It should transition colors from one to the next
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
call s:builder.add_section('Search', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl,'%#Normal#hello%#Normal_to_Search#%#Search#world')
|
||||
End
|
||||
|
||||
|
||||
It 'should reuse highlight group if background colors match'
|
||||
highlight Foo1 ctermfg=1 ctermbg=2
|
||||
highlight Foo2 ctermfg=1 ctermbg=2
|
||||
call s:builder.add_section('Foo1', 'hello')
|
||||
call s:builder.add_section('Foo2', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Foo1#helloworld')
|
||||
End
|
||||
|
||||
|
||||
It should switch highlight groups if foreground colors differ
|
||||
highlight Foo1 ctermfg=1 ctermbg=2
|
||||
highlight Foo2 ctermfg=2 ctermbg=2
|
||||
call s:builder.add_section('Foo1', 'hello')
|
||||
call s:builder.add_section('Foo2', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Foo1#hello%#Foo1_to_Foo2#%#Foo2#world')
|
||||
End
|
||||
|
||||
It should split left/right sections
|
||||
call s:builder.split()
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%=')
|
||||
End
|
||||
|
||||
It after split, sections use the right separator
|
||||
call s:builder.split()
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
call s:builder.add_section('Search', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'hello%#Normal_to_Search#%#Search#world')
|
||||
End
|
||||
|
||||
It should not repeat the same highlight group
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Normal#hellohello')
|
||||
End
|
||||
|
||||
It should replace accent groups with the specified group
|
||||
call s:builder.add_section('Normal', '%#__accent_foo#hello')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Normal#%#Normal_foo#hello')
|
||||
End
|
||||
|
||||
It should replace two accent groups with correct groups
|
||||
call s:builder.add_section('Normal', '%#__accent_foo#hello%#__accent_bar#world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Normal_foo#hello%#Normal_bar#world')
|
||||
End
|
||||
|
||||
It should special restore group should go back to previous group
|
||||
call s:builder.add_section('Normal', '%#__restore__#')
|
||||
let stl = s:builder.build()
|
||||
Assert NotMatch(stl, '%#__restore__#')
|
||||
Assert Match(stl, '%#Normal#')
|
||||
End
|
||||
|
||||
It should blend colors from the left through the split to the right
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
call s:builder.split()
|
||||
call s:builder.add_section('Search', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'Normal_to_Search')
|
||||
End
|
||||
End
|
||||
|
||||
Describe inactive builder
|
||||
Before each
|
||||
let s:builder = airline#builder#new({'active': 0})
|
||||
End
|
||||
|
||||
It should transition colors from one to the next
|
||||
call s:builder.add_section('Normal', 'hello')
|
||||
call s:builder.add_section('Search', 'world')
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, '%#Normal_inactive#hello%#Normal_to_Search_inactive#%#Search_inactive#world')
|
||||
End
|
||||
|
||||
It should not render accents
|
||||
call s:builder.add_section('Normal', '%#__accent_foo#hello%#foo#foo%#__accent_bar#world')
|
||||
let stl = s:builder.build()
|
||||
Assert Equals(stl, '%#Normal_inactive#hello%#foo_inactive#fooworld')
|
||||
End
|
||||
End
|
||||
|
||||
End
|
50
test/commands.vimspec
Normal file
50
test/commands.vimspec
Normal file
|
@ -0,0 +1,50 @@
|
|||
Describe commands.vim
|
||||
|
||||
It should toggle off and on
|
||||
execute 'AirlineToggle'
|
||||
Assert False(exists('#airline'))
|
||||
execute 'AirlineToggle'
|
||||
Assert True(exists('#airline'))
|
||||
End
|
||||
|
||||
It should toggle whitespace off
|
||||
call airline#extensions#load()
|
||||
execute 'AirlineToggleWhitespace'
|
||||
Assert False(exists('#airline_whitespace'))
|
||||
End
|
||||
|
||||
It should toggle whitespace on
|
||||
call airline#extensions#load()
|
||||
execute 'AirlineToggleWhitespace'
|
||||
Assert True(exists('#airline_whitespace'))
|
||||
End
|
||||
|
||||
It should display theme name "simple"
|
||||
execute 'AirlineTheme simple'
|
||||
Assert Equals(g:airline_theme, 'simple')
|
||||
End
|
||||
|
||||
It should display theme name "dark"'
|
||||
execute 'AirlineTheme dark'
|
||||
Assert Equals(g:airline_theme, 'dark')
|
||||
End
|
||||
|
||||
It should display theme name "dark" because specifying a name that does not exist
|
||||
execute 'AirlineTheme doesnotexist'
|
||||
Assert Equals(g:airline_theme, 'dark')
|
||||
End
|
||||
|
||||
It should display theme name molokai
|
||||
colors molokai
|
||||
Assert Equals(g:airline_theme, 'molokai')
|
||||
End
|
||||
|
||||
It should have a refresh command
|
||||
Assert Equals(exists(':AirlineRefresh'), 2)
|
||||
End
|
||||
|
||||
It should have a extensions command
|
||||
Assert Equals(exists(':AirlineExtensions'), 2)
|
||||
End
|
||||
|
||||
End
|
47
test/extensions_default.vimspec
Normal file
47
test/extensions_default.vimspec
Normal file
|
@ -0,0 +1,47 @@
|
|||
Describe extensions_default.vim
|
||||
Before
|
||||
let g:airline#extensions#default#layout = [
|
||||
\ [ 'c', 'a', 'b', 'warning' ],
|
||||
\ [ 'x', 'z', 'y' ]
|
||||
\ ]
|
||||
|
||||
let s:builder = airline#builder#new({'active': 1})
|
||||
End
|
||||
|
||||
It should use the layout airline_a_to_airline_b
|
||||
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'airline_c_to_airline_a')
|
||||
end
|
||||
|
||||
It should use the layout airline_a_to_airline_b
|
||||
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'airline_a_to_airline_b')
|
||||
End
|
||||
|
||||
It should use the layout airline_b_to_airline_warning
|
||||
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'airline_b_to_airline_warning')
|
||||
end
|
||||
|
||||
it should use the layout airline_x_to_airline_z
|
||||
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'airline_x_to_airline_z')
|
||||
end
|
||||
|
||||
it should use the layout airline_z_to_airline_y
|
||||
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||
let stl = s:builder.build()
|
||||
Assert Match(stl, 'airline_z_to_airline_y')
|
||||
end
|
||||
|
||||
it should only render warning section in active splits
|
||||
wincmd s
|
||||
Assert Match(airline#statusline(1), 'warning')
|
||||
Assert NotMatch(airline#statusline(2), 'warning')
|
||||
wincmd c
|
||||
end
|
||||
end
|
17
test/extensions_tabline.vimspec
Normal file
17
test/extensions_tabline.vimspec
Normal file
|
@ -0,0 +1,17 @@
|
|||
Describe extensions_tabline.vim
|
||||
Before all
|
||||
:%bd
|
||||
End
|
||||
|
||||
It should use a tabline
|
||||
e! file1
|
||||
Assert Match(airline#extensions#tabline#get(), '%#airline_tabsel# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) |%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill# buffers' )
|
||||
End
|
||||
|
||||
It Trigger on BufDelete autocommands
|
||||
e! file1
|
||||
sp file2
|
||||
bd
|
||||
Assert Match(airline#extensions#tabline#get(), '%#airline_tabsel# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) |%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill# buffers' )
|
||||
End
|
||||
End
|
28
test/highlighter.vimspec
Normal file
28
test/highlighter.vimspec
Normal file
|
@ -0,0 +1,28 @@
|
|||
Describe highlighter.vim
|
||||
It should create separator highlight groups
|
||||
hi highlighter1 ctermfg=1 ctermbg=2
|
||||
hi highlighter2 ctermfg=3 ctermbg=4
|
||||
call airline#highlighter#add_separator('highlighter1', 'highlighter2', 0)
|
||||
let hl = airline#highlighter#get_highlight('highlighter1_to_highlighter2')
|
||||
Assert Equal([ 'NONE', 'NONE', '4', '2', '' ], hl)
|
||||
End
|
||||
|
||||
if exists("+termguicolors")
|
||||
It should create separator highlight groups with termguicolors
|
||||
set termguicolors
|
||||
hi highlighter1 guifg=#cd0000 guibg=#00cd00 ctermfg=1 ctermbg=2
|
||||
hi highlighter2 guifg=#cdcd00 guibg=#0000ee ctermfg=3 ctermbg=4
|
||||
call airline#highlighter#add_separator('highlighter1', 'highlighter2', 0)
|
||||
let hl = airline#highlighter#get_highlight('highlighter1_to_highlighter2')
|
||||
Assert Equal(['#0000ee', '#00cd00', '4', '2', '' ], hl)
|
||||
End
|
||||
endif
|
||||
|
||||
It should populate accent colors
|
||||
Assert False(exists('g:airline#themes#dark#palette.normal.airline_c_red'))
|
||||
call airline#themes#patch(g:airline#themes#dark#palette)
|
||||
call airline#highlighter#add_accent('red')
|
||||
call airline#highlighter#highlight(['normal'])
|
||||
Assert NotEqual(0, hlID('airline_c_red'))
|
||||
End
|
||||
End
|
Loading…
Reference in New Issue
Block a user