Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ If you don't want ``Welcome`` to appear when you start vim:
let g:project_enable_welcome = 0
" if you want the NERDTree integration.
let g:project_use_nerdtree = 1
" if you want to suppress the gui title changes
let g:project_enable_title_change = 0

set rtp+=~/.vim/bundle/vim-project/
call project#rc("~/Code")
Expand Down
18 changes: 11 additions & 7 deletions autoload/project.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ command! -nargs=0 -bar Welcome
\ enew | call project#config#welcome()

if has("gui_running")
function! TabTitle()
let title = expand("%:p:t")
let t:title = exists("b:title") ? b:title : title
endfunction

au VimEnter * set guitablabel=%-2.2N%{gettabvar(v:lnum,'title')}
set title
function! TabTitle()
if get(g:, 'project_enable_title_change', 1)
let title = expand("%:p:t")
let t:title = exists("b:title") ? b:title : title
endif
endfunction

if get(g:, 'project_enable_title_change', 1)
au VimEnter * set guitablabel=%-2.2N%{gettabvar(v:lnum,'title')}
set title
endif
endif

if get(g:, 'project_enable_welcome', 1)
Expand Down
20 changes: 18 additions & 2 deletions autoload/project/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let s:pos = 0
function! s:full_path(arg) abort
let arg = substitute(a:arg, '\v\C/+$', '', '')
let arg = resolve(fnamemodify(arg, ":p"))
let arg = substitute(arg, '\v\C/+$', '', '')
let arg = substitute(arg, '\v\C\\+$', '', '')
return arg
endfunction
Expand Down Expand Up @@ -64,6 +65,19 @@ function! project#config#project_path(arg, ...) abort
endif
endfunction

function! s:callbackString(title) abort
let project = s:projects[a:title]
let type = project["type"]
let callbacks = project["callbacks"]
let retval = []
if len(callbacks) > 0
for callback in callbacks
call add(retval, 'execute "call '.callback.'(\"'.a:title.'\")"')
endfor
endif
return join(retval, " \\| ")
endfunction

function! s:callback(title) abort
let project = s:projects[a:title]
let type = project["type"]
Expand Down Expand Up @@ -133,14 +147,16 @@ function! project#config#welcome() abort
if v["type"] == "project"
let file = v["project"]
let lcd = " \\| lcd ".v["project"]
let callback = " \\| " . s:callbackString(v["title"])
else
let file = v["event"]
let lcd = ""
let callback = ""
endif
let line = printf(printf(' ['. cnt .']'.padding.'%s '.file, '%-'.max_title_length.'s'), v["title"])
call append('$', line)
if get(g:, 'project_use_nerdtree', 0) && isdirectory(file)
execute 'nnoremap <silent><buffer> '. cnt .' :enew \| NERDTree '. s:escape(file).lcd."<cr>"
execute 'nnoremap <silent><buffer> '. cnt .' :enew '.lcd.callback.' \| NERDTree '. s:escape(file)."<cr>"
else
execute 'nnoremap <silent><buffer> '. cnt .' :edit '. s:escape(file).lcd."<cr>"
endif
Expand Down Expand Up @@ -210,7 +226,7 @@ function! s:setup() abort
endif
execute autocmd
endfor
if has("gui_running")
if has("gui_running") && get(g:, 'project_enable_title_change', 1)
au BufEnter,BufRead,WinEnter * call TabTitle()
au BufEnter,BufRead,WinEnter * let &titlestring = getcwd()
endif
Expand Down