1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 08:30:06 +08:00

Add key bindings for list projects

This commit is contained in:
wsdjeg 2017-12-17 21:57:02 +08:00
parent ea732fae96
commit 861914d339
2 changed files with 33 additions and 16 deletions

View File

@ -16,6 +16,7 @@ function! SpaceVim#layers#core#config() abort
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', 'p'], 'call SpaceVim#plugins#projectmanager#list()', 'List all projects', 1)
let lnum = expand('<slnum>') + s:lnum - 1
if has('python3')
let cmd = 'Denite file_rec'

View File

@ -18,18 +18,34 @@
let s:project_paths = {}
function! s:cache_project(prj) abort
if !has_key(s:project_paths, a:prj.path)
let s:project_paths[a:prj.path] = a:prj
endif
if !has_key(s:project_paths, a:prj.path)
let s:project_paths[a:prj.path] = a:prj
let desc = '[' . a:prj.name . '] ' . a:prj.path
let cmd = 'call SpaceVim#plugins#projectmanager#open("' . a:prj.path . '")'
call add(g:unite_source_menu_menus.Projects.command_candidates, [desc,cmd])
endif
endfunction
let g:unite_source_menu_menus =
\ get(g:,'unite_source_menu_menus',{})
let g:unite_source_menu_menus.Projects = {'description':
\ 'Custom mapped keyboard shortcuts [SPC] p p'}
let g:unite_source_menu_menus.Projects.command_candidates =
\ get(g:unite_source_menu_menus.Projects,'command_candidates', [])
function! SpaceVim#plugins#projectmanager#list() abort
Unite menu:Projects
endfunction
function! SpaceVim#plugins#projectmanager#open(project) abort
let path = s:project_paths[a:project]['path']
tabnew
exe 'lcd ' . path
Startify | VimFiler
endfunction
function! SpaceVim#plugins#projectmanager#current_name() abort
return get(b:, '_spacevim_project_name', '')
return get(b:, '_spacevim_project_name', '')
endfunction
function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
@ -54,18 +70,18 @@ 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)',
\ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"',
\ ],
\ 'do' : 'bd %d'
\ }
\ )
endif
let name = get(b:, '_spacevim_project_name', '')
if name != ''
call s:BUFFER.filter_do(
\ {
\ 'expr' : [
\ 'buflisted(v:val)',
\ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"',
\ ],
\ 'do' : 'bd %d'
\ }
\ )
endif
endfunction