aboutsummaryrefslogtreecommitdiff
path: root/vim/.vim/autoload/dyamon/session.vim
blob: 3934ebdfbb54640635b1f7039a919876c44e9b82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
" Autoload functions to handle (native/Obsession) sessions
" Last Changed: 2021-10-26
" Author: Federico Igne <>
" License: This file is placed in the public domain.

function! dyamon#session#new(...) abort
    " If Obsession cmd is availble use it (fallback to `mksession`)
    let l:cmd = exists(':Obsession') ? 'Obsession' : 'mksession!'
    " If no argument is provided, the default session name is the
    " current working directory.
    let l:default = $VIM_SESSIONS . '/' .
                  \ substitute(fnamemodify(getcwd(),':t'), '\v^\.', '', '') .
                  \ '.vim'
    let l:session = get(a:, 1, l:default)
    " Create new session (or load existing one).
    execute l:cmd . ' ' . l:session
endfunction