xolox / vim-session

Extended session management for Vim (:mksession on steroids)
http://peterodding.com/code/vim/session/
961 stars 80 forks source link

Persist markers into session? #180

Open eduardoarandah opened 5 years ago

eduardoarandah commented 5 years ago

I’ve been looking all over the place to save/load my markers in a session instead of globally (which I find pretty dumb tbh)

So, let’s say I have an “I” marker for the info.txt in each project, doesn’t mix with the info.txt in another project.

I’ve read that :wv and :rv let you create a viminfo file in another location. And that’s exactly what I want to happen when I have a session.

Is this possible?

If so, would you consider integrating it? I’d like to contribute but have no idea about vimscript 😅

eduardoarandah commented 5 years ago

This provides a great idea to create a viminfo file that autosaves/autoloads with same name as the session:

https://vi.stackexchange.com/questions/17091/can-capitalized-marks-be-saved-in-session-instead-of-viminfo/17093#17093

command! -bang -complete=file -nargs=? Mksession mksession<bang> <args> |
      \ let [s:viminfofile, s:viminfo] = [&viminfofile, &viminfo] |
      \ try |
      \   let [&viminfofile, &viminfo] = [v:this_session . '.viminfo', 'f'] |
      \   wviminfo! |
      \ finally |
      \   let [&viminfofile, &viminfo] = [s:viminfofile, s:viminfo] |
      \ endtry

augroup ViminfoSessionRestore
  autocmd!
  autocmd SessionLoadPost * |
        \ let [s:viminfofile, s:viminfo] = [&viminfofile, &viminfo] |
        \ try |
        \   let [&viminfofile, &viminfo] = [v:this_session . '.viminfo', 'f'] |
        \   rviminfo! |
        \ finally |
        \   let [&viminfofile, &viminfo] = [s:viminfofile, s:viminfo] |
        \ endtry
augroup END

so your sessions directory would look like:

project1
project1.viminfo
project2
project2.viminfo

I tried it but couldn't make progress