1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-23 12:31:32 +08:00
SpaceVim/autoload/SpaceVim/layers/ui.vim

223 lines
7.7 KiB
VimL
Raw Normal View History

2017-01-14 19:49:19 +08:00
scriptencoding utf-8
function! SpaceVim#layers#ui#plugins() abort
2017-05-16 22:14:38 +08:00
let plugins = [
2017-01-14 19:49:19 +08:00
\ ['Yggdroot/indentLine'],
\ ['majutsushi/tagbar', {'loadconf' : 1}],
\ ['tenfyzhong/tagbar-makefile.vim', {'merged': 0}],
\ ['tenfyzhong/tagbar-proto.vim', {'merged': 0}],
2017-02-02 00:55:16 +08:00
\ ['lvht/tagbar-markdown',{'merged' : 0}],
2017-04-09 21:53:54 +08:00
\ ['t9md/vim-choosewin', {'merged' : 0}],
2017-01-14 20:14:14 +08:00
\ ['mhinz/vim-startify', {'loadconf' : 1}],
\ ['blueyed/vim-diminactive', {'merged' : 0}],
2017-01-14 19:49:19 +08:00
\ ]
2017-05-16 22:14:38 +08:00
if get(g:, '_spacevim_statusline_loaded', 0) == 0
call add(plugins, ['vim-airline/vim-airline', { 'merged' : 0,
2017-05-19 23:29:46 +08:00
\ 'loadconf' : 1}])
2017-05-16 22:14:38 +08:00
call add(plugins, ['vim-airline/vim-airline-themes', { 'merged' : 0}])
endif
return plugins
2017-01-14 19:49:19 +08:00
endfunction
function! SpaceVim#layers#ui#config() abort
let g:indentLine_color_term = get(g:, 'indentLine_color_term', 239)
let g:indentLine_color_gui = get(g:, 'indentLine_color_gui', '#09AA08')
let g:indentLine_char = get(g:, 'indentLine_char', '¦')
let g:indentLine_concealcursor = 'niv'
let g:indentLine_conceallevel = 2
2017-01-14 19:49:19 +08:00
let g:indentLine_fileTypeExclude = ['help', 'startify', 'vimfiler']
let g:signify_disable_by_default = 0
let g:signify_line_highlight = 0
noremap <silent> <F2> :silent TagbarToggle<CR>
2017-04-18 23:55:34 +08:00
" Ui toggles
call SpaceVim#mapping#space#def('nnoremap', ['t', '8'], 'call call('
\ . string(s:_function('s:toggle_fill_column')) . ', [])',
\ 'toggle-colorcolumn', 1)
2017-05-01 20:00:43 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'b'], 'call ToggleBG()',
\ 'toggle background', 1)
2017-05-12 21:56:04 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 't'], 'call SpaceVim#plugins#tabmanager#open()',
\ 'Open tabs manager', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'f'], 'call call('
\ . string(s:_function('s:toggle_colorcolumn')) . ', [])',
\ 'toggle-colorcolumn', 1)
2017-05-01 13:44:43 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'h', 'h'], 'set cursorline!',
\ 'toggle highlight of the current line', 1)
2017-05-01 14:23:15 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'h', 'i'], 'call call('
\ . string(s:_function('s:toggle_indentline')) . ', [])',
2017-08-29 05:55:27 +08:00
\ ['toggle highlight indentation levels',
\ [
\ 'SPC t h i is to running :IndentLinesToggle which is definded in indentLine'
\ ]
\ ], 1)
2017-05-01 14:32:00 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'h', 'c'], 'set cursorcolumn!',
\ 'toggle highlight indentation current column', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'h', 's'], 'call call('
\ . string(s:_function('s:toggle_syntax_hi')) . ', [])',
\ 'toggle syntax highlighting', 1)
call SpaceVim#mapping#space#def('nnoremap', ['T', 'F'], '<F11>',
\ 'fullscreen-frame', 0)
call SpaceVim#mapping#space#def('nnoremap', ['T', 'm'], 'call call('
\ . string(s:_function('s:toggle_menu_bar')) . ', [])',
2017-05-02 20:53:41 +08:00
\ 'toggle-menu-bar', 1)
2017-05-02 22:22:27 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['T', 'f'], 'call call('
\ . string(s:_function('s:toggle_win_fringe')) . ', [])',
\ 'toggle-win-fringe', 1)
2017-05-02 20:53:41 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['T', 't'], 'call call('
\ . string(s:_function('s:toggle_tool_bar')) . ', [])',
\ 'toggle-tool-bar', 1)
2017-05-01 20:17:02 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['T', '~'], 'call call('
\ . string(s:_function('s:toggle_end_of_buffer')) . ', [])',
2017-05-01 20:34:59 +08:00
\ 'display ~ in the fringe on empty lines', 1)
2017-05-15 23:22:54 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 's'], 'call call('
\ . string(s:_function('s:toggle_syntax_checker')) . ', [])',
\ 'toggle syntax checker', 1)
2017-05-19 23:29:46 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'S'], 'call call('
\ . string(s:_function('s:toggle_spell_check')) . ', [])',
2017-10-06 02:25:35 +08:00
\ 'toggle spell checker', 1)
2017-05-23 22:56:31 +08:00
call SpaceVim#mapping#space#def('nnoremap', ['t', 'w'], 'call call('
\ . string(s:_function('s:toggle_whitespace')) . ', [])',
\ 'toggle the whitespace', 1)
2017-04-18 23:55:34 +08:00
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
2017-05-01 20:17:02 +08:00
function! s:_function(fstr) abort
return function(a:fstr)
endfunction
2017-04-18 23:55:34 +08:00
else
2017-05-01 20:17:02 +08:00
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
2017-04-18 23:55:34 +08:00
endif
2017-04-22 20:38:00 +08:00
let s:tmflag = 0
2017-04-18 23:55:34 +08:00
function! s:toggle_menu_bar() abort
2017-04-22 20:38:00 +08:00
if !s:tmflag
set go+=m
let s:tmflag = 1
else
set go-=m
let s:tmflag = 0
endif
2017-01-14 19:49:19 +08:00
endfunction
2017-05-02 20:53:41 +08:00
let s:ttflag = 0
function! s:toggle_tool_bar() abort
if !s:ttflag
set go+=T
let s:ttflag = 1
else
set go-=T
let s:ttflag = 0
endif
endfunction
let s:ccflag = 0
function! s:toggle_colorcolumn() abort
if !s:ccflag
set cc=80
let s:ccflag = 1
else
set cc=
let s:ccflag = 0
endif
2017-05-17 20:24:45 +08:00
call SpaceVim#layers#core#statusline#toggle_mode('fill-column-indicator')
endfunction
let s:fcflag = 0
function! s:toggle_fill_column() abort
2017-05-01 14:23:15 +08:00
if !s:fcflag
2017-05-15 23:22:54 +08:00
let &colorcolumn=join(range(80,999),',')
2017-05-01 14:23:15 +08:00
let s:fcflag = 1
else
2017-05-01 13:44:43 +08:00
set cc=
2017-05-01 14:23:15 +08:00
let s:fcflag = 0
endif
2017-05-17 20:24:45 +08:00
call SpaceVim#layers#core#statusline#toggle_mode('hi-characters-for-long-lines')
2017-05-01 14:23:15 +08:00
endfunction
let s:idflag = 0
function! s:toggle_indentline() abort
if !s:idflag
IndentLinesDisable
let s:idflag = 1
else
IndentLinesEnable
let s:idflag = 0
endif
endfunction
2017-05-01 14:32:00 +08:00
let s:shflag = 0
function! s:toggle_syntax_hi() abort
if !s:shflag
syntax off
let s:shflag = 1
else
syntax on
let s:shflag = 0
endif
endfunction
2017-05-01 20:17:02 +08:00
let s:ebflag = 0
2017-05-01 22:54:09 +08:00
let s:HI = SpaceVim#api#import('vim#highlight')
2017-05-01 20:17:02 +08:00
function! s:toggle_end_of_buffer() abort
if !s:ebflag
if &background ==# 'dark'
2017-05-01 20:34:59 +08:00
hi EndOfBuffer guifg=white
2017-05-01 20:17:02 +08:00
else
2017-05-01 20:34:59 +08:00
hi EndOfBuffer guifg=gray
2017-05-01 20:17:02 +08:00
endif
let s:ebflag = 1
else
if (exists('+termguicolors') && &termguicolors) || has('gui_running')
2017-05-01 22:54:09 +08:00
let normalbg = s:HI.group2dict('Normal').guibg
2017-05-01 20:17:02 +08:00
else
2017-05-01 22:54:09 +08:00
let normalbg = s:HI.group2dict('Normal').ctermbg
2017-05-01 20:17:02 +08:00
endif
2017-05-01 22:54:09 +08:00
exe 'hi! EndOfBuffer guifg=' . normalbg . ' guibg=' . normalbg
2017-05-01 20:17:02 +08:00
let s:ebflag = 0
endif
endfunction
2017-05-02 22:22:27 +08:00
let s:tfflag = 0
function! s:toggle_win_fringe() abort
if !s:tfflag
set guioptions+=L
set guioptions+=r
let s:tfflag = 1
else
set guioptions-=L
set guioptions-=r
let s:tfflag = 0
endif
endfunction
2017-05-15 23:22:54 +08:00
function! s:toggle_syntax_checker() abort
2017-05-19 23:29:46 +08:00
call SpaceVim#layers#core#statusline#toggle_section('syntax checking')
call SpaceVim#layers#core#statusline#toggle_mode('syntax-checking')
verbose NeomakeToggle
2017-05-15 23:22:54 +08:00
endfunction
2017-05-19 23:29:46 +08:00
function! s:toggle_spell_check() abort
if &l:spell
let &l:spell = 0
else
let &l:spell = 1
endif
call SpaceVim#layers#core#statusline#toggle_mode('spell-checking')
2017-10-06 03:03:28 +08:00
if &l:spell == 1
echo 'spell-checking enabled.'
else
echo 'spell-checking disabled.'
endif
2017-05-19 23:29:46 +08:00
endfunction
2017-05-23 22:56:31 +08:00
function! s:toggle_whitespace() abort
call SpaceVim#layers#core#statusline#toggle_section('whitespace')
call SpaceVim#layers#core#statusline#toggle_mode('whitespace')
endfunction