split out change directory logic from LoadProject() into ProjectCD()
This commit is contained in:
parent
2dc95f6585
commit
83273d0524
13
vimrc
13
vimrc
@ -103,7 +103,8 @@ if has("autocmd")
|
|||||||
\ exe "normal! g`\"" |
|
\ exe "normal! g`\"" |
|
||||||
\ endif
|
\ endif
|
||||||
|
|
||||||
autocmd BufEnter * call LoadProject()
|
autocmd BufWinEnter * call LoadProject()
|
||||||
|
autocmd BufEnter * call ProjectCD()
|
||||||
endif " has("autocmd")
|
endif " has("autocmd")
|
||||||
|
|
||||||
"==============================================================================
|
"==============================================================================
|
||||||
@ -118,14 +119,12 @@ function! LoadProject()
|
|||||||
let projfile = findfile("project.vim", ".;")
|
let projfile = findfile("project.vim", ".;")
|
||||||
if projfile != ""
|
if projfile != ""
|
||||||
let b:project_directory = fnamemodify(projfile, ":p:h")
|
let b:project_directory = fnamemodify(projfile, ":p:h")
|
||||||
silent! exec "cd " . b:project_directory
|
|
||||||
exec "source " . fnameescape(projfile)
|
exec "source " . fnameescape(projfile)
|
||||||
let b:project_loaded = 1
|
let b:project_loaded = 1
|
||||||
else
|
else
|
||||||
let projdir = finddir("project.vim", ".;")
|
let projdir = finddir("project.vim", ".;")
|
||||||
if projdir != ""
|
if projdir != ""
|
||||||
let b:project_directory = fnamemodify(projdir, ":p:h:h")
|
let b:project_directory = fnamemodify(projdir, ":p:h:h")
|
||||||
silent! exec "cd " . b:project_directory
|
|
||||||
for f in split(glob(projdir . '/*.vim'), '\n')
|
for f in split(glob(projdir . '/*.vim'), '\n')
|
||||||
exec 'source ' . fnameescape(f)
|
exec 'source ' . fnameescape(f)
|
||||||
endfor
|
endfor
|
||||||
@ -134,6 +133,14 @@ function! LoadProject()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" ProjectCD - Change to the project directory
|
||||||
|
" for some reason doing this in LoadProject() didn't work on Windows
|
||||||
|
function! ProjectCD()
|
||||||
|
if exists("b:project_directory")
|
||||||
|
exec "cd " . fnameescape(b:project_directory)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! FindSymbolInSources(sources, ...)
|
function! FindSymbolInSources(sources, ...)
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
let sym = a:1
|
let sym = a:1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user