Skip to content

Examples

Zhaosheng Pan edited this page Feb 25, 2022 · 13 revisions

coc-explorer, vista.vim and undotree:

coc-explorer: https://github.com/weirongxu/coc-explorer

Vista.vim: https://github.com/liuchengxu/vista.vim

Undotree: https://github.com/mbbill/undotree

let g:vista_sidebar_position = 'vertical topleft'
let g:vista_sidebar_width = 40
let g:undotree_SetFocusWhenToggle = 1
let g:undotree_SplitWidth = 40

let g:sidebars = {
  \ 'coc-explorer': {
  \     'position': 'left',
  \     'check_win': {nr -> getwinvar(nr, '&filetype') ==# 'coc-explorer'},
  \     'open': 'CocCommand explorer --no-toggle',
  \     'close': 'CocCommand explorer --toggle'
  \ },
  \ 'vista': {
  \     'position': 'left',
  \     'check_win': {nr -> bufname(winbufnr(nr)) =~ '__vista__'},
  \     'open': 'Vista',
  \     'close': 'Vista!'
  \ },
  \ 'undotree': {
  \     'position': 'left',
  \     'check_win': {nr -> getwinvar(nr, '&filetype') ==# 'undotree'},
  \     'open': 'UndotreeShow',
  \     'close': 'UndotreeHide'
  \ }
  \ }

noremap <silent> <M-1> :call sidebar#toggle('coc-explorer')<CR>
noremap <silent> <M-2> :call sidebar#toggle('vista')<CR>
noremap <silent> <M-3> :call sidebar#toggle('undotree')<CR>

quickfix, loclist and vim-terminal-help:

vim-terminal-help: https://github.com/skywind3000/vim-terminal-help

autocmd FileType qf call s:setup_quickfix_window()
function! s:setup_quickfix_window()
    wincmd J
    10wincmd _
    setlocal wrap foldcolumn=0 colorcolumn= signcolumn=no cursorline
    nnoremap <silent> <buffer> q <C-w>q
endfunction

let g:sidebars = {
  \ 'quickfix': {
  \     'position': 'bottom',
  \     'check_win': {nr -> getwinvar(nr, '&filetype') ==# 'qf' && !getwininfo(win_getid(nr))[0]['loclist']},
  \     'open': 'copen',
  \     'close': 'cclose'
  \ },
  \ 'loclist': {
  \     'position': 'bottom',
  \     'check_win': {nr -> getwinvar(nr, '&filetype') ==# 'qf' && getwininfo(win_getid(nr))[0]['loclist']},
  \     'open': 'silent! lopen',
  \     'close': 'silent! lclose'
  \ },
  \ 'terminal': {
  \     'position': 'bottom',
  \     'check_win': {-> exists('t:__terminal_bid__') ? bufwinnr(t:__terminal_bid__) : 0},
  \     'open': 'call TerminalOpen()',
  \     'close': 'call TerminalClose()'
  \ }
  \ }

noremap <silent> <M-6> :call sidebar#toggle('quickfix')<CR>
noremap <silent> <M-7> :call sidebar#toggle('loclist')<CR>
noremap <silent> <M-=> :call sidebar#toggle('terminal')<CR>
if has('nvim')
    tnoremap <silent> <M-6> <C-\><C-n>:call sidebar#toggle('quickfix')<CR>
    tnoremap <silent> <M-7> <C-\><C-n>:call sidebar#toggle('loclist')<CR>
    tnoremap <silent> <M-=> <C-\><C-n>:call sidebar#toggle('terminal')<CR>
else
    tnoremap <silent> <M-6> <C-_>:call sidebar#toggle('quickfix')<CR>
    tnoremap <silent> <M-7> <C-_>:call sidebar#toggle('loclist')<CR>
    tnoremap <silent> <M-=> <C-_>:call sidebar#toggle('terminal')<CR>
endif
Clone this wiki locally