Giter VIP home page Giter VIP logo

vim-obsession's Introduction

obsession.vim

Vim features a :mksession command to write a file containing the current state of Vim: window positions, open folds, stuff like that. For most of my existence, I found the interface way too awkward and manual to be useful, but I've recently discovered that the only thing standing between me and simple, no-hassle Vim sessions is a few tweaks:

  • Instead of making me remember to capture the session immediately before exiting Vim, allow me to do it at any time, and automatically re-invoke :mksession immediately before exit.
  • Also invoke :mksession whenever the layout changes (in particular, on BufEnter), so that even if Vim exits abnormally, I'm good to go.
  • If I load an existing session, automatically keep it updated as above.
  • If I try to create a new session on top of an existing session, don't refuse to overwrite it. Just do what I mean.
  • If I pass in a directory rather than a file name, just create a Session.vim inside of it.
  • Don't capture options and maps. Options are sometimes mutilated and maps just interfere with updating plugins.

Use :Obsess (with optional file/directory name) to start recording to a session file and :Obsess! to stop and throw it away. That's it. Load a session in the usual manner: vim -S, or :source it.

There's also an indicator you can put in 'statusline', 'tabline', or 'titlestring'. See :help obsession-status.

Installation

If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/tpope/vim-obsession.git
vim -u NONE -c "helptags vim-obsession/doc" -c q

Self-Promotion

Like obsession.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.

License

Copyright ยฉ Tim Pope. Distributed under the same terms as Vim itself. See :help license.

vim-obsession's People

Contributors

adizero avatar bobrippling avatar noahfrederick avatar prati0100 avatar rsrchboy avatar tpope avatar wilhelmtell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-obsession's Issues

Obsession! does not unlet v:this_session

Since session tracking is stopped and the relevant file deleted, I contend that v:this_session should be unlet.

This is mostly because after running Obsession! the status indicator shows [S], as though there were (paused) tracking.

A different solution would be to remove the v:this_session part of the check from the status line flags, but I imagine part of the idea there was to keep the status line flag visible even when using non-Obsession session files.

Work around bug in vim session storage?

So when vim writes a session it simply does:

