Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
167 lines
4.5 KiB
VimL
167 lines
4.5 KiB
VimL
"=============================================================================
|
|
" FILE: buffer.vim
|
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
|
" License: MIT license
|
|
"=============================================================================
|
|
|
|
let s:save_cpo = &cpo
|
|
set cpo&vim
|
|
|
|
function! unite#kinds#buffer#define() abort "{{{
|
|
return s:kind
|
|
endfunction"}}}
|
|
|
|
let s:kind = {
|
|
\ 'name' : 'buffer',
|
|
\ 'default_action' : 'open',
|
|
\ 'action_table': {},
|
|
\ 'parents': ['file'],
|
|
\}
|
|
|
|
" Actions "{{{
|
|
let s:kind.action_table.open = {
|
|
\ 'description' : 'open buffer',
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.open.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
if bufexists(candidate.action__buffer_nr)
|
|
execute 'buffer' candidate.action__buffer_nr
|
|
endif
|
|
endfor
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.goto = {
|
|
\ 'description' : 'goto buffer tab',
|
|
\ }
|
|
function! s:kind.action_table.goto.func(candidate) abort "{{{
|
|
for i in range(tabpagenr('$'))
|
|
let tabnr = i + 1
|
|
for nr in tabpagebuflist(tabnr)
|
|
if nr == a:candidate.action__buffer_nr
|
|
execute 'tabnext' tabnr
|
|
execute bufwinnr(nr) 'wincmd w'
|
|
|
|
" Jump to the first.
|
|
return
|
|
endif
|
|
endfor
|
|
endfor
|
|
execute 'buffer' a:candidate.action__buffer_nr
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.delete = {
|
|
\ 'description' : 'delete from buffer list',
|
|
\ 'is_invalidate_cache' : 1,
|
|
\ 'is_quit' : 0,
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.delete.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
call s:delete('bdelete', candidate)
|
|
endfor
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.fdelete = {
|
|
\ 'description' : 'force delete from buffer list',
|
|
\ 'is_invalidate_cache' : 1,
|
|
\ 'is_quit' : 0,
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.fdelete.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
call s:delete('bdelete!', candidate)
|
|
endfor
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.wipeout = {
|
|
\ 'description' : 'wipeout from buffer list',
|
|
\ 'is_invalidate_cache' : 1,
|
|
\ 'is_quit' : 0,
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.wipeout.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
call s:delete('bwipeout', candidate)
|
|
endfor
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.unload = {
|
|
\ 'description' : 'unload from buffer list',
|
|
\ 'is_invalidate_cache' : 1,
|
|
\ 'is_quit' : 0,
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.unload.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
call s:delete('unload', candidate)
|
|
endfor
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.preview = {
|
|
\ 'description' : 'preview buffer',
|
|
\ 'is_quit' : 0,
|
|
\ }
|
|
function! s:kind.action_table.preview.func(candidate) abort "{{{
|
|
call unite#view#_preview_file(a:candidate.action__path)
|
|
|
|
let filetype = getbufvar(a:candidate.action__buffer_nr, '&filetype')
|
|
if filetype != ''
|
|
let winnr = winnr()
|
|
execute bufwinnr(a:candidate.action__buffer_nr) . 'wincmd w'
|
|
execute 'setfiletype' filetype
|
|
execute winnr . 'wincmd w'
|
|
endif
|
|
endfunction"}}}
|
|
|
|
let s:kind.action_table.rename = {
|
|
\ 'description' : 'rename buffers',
|
|
\ 'is_invalidate_cache' : 1,
|
|
\ 'is_quit' : 0,
|
|
\ 'is_selectable' : 1,
|
|
\ }
|
|
function! s:kind.action_table.rename.func(candidates) abort "{{{
|
|
for candidate in a:candidates
|
|
if getbufvar(candidate.action__buffer_nr, '&buftype') =~ 'nofile'
|
|
" Skip nofile buffer.
|
|
continue
|
|
endif
|
|
|
|
let old_buffer_name = bufname(candidate.action__buffer_nr)
|
|
let buffer_name = input(printf('New buffer name: %s -> ', old_buffer_name), old_buffer_name)
|
|
if buffer_name == '' || buffer_name ==# old_buffer_name
|
|
continue
|
|
endif
|
|
|
|
call unite#kinds#file#do_rename(old_buffer_name, buffer_name)
|
|
endfor
|
|
endfunction"}}}
|
|
"}}}
|
|
|
|
" Misc
|
|
function! s:delete(delete_command, candidate) abort "{{{
|
|
" Not to close window, move to alternate buffer.
|
|
|
|
let winnr = 1
|
|
while winnr <= winnr('$')
|
|
if winbufnr(winnr) == a:candidate.action__buffer_nr
|
|
execute winnr . 'wincmd w'
|
|
call unite#util#alternate_buffer()
|
|
|
|
let unite_winnr = bufwinnr(unite#get_current_unite().bufnr)
|
|
if unite_winnr > 0
|
|
execute unite_winnr 'wincmd w'
|
|
endif
|
|
endif
|
|
|
|
let winnr += 1
|
|
endwhile
|
|
|
|
silent execute a:candidate.action__buffer_nr a:delete_command
|
|
endfunction"}}}
|
|
|
|
let &cpo = s:save_cpo
|
|
unlet s:save_cpo
|
|
|
|
" vim: foldmethod=marker
|