dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 83dd9b39381fac7c76093b1ba8fc53d379c3123a
parent eeef00bfc82a0bca82036be891d752d1c72519f4
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Tue, 30 Jul 2019 17:14:04 +0200

vim: reorganised the sessions plugin

Former-commit-id: 6f5bd582bbdce6da116a2eddcba3d0c8ffb57d6b
Diffstat:
Mvim/autoload/sessions.vim | 25+++++++++++--------------
Avim/plugin/sessions.vim | 10++++++++++
Mvim/vimrc | 6++++++
3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/vim/autoload/sessions.vim b/vim/autoload/sessions.vim @@ -1,25 +1,23 @@ -" Custom session management (should be plugin) {{{ +let s:seshdir = $HOME.'/.vim/sessions/' function! sessions#SaveSession() abort - let seshdir = $HOME.'/.vim/sessions/' - silent call mkdir (seshdir, 'p') + silent call mkdir (s:seshdir, 'p') let name = input("Save as: ") if name == "" echo "\nNo name provided." else - let seshfile = seshdir.name.".vim" + let seshfile = s:seshdir.name.".vim" execute "mksession! " . seshfile echo "\nSession saved: ".seshfile endif endfunction -function! sessions#ListSessions() abort - let seshdir = $HOME.'/.vim/sessions/' - silent call mkdir (seshdir, 'p') - let files = globpath(seshdir, '*', 0, 1) +function! s:ListSessions() abort + silent call mkdir (s:seshdir, 'p') + let files = globpath(s:seshdir, '*', 0, 1) call filter(files, '!isdirectory(v:val)') return files endfunction -function! sessions#ChooseSession() abort - let files = ListSessions() +function! s:ChooseSession() abort + let files = <SID>ListSessions() if len(files) > 0 let inputfiles = map(copy(files), 'index(files, v:val)+1.": ".v:val') let response = inputlist(inputfiles) @@ -34,7 +32,7 @@ function! sessions#ChooseSession() abort endif endfunction function! sessions#LoadSession() abort - let session = ChooseSession() + let session = <SID>ChooseSession() if session != "" execute 'source '.session else @@ -42,7 +40,7 @@ function! sessions#LoadSession() abort endif endfunction function! sessions#DeleteSession() abort - let sesh = ChooseSession() + let sesh = <SID>ChooseSession() if sesh == "" echo "\nNo session selected" return 1 @@ -61,9 +59,8 @@ endfunction function! sessions#CloseSession() bufdo! bwipeout cd - if g:loaded_tagbar == 1 + if exists('g:loaded_tagbar') && g:loaded_tagbar == 1 execute "TagbarClose" endif echom "Session closed." endfunction -" }}} diff --git a/vim/plugin/sessions.vim b/vim/plugin/sessions.vim @@ -0,0 +1,10 @@ +if exists("g:loaded_sessions") || &cp + finish +endif + +let g:loaded_sessions = 1 + +noremap <silent> <unique> <script> <Plug>SaveSession :call sessions#SaveSession()<CR> +noremap <silent> <unique> <script> <Plug>LoadSession :call sessions#LoadSession()<CR> +noremap <silent> <unique> <script> <Plug>DeleteSession :call sessions#DeleteSession()<CR> +noremap <silent> <unique> <script> <Plug>CloseSession :call sessions#CloseSession()<CR> diff --git a/vim/vimrc b/vim/vimrc @@ -212,6 +212,12 @@ let g:vimwiki_list = [wiki] let g:vimwiki_global_ext = 0 let g:vimwiki_ext2syntax = {'.wiki': 'default'} " }}} +" Sessions {{{ +nmap <leader>ss <Plug>SaveSession +nmap <leader>sl <Plug>LoadSession +nmap <leader>sd <Plug>DeleteSession +nmap <leader>sq <Plug>CloseSession +" }}} set omnifunc=syntaxcomplete#Complete " }}}