open("/home/frew/.vvar/sessions/notes", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 5
write(5, "let SessionLoad = 1\nif &cp | set"..., 1215) = 1215

If there is an OS crash during the write, you can end up with broken sessions (binary sessions are clearly wrong):

$ file * 
apache-logformat-compiler.vim: ASCII text
awesome.vim:                   ASCII text
blog.vim:                      data
dotfiles.vim:                  ASCII text
feedpipe.py:                   ASCII text
keyboard.vim:                  ASCII text
lizard-brain:                  ASCII text
notes:                         ASCII text
PAWS:                          ASCII text
Plack.vim:                     ASCII text
querylog.vim:                  ASCII text
salt.vim:                      ASCII text
zr:                            data

If Obsession (or preferably vim) were to write the session to $session.tmp and then rename it to $session, the updates would be atomic. Any chance this could be a part of Obsession?

Default directory for sessions & default session

Hi Tim,

I like the simplicity of this plugin. But I wanted to see what you have to say about 2 things

  1. Default directory for saving session files.
    • The idea being if I specify one, sessions should be stored in it, otherwise it will stick with the current behavior. What is your opinion on the same ?
  2. Default session.
    • The idea being that we could enable (by setting an option) auto loading of this default session when launching vim. When vim exits, besides writing the session file, we can also update the default session which can just be a symlink to the current session file. Something like this would obviously need to be in a specific directory and hence I guess this feature could also be enabled if the 1st is accepted.

I was originally thinking of just adding this feature but considered taking your opinion on the same. I would be glad to contribute if you think this can be good.

ProTip: start vim with obsession

Hello,

I'd like to share the following sh(1) function that I wrote to "alias" vim so that it starts with obsession, unless there are any arguments provided to vim (in the case of editing a particular file). Just add it to your .profile or .bashrc or .zshrc to use it.

function vim() {
  if test $# -gt 0; then
    env vim "$@"
  elif test -f Session.vim; then
    env vim -S
  else
    env vim -c Obsession
  fi
}

Thanks so much for creating vim obsession! ๐Ÿ’Œ

Documentation of command not correct?

Documentation says:

Use :Obsess (with optional file/directory name) to start recording to a session file and :Obsess! to stop and throw it away. That's it. Load a session in the usual manner: vim -S, or :source it.

But as far as I can tell the command is :Obsession and :Obsession!

Digging this plugin, thanks for sharing!

How about just one working example of new statusline or titlestring?

I like the idea, but don't see how it works.

Let's say I wanted to use an asterisk as my indicator? And add it to the titlestring.

What would I add to .vimrc?

:set titlestring=%t%(\ %M%)%(\ (%F)%)%a\ -\ VIM

And how to add the obsession indicator?

%{ObsessionIndicator('[%s]')}

Save folds even if buffer is closed

Is there a way to have manual folds stored in the session even if one closes the buffer?

I have researched this issue outside of the vim-obsession context but have run into various difficulties, and it would be cool to handle this within the session context, now that I have this plugin.

Is it possible to save `colorscheme` as part of a session?

Tim, thank you a huge bunch for your great plugins!

Question - for vim-obsession

Is it possible to save colorscheme as part of a session?

Actually, I tried even to manually insert colorscheme desert into the Session.vim file.
But ... the colorscheme line had just disappeared after loading the vim with vim -S Session.vim...

Feature Request: Option to save sessions to .vim/session

If it wouldn't be too much trouble, adding an option to save sessions to .vim/session would be useful to users of vim-startify (and potentially to users who want to centralize their sessions) so that we can use the Obsession-style sessions and have them accessible from the vim-startify menu.

Passing Args to `Obsess` Not Working

First off, great plugin. Nice work @tpope! Second, I'm having trouble passing args to the Obsess function (in the event that I need to create a new session with a custom file name).

Is this something to do with vim-obsession, or something else on my end I can fix?

" Obsession {
nmap <Leader>s :call ToggleObsess()<CR>

function! ToggleObsess()
    let d=FindRootDirectory()."/.session.vim"
    if !empty(glob(d))
        " Load previous session
        source d
    else
        " Create new session
        Obsess d
    endif
endfunction
" }

Much appreciated,

Brandon

g:obsession_append

Hi,

I'm using this variable in a plugin I'm working on, I wonder if there can be side-effects in using it. Because if I set it to a value and another script does the same, only the last one would matter. Would it be possible to turn its content to a list, and then append all the contents of the list to the session? So I would retrieve the index of my append and replace it, instead of replacing the whole variable.

Thanks

Tab name

Hi, i'm using taboo to set tab names in a vim session, which aren't restored with obsession. Is it possible to add this feature?
Thanks!

Suggestion: Capture at least some options

Hi Tim:

Don't capture options and maps. Options are sometimes mutilated and maps just interfere with updating plugins.

I agree about mappings, but I think It would be pretty useful to save path and tags, and even allow to pass them as options to :Obsession, that way every session could be more like an IDE project, but ala Vim. What do you think?

there is a issue when my obsession work with loadview

i run vim in ubuntu
in my ~/.vimrc i set

set sessionoptions-=options
set viewoptions=folds,cursor,unix,slash

augroup autosave_buffer
 autocmd!
 autocmd BufWinLeave *.* mkview
 autocmd BufWinEnter *.* silent loadview
augroup END

then i open a file say test.c with fold --> :Obsession -->close vim
--> vim text.c open this file and expand some fold & add some line-->close vim -->vim -S Session.vim open the session.
then there is some error messages display in my terminal

Store the "alternative buffer" in the session

Hello tpope,

I'd like to store the alternative buffer in the session so that I can close vim, open it back up and type <c-^> and automatically switch to the previous buffer that I was using.

I am also using vim-prosession and made a similar issue and dhruvasagar was super kind to help me get working vimrc code that will achieve my goal, but I would love to share this functionality in vim-obsession.

To me, this seems like a relatively harmless addition that just adds a slight UX benefit to using vim-obsession, but you will undoubtably know best.

Here is the code as it currently stands:

" https://github.com/dhruvasagar/vim-prosession/issues/50

function! s:preserve_alt_buffer()
  let l:alternate = fnameescape(expand('#'))
  if !empty(l:alternate)
    call system('echo "let @#=\"'.l:alternate.'\"" >> '.v:this_session)
  endif
endfunction

augroup ProsessionPreserveAlt
  au!

  autocmd VimLeave * call s:preserve_alt_buffer()
augroup END

Just a question about how you guys handle swap files

You see, my Macbook likes to freeze a lot. It's not enough to warrant me to be really upset (for more than a few minutes when it happens, as it averages once every 2 weeks) but it's enough that it gives me reason to set up a plugin such as this one.

Now what happens when I go and re-open with vim -S after my machine dies is that I get a flood of "What should I do with your swap file".

How do you guys deal with this? I find that I usually try to mash D, but this is not really ideal for the reason that if I keep pressing D I will eventually start to erase lines from some buffers.

If I don't mash D, say I Recover with R, I am re-presented with the prompt the next time because Vim is just so nice/dumb. Not to mention R will lead me to replace some letter in some buffer with the r character.

The other obvious reason why mashing D sucks is that I'm just actually choosing to throw away any unsaved buffers.

Honestly this wouldnt be problematic if my goddamned fruit machine will just stop freezing up.

Windows switch slowdown

Depending on IO speed (like a slow disk or inside Windows Subsystem for Linux), Obsession will cause slowdown when switching between windows, because it hits files every time buffers change, it can be quite perceptible, the editor blocking while simply moving window focus. Maybe using async would solve the matter.

Quickfix window isn't restored properly

Much like #5 (NERDTree windows), the Quickfix window becomes a blank when the session is restored. That is, not just the empty quickfix list, but an ordinary empty buffer.

Not a huge issue, but it would be nice to restore it as a quickfix window. For instance, I have <Leader>q mapped to :cclose, and it would be nice if that still worked after loading my session.

Weird error messages never happened before

Weird error messages never happened before.

Messages maintainer: Bram Moolenaar <[email protected]>
Error detected while processing BufEnter Autocommands for "*":
Vim(mksession):E11: Invalid in command-line window; <CR> executes, CTRL-C quits: mksession! /Users/mark/.vim/sessions/\%Users\%mark\%.dot_vim.vim
Press ENTER or type command to continue

reproduce steps

  1. vim -u NONE
  2. q: to open command line window
  3. type :mksession to make a session

my platform

macOS 10.14.6
head version of vim, neovim, macvim

Obsession on bufenter creates a poor fireplace experience

The cq maps from tpope/vim-fireplace create Scratch windows. Without disabling Obsession on BufEnter, these buffers trigger Obsession's mksession, and chaos ensues. The cq mappings will stop working, and you'll get E95 a lot.

The fix is using the g:obsession_no_bufenter variable, but it would be nice to perhaps skip certain buffers like the command line window.

Make sessions executable

It's possible to insert a shebang at the beginning of a vimscript file to specify vim or nvim as the interpreter (ref. :help #!).

What would you think of a patch that added such a shebang to obsession's session files and made the session executable, so that you could start your session with ./session.vim?

Obsession not work automatically when attached to a existing session.

Hi Tim!

When I open a session and do changes and then pause Obsession it doesnt seem to save anything. This can be tested by opening the session after layout changes.

But when I use :Obsession command twice so it says that it stops and track again.. and do some changes and then :Obsession to pause.. it actually saves the changes such as layout etc.

I use

:source ~/.config/nvim/sessions/test

to open the session up.

Not sure how to get logs for this behaviour.

NERD Tree isn't restored properly

This isn't a deal breaker, but if I have NERD Tree open in the main window or another vim tab and then quit out of vim and re-open that session, the split that had NERD Tree in it is just blank. It's easy enough to just close that split and then re-open NERD Tree, but I just thought I'd see if you have any idea if it's possible to actually restore it fully?

If there isn't a way to restore NERD Tree properly, is there a way to close out all the NERD Tree splits automatically when quitting vim perhaps? Maybe that isn't good either, just throwing ideas out.

Thanks much

iskeyword clobbered when restoring

My C++ files end up loading up (when restoring with vim -S or nvim -S) with iskeyword having gained a - which causes problems for various reasons.

What's confusing to me is that the Session.vim file has no mention of iskeyword inside of it. And using verbose set iskeyword? does NOT show me where it got set/changed.

I also acknowledge that this is likely not an error with or caused by obsession... but hopefully someone has a clue for me.

Doubled up files

I'm getting doubled up files when I exit and re-enter Obsession sessions. Not sure if the following is helpful and not sure how to debug.

(Probably related to some combination of key binding / plugin. Feel free to withdraw / backburner this until I've tried reproducing with more vanilla settings.)


$ pwd
/home/jjones/tmp
$ ls
hello.txt
$ cat hello.txt
hello

 1:[hello.txt]  2:[hello.txt]
1   hello

$ grep hello.txt Session.vim
badd +0 ~/tmp/hello.txt
$argadd hello.txt
edit ~/tmp/hello.txt
tabedit ~/tmp/hello.txt
$

$ vv
"~/tmp/hello.txt" "~/tmp/hello.txt" 1L, 6C"~/tmp/hello.txt" 1 line --100%--
Press ENTER or type command to continue

 1:[hello.txt]  2:[hello.txt]  3:[hello.txt]
1   hello

$ grep hello.txt Session.vim
badd +1 ~/tmp/hello.txt
$argadd hello.txt
edit ~/tmp/hello.txt
tabedit ~/tmp/hello.txt
tabedit ~/tmp/hello.txt
$

What vv is (seems simple enough)

$ alias vv
alias vv='_vi'
$ type _vi
_vi is a function
_vi ()
{
    if (( $# == 0 )) && [[ -f Session.vim ]]; then
        vim $jj_vim_options -S Session.vim;
    else
        vim $jj_vim_options "$@";
    fi
}
$ echo $jj_vim_options
-X
$

Session.vim

let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
cd ~/tmp
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
  let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +1 ~/tmp/hello.txt
argglobal
silent! argdel *
$argadd hello.txt
set stal=2
edit ~/tmp/hello.txt
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winminheight=1 winheight=1 winminwidth=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 30) / 61)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabedit ~/tmp/hello.txt
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winminheight=1 winheight=1 winminwidth=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 30) / 61)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabedit ~/tmp/hello.txt
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winminheight=1 winheight=1 winminwidth=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 30) / 61)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 05|
tabnext 2
set stal=1
if exists('s:wipebuf')
  silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToO
