1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-04 03:11:27 +08:00
SpaceVim/autoload/SpaceVim/plugins/projectmanager.vim
2017-12-17 21:22:53 +08:00

74 lines
1.9 KiB
VimL

"=============================================================================
" projectmanager.vim --- project manager for SpaceVim
" Copyright (c) 2016-2017 Shidong Wang & Contributors
" Author: Shidong Wang < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: MIT license
"=============================================================================
" project item:
" {
" "path" : "path/to/root",
" "name" : "name of the project, by default it is name of root directory",
" "type" : "git maven or svn",
" }
"
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
endfunction
function! SpaceVim#plugins#projectmanager#list() abort
endfunction
function! SpaceVim#plugins#projectmanager#current_name() abort
return get(b:, '_spacevim_project_name', '')
endfunction
function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
let project = {
\ 'path' : getcwd(),
\ 'name' : fnamemodify(getcwd(), ':t')
\ }
call s:cache_project(project)
let g:_spacevim_project_name = project.name
let b:_spacevim_project_name = g:_spacevim_project_name
endfunction
function! SpaceVim#plugins#projectmanager#current_root() abort
try
Rooter
catch
endtry
return getcwd()
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
endfunction