1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:30:04 +08:00

Add callback for projectmanager

This commit is contained in:
wsdjeg 2017-12-24 21:58:39 +08:00
parent d1e112baed
commit dbefd008fe
3 changed files with 41 additions and 2 deletions

View File

@ -51,7 +51,9 @@ function! SpaceVim#layers#lang#c#plugins() abort
call add(plugins, ['tweekmonster/deoplete-clang2'])
endif
elseif g:spacevim_autocomplete_method ==# 'ycm'
" no need extra plugins
elseif g:spacevim_autocomplete_method ==# 'completor'
" no need extra plugins
elseif g:spacevim_autocomplete_method ==# 'asyncomplete'
else
call add(plugins, ['Rip-Rip/clang_complete'])
@ -63,6 +65,10 @@ endfunction
function! SpaceVim#layers#lang#c#config() abort
call SpaceVim#plugins#runner#reg_runner('c', ['gcc -o #TEMP# %s', '#TEMP#'])
call SpaceVim#mapping#space#regesit_lang_mappings('c', funcref('s:language_specified_mappings'))
call SpaceVim#plugins#projectmanager#reg_callback(funcref('s:update_clang_flag'))
if filereadable('.clang')
call s:update_clang_flag()
endif
endfunction
function! SpaceVim#layers#lang#c#set_variable(var) abort
@ -84,3 +90,7 @@ function! s:language_specified_mappings() abort
\ 'execute current file', 1)
endfunction
function! s:update_clang_flag() abort
endfunction

View File

@ -48,15 +48,28 @@ function! SpaceVim#plugins#projectmanager#current_name() abort
return get(b:, '_spacevim_project_name', '')
endfunction
" this func is called when vim-rooter change the dir, That means the project
" is changed, so will call call the registered function.
function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort
let project = {
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
for callback in s:project_callback
call call(callback, [])
endfor
endfunction
let s:project_callback = []
function! SpaceVim#plugins#projectmanager#reg_callback(func) abort
if type(a:func) == 2
call add(s:project_callback, a:func)
else
call SpaceVim#logger#warn('can not register the project callback: ' . string(a:func))
endif
endfunction
function! SpaceVim#plugins#projectmanager#current_root() abort

View File

@ -6,6 +6,22 @@ function! SpaceVim#util#globpath(path, expr) abort
endif
endfunction
function! SpaceVim#util#findFileInParent(what, where) abort
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let file = findfile(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return file
endfunction
function! SpaceVim#util#findDirInParent(what, where) abort
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let dir = finddir(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return dir
endfunction
function! SpaceVim#util#echoWarn(msg) abort
echohl WarningMsg
echo a:msg