set winminheight=1 winminwidth=1
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
  exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
let g:this_session = v:this_session
let g:this_obsession = v:this_session
let g:this_obsession_status = 2
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :


.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

"" VundleBegin
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
""

Plugin 'chrisbra/Recover.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'exu/pgsql.vim'
Plugin 'fatih/vim-go'
Plugin 'flazz/vim-colorschemes'
Plugin 'gregsexton/gitv'
Plugin 'hashivim/vim-vagrant'
Plugin 'heavenshell/vim-pydocstring'
"Plugin 'hynek/vim-python-pep8-indent'
"Plugin 'python-mode/python-mode'
Plugin 'mileszs/ack.vim'
Plugin 'mkitt/tabline.vim'
Plugin 'scrooloose/nerdtree'
"Plugin 'scrooloose/syntastic'
Plugin 'w0rp/ale'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-obsession'
Plugin 'tpope/vim-capslock'
Plugin 'tmux-plugins/vim-tmux'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-scripts/burnttoast256'
Plugin 'guns/xterm-color-table.vim'

""
" All of your Plugins must be added before the following line
call vundle#end()         " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"   filetype plugin on
" :PluginUpdate, :PluginList, :PluginInstall - `!` also update
" :PluginSearch foo - searches for foo, `!` refresh local cache
" :PluginClean - `!` auto-approve
"   see :h vundle for more details or wiki for FAQ
"" EndVundle

