Closed llinfeng closed 4 years ago
@llinfeng I think that's a fair expectation. I can work on adding support for configuring excluded / ignored paths.
As for now, you could either simply start vim with vim index.wiki
and that would skip loading the session. If you want to use g:prosession_on_startup
, you should set it to 0
to disable session loading on startup. <- in reference to your autocmd above.
Thank you for your quick reply. Looking forward to the option to exclude/ignore paths.
RE: setting g:prosession_on_startup
to 0 using autocmd
--- I forget to update the post above. Switching it to 0 did not help vim +VimwikiMakeDiaryNote
to start without loading from the saved session files.
One personal solution based on my habit of quitting session using a Z
mapping in normal mode:
autocmd BufRead,BufNewFile */Wiki/Warehouse/** nnoremap Z :wall!<CR>:ProsessionDelete<CR>:qa<CR>
autocmd BufRead,BufNewFile */AHK_Scripts/** nnoremap Z :wall!<CR>:ProsessionDelete<CR>:qa<CR>
@llinfeng Yes actually BufRead
or even VimEnter
autocmds execute after vim has done loading everything, including loading prosession plugin, so it wouldn't be able to affect prosession's session loading.
You could do something like vim +let\ g:prosession_on_startup=0
on a directory you don't want prosession to kick in and that should work.
@llinfeng On testing I found that the above mentioned method does not work, again because that runs after vimrc has been loaded.
This is the right solution :
$ vim --cmd "let g:prosession_on_startup=0"
Thanks a lot! I have updated my Autohotkey scripts so that they will be launching Gvim with the --cmd "let g:prosession_on_startup=0"
argument.
gvim +VimwikiMakeDiaryNote --cmd "let g:prosession_on_startup=0"
runs out of the box, assuming the folder containing gvim.exe
is added to the PATH
environmental variable.Closing the issue as I can always start a Prosession-free Vim session by vim --cmd "let g:prosession_on_startup=0"
. Creating an alias for *NIX and adjusting however one starts his/her Gvim sessions shall suffice.
I came up with the following zsh
function as a working alternative, where vim
is remapped so that:
# This is a simple zsh function that remaps `vim` to be aware of where it is called
# Note, the "$1" piece is necessary to have.
function vim() {
if test $(pwd) = "/home/username"; then
# excluding the home dir
/usr/bin/vim --cmd "let g:prosession_on_startup=0" $1
elif [ $(pwd) = "/home/username/Yet_another_dir" ]; then
# excluding another dir
/usr/bin/vim --cmd "let g:prosession_on_startup=0" $1
# more directories can be added here :)
else
/usr/bin/vim $1
fi
}
@dhruvasagar An option like g:prosession_no_auto_start_dir
would be a more elegant solution.
May I exclude certain directories from auto-loading/saving with Prosession? I host a personal wiki using Vimwiki and browse/edit files in
~/Wiki/Warehouse
on an hourly basis. I prefer to disable Prosession completely for these files.For now,
vim +VimwikiMakeDiaryNote
is not considered as a way of "starting Vim with an argument". The+VimwikiMakeDiaryNote
flag is intended to open up the diary wiki of the day. However, after putting onvim-prosession
,vim +VimwikiMakeDiaryNote
will faithfully load what has been the last view of the session from a day before :)I put the following line towards the end of my
~/.vimrc
. It did not help. I guess sessions must have been sourced earlier?Thanks a lot!