diff --git a/plugin/SimpleWorkspaces.vim b/plugin/SimpleWorkspaces.vim index 51411f5..0439b61 100644 --- a/plugin/SimpleWorkspaces.vim +++ b/plugin/SimpleWorkspaces.vim @@ -4,17 +4,21 @@ endif let did_load_simpleworkspaces = 1 -if !exists('g:workspace_prefix') - let g:workspace_prefix = $HOME.'/.cache/vim_workspaces' +if !exists('g:SimpleWorkspaces#prefix') + let g:SimpleWorkspaces#prefix = $HOME.'/.cache/vim_workspaces' endif -if !exists('g:last_workspace_path') - let g:last_workspace_path = $HOME.'/.vim_last_workspace' +if !exists('g:SimpleWorkspaces#last_workspace') + let g:SimpleWorkspaces#last_workspace = $HOME.'/.vim_last_workspace' +endif + +if !exists('g:SimpleWorkspaces#manual_save_path') + let g:SimpleWorkspaces#manual_save_path = $HOME.'/.vim/saved_workspaces' endif function! s:RestoreWorkspace() - if g:open_previous_workspace > 0 && filereadable(g:last_workspace_path) - let l:workspace_path = readfile(g:last_workspace_path) + if g:SimpleWorkspaces#open_previous > 0 && filereadable(g:SimpleWorkspaces#last_workspace) + let l:workspace_path = readfile(g:SimpleWorkspaces#last_workspace) call SimpleWorkspaces#open(l:workspace_path[0]) endif endfunction @@ -23,12 +27,13 @@ command! -nargs=? -complete=file WorkspaceInit call SimpleWorkspaces#init('') command! -nargs=? -complete=file WorkspaceDelete call SimpleWorkspaces#rm('') command! -nargs=? -complete=custom,s:AvailableWorkspaces WorkspaceOpen call SimpleWorkspaces#open('') +command! -nargs=? -complete=file WorkspaceSave call SimpleWorkspaces#save('') command! -nargs=0 WorkspaceQuit call SimpleWorkspaces#quit() function! s:AvailableWorkspaces(a,b,c) - if isdirectory(g:workspace_prefix) + if isdirectory(g:SimpleWorkspaces#prefix) let l:workspace_names = [] - for workspace in split(globpath(g:workspace_prefix, '*'), '\n') + for workspace in split(globpath(g:SimpleWorkspaces#prefix, '*'), '\n') call add(l:workspace_names, substitute(workspace, '\v.*/(.*)$', '\1', &gd ? 'gg' : 'g')) endfor return join(l:workspace_names, "\n") @@ -36,7 +41,7 @@ function! s:AvailableWorkspaces(a,b,c) return '' endfunction -if exists('g:open_previous_workspace') +if exists('g:SimpleWorkspaces#open_previous') call s:RestoreWorkspace() endif