" https://github.com/w0rp/ale
filetype plugin on
let &runtimepath.=',~/.vim/bundle/ale'

set background=dark
" http://www.robmeerman.co.uk/unix/256colours
" set term=putty-256color
set term=xterm
set t_Co=256
colorscheme burnttoast256

let g:NERDTreeDirArrows=0
let g:NERDTreeShowHidden=1

let g:airline_powerline_fonts = 1
" Show capslock status in the statusline
let g:airline#extensions#capslock#enabled = 1


let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'

" https://github.com/scrooloose/syntastic#settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set expandtab
set hlsearch
set ignorecase
set ruler               " show cursor position in status line
set shiftwidth=4
set showcmd             " show partial command in status line
set showmatch           " show matching bracket
set smarttab
set softtabstop=4       " no hard tabs
set textwidth=80
set whichwrap=b,s,,>,h,l
set wrap                " wrap lines
set scrolloff=4
set nu

" unix specific
set t_vb= "who needs a visual bell anyway?
set t_te= "stops vim clearing the screen

" :T => new tab, H => left, L => right
command! -nargs=? T :tabnew
map H :tabprev<return>
map L :tabnext<return>

" automatically load Session file
" - if it exists and no file arguments were specified
:if !empty(glob("Session.vim")) && argc() == 0
:   source Session.vim
:endif

