Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
new command WorkspaceSave
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyorst committed Aug 13, 2018
1 parent 8b03325 commit 56a15fb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions plugin/SimpleWorkspaces.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,20 +27,21 @@ command! -nargs=? -complete=file WorkspaceInit call SimpleWorkspaces#init('<args
command! -nargs=? -complete=file WorkspaceAdd call SimpleWorkspaces#add('<args>')
command! -nargs=? -complete=file WorkspaceDelete call SimpleWorkspaces#rm('<args>')
command! -nargs=? -complete=custom,s:AvailableWorkspaces WorkspaceOpen call SimpleWorkspaces#open('<args>')
command! -nargs=? -complete=file WorkspaceSave call SimpleWorkspaces#save('<args>')
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")
endif
return ''
endfunction

if exists('g:open_previous_workspace')
if exists('g:SimpleWorkspaces#open_previous')
call s:RestoreWorkspace()
endif

0 comments on commit 56a15fb

Please sign in to comment.