diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 4bad3e0b0..bf9fa42ba 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -12,6 +12,7 @@ function! SpaceVim#layers#core#config() abort call SpaceVim#layers#load('core#statusline') call SpaceVim#layers#load('core#tabline') call SpaceVim#mapping#space#def('nnoremap', ['p', 't'], 'Rooter', 'find-project-root', 1) + call SpaceVim#mapping#space#def('nnoremap', ['p', 'k'], 'call SpaceVim#plugins#projectmanager#kill_project()', 'kill all project buffers', 1) call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], 'CtrlP', 'find files in current project', 1) call SpaceVim#mapping#space#def('nnoremap', ['p', '/'], 'Grepper', 'fuzzy search for text in current project', 1) endfunction diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index 933da10a8..c64d6347d 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -15,7 +15,6 @@ " - let s:project_paths = {} function! s:cache_project(prj) abort @@ -27,7 +26,28 @@ endfunction function! SpaceVim#plugins#projectmanager#list() abort - +endfunction + +function! SpaceVim#plugins#projectmanager#current_() + return get(b:, '_spacevim_project_name', '') +endfunction + +let s:BUFFER = SpaceVim#api#import('vim#buffer') + +function! SpaceVim#plugins#projectmanager#kill_project() abort + let name = get(b:, '_spacevim_project_name', '') + if name != '' + call s:BUFFER.filter_do( + \ { + \ 'expr' : [ + \ 'buflisted(v:val)', + \ 'index(tabpagebuflist(), v:val) == -1', + \ 'getbufvar(v:val, "_spacevim_project_name") == ' . name, + \ ], + \ 'do' : 'bd %d' + \ } + \ ) + endif endfunction