map <space>

augroup LoadOnce
    " Prevent progressively slower reloading time of .vimrc
    " http://stackoverflow.com/q/15353988
    autocmd!
    autocmd bufwritepost .vimrc source $MYVIMRC

    autocmd FileType c,cpp,python,ruby,java,sql
        \ autocmd BufWritePre <buffer> :%s/\s\+$//e
    autocmd BufNewFile,BufReadPost *.md set filetype=markdown
    autocmd Filetype gitcommit setlocal spell textwidth=72
augroup END

augroup obsessionfix
    autocmd!
    autocmd SessionLoadPost * silent :Obsession|silent :Obsession
augroup END

set relativenumber
set number
set ttyfast
set clipboard^=unnamed

set mouse=a
map <ScrollWheelUp> <C-U>
map <ScrollWheelDown> <C-D>
" Not sure why these need to be at the end to be respected.
hi CursorLineNr term=bold ctermfg=246 ctermbg=232
hi ColorColumn ctermbg=232
hi LineNr term=bold ctermfg=237 ctermbg=232
set colorcolumn=80

Question: Your opinion about vim-prosession

Hey Tim,

Yesterday I wrote vim-prosession which leverages vim-obsession to allow for autoloading of sessions on launch (in case no arguments were passed to vim) as well as provides a simple command with completion to enable switching between sessions easily. The idea is to use a session per project and you can easily switch sessions when you wish to switch context. This enables cleaner & isolated project sessions that keep buffers & settings that belong only for that project / session.

Wanted to know what your thoughts on the same might be ?

Persist wildignore across sessions

Is there a way to persist wildignore option value throught sessions? I set this one per-project and would like to have it set properly after I load a session for a given project.

I know you've disabled saving options in your plugin, but I wonder if there is another (suggested) way of doing that?

Start `Obsession` on VimEnter

Hi, thanks for making this plugin.

I'd like to "track" sessions for *all* the projects I'm working on, without bothering to invoke :Obsession when starting vim.
I have an autocommand for this:

au VimEnter *
  \ if !exists('g:this_obsession') && expand('%:p') !~# '\.git[\/].*MSG$' |
  \   silent Obsession |
  \ endif

