1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 10:40:04 +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#layers#load('core#tabline')
call SpaceVim#mapping#space#def('nnoremap', ['p', 't'], 'Rooter', 'find-project-root', 1) 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', '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 let lnum = expand('<slnum>') + s:lnum - 1
if has('python3') if has('python3')
let cmd = 'Denite file_rec' let cmd = 'Denite file_rec'

View File

@ -18,18 +18,34 @@
let s:project_paths = {} let s:project_paths = {}
function! s:cache_project(prj) abort function! s:cache_project(prj) abort
if !has_key(s:project_paths, a:prj.path) if !has_key(s:project_paths, a:prj.path)
let s:project_paths[a:prj.path] = a:prj let s:project_paths[a:prj.path] = a:prj
endif 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 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 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 endfunction
function! SpaceVim#plugins#projectmanager#current_name() abort function! SpaceVim#plugins#projectmanager#current_name() abort
return get(b:, '_spacevim_project_name', '') return get(b:, '_spacevim_project_name', '')
endfunction endfunction
function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
@ -54,18 +70,18 @@ endfunction
let s:BUFFER = SpaceVim#api#import('vim#buffer') let s:BUFFER = SpaceVim#api#import('vim#buffer')
function! SpaceVim#plugins#projectmanager#kill_project() abort function! SpaceVim#plugins#projectmanager#kill_project() abort
let name = get(b:, '_spacevim_project_name', '') let name = get(b:, '_spacevim_project_name', '')
if name != '' if name != ''
call s:BUFFER.filter_do( call s:BUFFER.filter_do(
\ { \ {
\ 'expr' : [ \ 'expr' : [
\ 'buflisted(v:val)', \ 'buflisted(v:val)',
\ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"', \ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"',
\ ], \ ],
\ 'do' : 'bd %d' \ 'do' : 'bd %d'
\ } \ }
\ ) \ )
endif endif
endfunction endfunction