The autocommand tries to avoid firing Obsession when:

  • session is sourced with vim -S
  • vim is opened to write commit messages

But, as I found out yesterday, this is not robust enough as apparently my session got overwritten when git/rebase-merge/git-rebase-todo was opened.

So questions:

  • is there a robust autocommand that properly handles invoking :Obsession for the users?
  • if such holly autocommand exists, does it make sense to put it in vim-obsession? Not "active" by default, but "option activated".

Native Obsession Status?

I find it quite convenient to have Obsession's status showing.

To add the status to my statusline, I use the following function:

function! ObsessionStatus()
  let session = filereadable(v:this_session)
  if exists('g:this_obsession') && session
    return 'tracking'
  elseif session
    return 'paused'
  else
    return ''
  endif
endfunction

And then use the following two maps:

nnoremap go :Obsession<CR>:redraw!<CR>
nnoremap gO :Obsession!<CR>:redraw!<CR>

I'm not too crazy about these maps. I would much rather just hook into Obsession so I can continue to use :O<CR> and :O!<CR>.

I'm also not sure that the redraw!s are the correct solution to getting the status to update. It feels messy but was all I could come up with.

Would you be open to including this in the plugin itself? Obviously the Status function would need to change what it returns. I'm also not 100% sure the logic is sound... I don't handle the exceptional case where g:this_obsession and b:this_session is not set. In any event, I'm looking for a fugitive#status() analogue here.

Thanks!

[Minor/annoyance] README is out of date

This is more of an annoyance than anything, but the README file in the repo and the help doc is out of sync. The README file refers to :Obsess command but the help doc shows it as :Obsession.

Globbing relies on a trailing path separator character

Session name completion doesn't seem to work when the path set in g:prosession_dir doesn't have a trailing path separator.
This "~\vimfiles\sessions\" works while "~\vimfiles\sessions" doesn't.
Changing line 68 to:

    let flist = glob(g:prosession_dir . flead . '/*.vim', 0, 1)

seems to solve it.(Disclaimer: very little Vimscript skills)

Persist `winfixwidth`

Is there a way to configure this plugin, or the Vim session functionality it builds upon, to persist winfixwidth on my windows? This is the only aspect of my layouts that don't get restored. From my searching, there doesn't seem to be a way to tell Vim what settings to save.

Persist NetRW/vim-vinegar splits?

Not sure if I'm missing an option, but I did get my sessions working exactly how I'd like them so far, except that NetRW/vim-vinegar splits are not persisted. This is certainly doesn't break my workflow, but wanted to make sure you were aware of it or see if there's just an option I need to include.

Suggestion: rename Session.vim to .session.vim

Hi Tim,

Was wondering if it would make more sense to change the generic filename to .session.vim instead of Session.vim. I realize there's a way to customize the filename for myself, but was thinking this could be applied more generically with the plugin and is more in-line with dot file convention. Thanks for this plugin.

winheight cannot be smaller than winminheight

Nice plugin!

I have these settings in my .vimrc courtesy of Gary Bernhardt's Destroy All Software screencast series.

set winwidth=84
" We have to have a winheight bigger than we want to set winminheight. But if
" we set winheight to be huge before winminheight, the winminheight set will
" fail.
set winheight=5
set winminheight=5
set winheight=999

When I go to load up a saved session I receive the following error:

Screen Shot 2013-03-12 at 1 05 14 PM

I'm not sure what is setting winheight=1, but that isn't in my .vimrc. Is that something this plugin is setting? It doesn't seem like it matters much, the sessions load fine, but it's obviously an eye sore / slow to have it error out each time I load up a saved session.

Thanks for taking a look!

REQUEST: Save vimwiki history per window

In vimwiki there is a forward/reverse feature to navigate your history of wikipages.

Is it possible to save and restore this history? This would save some time when drafting a document that uses a wiki for notes.

E:190 cannot open "file" for writting

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 21 2020 16:11:23)
Included patches: 1-814
Compiled by Arch Linux
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +clipboard +dnd +gettext +listcmds -mouse_sysmouse +postscript +spell +textobjects +wildignore
+arabic +cmdline_compl -ebcdic -hangul_input +localmap +mouse_urxvt +printer +startuptime +textprop +wildmenu
+autocmd +cmdline_hist +emacs_tags +iconv +lua/dyn +mouse_xterm +profile +statusline +timers +windows
+autochdir +cmdline_info +eval +insert_expand +menu +multi_byte +python/dyn -sun_workshop +title +writebackup
-autoservername +comments +ex_extra +ipv6 +mksession +multi_lang +python3/dyn +syntax +toolbar +X11
+balloon_eval +conceal +extra_search +job +modify_fname -mzscheme +quickfix +tag_binary +user_commands -xfontset
+balloon_eval_term +cryptv -farsi +jumplist +mouse +netbeans_intg +reltime -tag_old_static +vartabs +xim
+browse +cscope +file_in_path +keymap +mouseshape +num64 +rightleft -tag_any_white +vertsplit -xpm
++builtin_terms +cursorbind +find_in_path +lambda +mouse_dec +packages +ruby/dyn +tcl/dyn +virtualedit +xsmp_interact
+byte_offset +cursorshape +float +langmap +mouse_gpm +path_extra +scrollbind +termguicolors +visual +xterm_clipboard
+channel +dialog_con_gui +folding +libcall -mouse_jsbterm +perl/dyn +signs +terminal +visualextra -xterm_save
+cindent +diff -footer +linebreak +mouse_netterm +persistent_undo +smartindent +terminfo +viminfo
+clientserver +digraphs +fork() +lispindent +mouse_sgr +popupwin +sound +termresponse +vreplace
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "/etc/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "
/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/
include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/inc
lude/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -march=x86-64 -mtune=generic -O2
-pipe -fno-plt -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-co
mmon,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0
-lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort
-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.32/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz
-lpthread -lm

tagbar

Dear developer,
if 'set sessionsoptions-=blank' is used, tagbar (https://github.com/majutsushi/tagbar) is
not restored on reloading the session...
Below I attached a diff -u with the needed change to fix this issue,

best C.

--- obsession_orig.vim	2019-07-28 09:38:50.000000000 +0200
+++ obsession.vim	2019-07-28 09:39:00.000000000 +0200
@@ -73,7 +73,9 @@
   let sessionoptions = &sessionoptions
   if exists('g:this_obsession')
     try
-      set sessionoptions-=blank sessionoptions-=options sessionoptions+=tabpages
+      "tagbar is considered a blank windows by vim and thus it is not reopened if -=blank is used
+      set sessionoptions-=options sessionoptions+=tabpages
+      "set sessionoptions-=blank sessionoptions-=options sessionoptions+=tabpages
       execute 'mksession! '.fnameescape(g:this_obsession)
       let body = readfile(g:this_obsession)
       call insert(body, 'let g:this_session = v:this_session', -3)

cannot store filenames starting with tilda

I do not know if this repo is the root cause of this issue. I use neovim 0.2.2

When opening a file whose path starts with tilda (the home dir) e.g. ~/file1.md on a buffer, closing vim and opening it again, vim opens the buffer as empty complaining that file1.md does not exist. The buffer list at the vim plugin 'bufexplorer' also does not have the tilda after closing and opening vim.

In other words, it seams that the session cannot store filenames starting with tilda.

I am new to vim so here is my vimrc. If I can narrow down the issue and provide something more concrete to identify which plugin is the root cause, let me know.

"""""""""""""""" Avoid having to press two keys (shift-;) to enter a command
nmap ; :

"""""""""""""""" Speedups based on http://jeff560.tripod.com/words7.html
" avoid hh and uu as h is used for navigation u for undo
inoremap jj <Esc>
" in case of multiple windows (which should be avoided) it opens the active buffer into a new tab allowing you to see the buffer in the whole vim window until you close the tab. The buffer remains also in the previous tab.
nnoremap vv :tab split<CR>
nnoremap qq :q<CR>
" specific to vim-bookmarks
nnoremap ww :BookmarkToggle
nnoremap xx :BookmarkShowAll
" available shortcuts that can be done with one hand and are easy to remember
"nnoremap yy :q<CR>
" specific to bufexplorer
nnoremap <silent> ww :BufExplorer<CR>


"""""""""""""""" Manage size of workspace
" for vertical split in HP: set lines=60 columns=101

"""""""""""""""" Manage tab key in insert mode
filetype plugin indent on
set tabstop=2                " show existing tab with 2 spaces width
set shiftwidth=2             " when indenting with '>', use the same number of spaces width
set expandtab                " on pressing tab, insert the same number of spaces


"""""""""""""""" Manage colors and syntax highlighting
color desert                 " has a better color of comments


"""""""""""""""" Customize vim
set nowritebackup " https://github.com/ember-cli/ember-cli/issues/5311#issuecomment-170383075
set number


"""""""""""""""" Customize plugins

" specific to Taboo
hi TabLineFill term=bold cterm=bold ctermbg=0
hi TabLine ctermfg=Yellow
set sessionoptions+=tabpages,globals
cabbrev tr TabooRename

" specific to CtrlP
set wildignore+=*/node_modules/*

" specific to vim-bookmarks
let g:bookmark_no_default_key_mappings = 1
let g:bookmark_save_per_working_dir = 1

" specific to bufexplorer
let g:bufExplorerShowRelativePath=0
let g:bufExplorerShowTabBuffer=1
let g:bufExplorerSortBy='fullpath'

" specific to buffergator
let g:buffergator_suppress_keymaps = 1
nmap <tab> :BuffergatorMruCycleNext<cr>
nmap <s-tab> :BuffergatorMruCyclePrev<cr>
set hidden " https://github.com/neovim/neovim/issues/2368#issuecomment-323680533
let g:buffergator_viewport_split_policy = 'n'
let g:buffergator_autoupdate = 1
let g:buffergator_sort_regime = 'filepath'

" specific to prosession
let g:prosession_per_branch = 1


"""""""""""""""" Customize neovim if any and install plugin manager
if has("nvim")
  tnoremap jj <C-\><C-n>
  " switch between terminal splits
  tnoremap <A-h> <C-\><C-n><C-w>h
  tnoremap <A-j> <C-\><C-n><C-w>j
  tnoremap <A-k> <C-\><C-n><C-w>k
  tnoremap <A-l> <C-\><C-n><C-w>l
  " switch between non-terminal splits
  nnoremap <A-h> <C-w>h
  nnoremap <A-j> <C-w>j
  nnoremap <A-k> <C-w>k
  nnoremap <A-l> <C-w>l
  " More natural splits
  set splitbelow          " Horizontal split below current.
  set splitright          " Vertical split to right of current.

  if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) " installs plugins-manager if not installed
    silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  endif
else
  if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  endif
endif


"""""""""""""""" Manage plugins
call plug#begin()

" for text editing
Plug 'gcmt/taboo.vim'
Plug 'ctrlpvim/ctrlp.vim'

Plug 'jlanzarotta/bufexplorer'
Plug 'jeetsukumaran/vim-buffergator'

Plug 'tpope/vim-obsession'         " needed for the next
Plug 'dhruvasagar/vim-prosession'  " loads obsession on vim startup

if has('nvim')
  Plug 'mklabs/split-term.vim'
endif

" for programming
Plug 'tpope/vim-projectionist'     " :A moves to the alternate file stated at .projections.json of the repo
Plug 'MattesGroeger/vim-bookmarks'
Plug 'AndrewRadev/ember_tools.vim' " Pressing gf on a specific line will open the corresponding file

call plug#end()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.