Open jondkinney opened 11 years ago
Oh, I should mention... sessions load up without error if I remove those lines from my .vimrc
Is the fundamental problem that you are restoring a big window into a smaller one? Perhaps set sessionoptions+=resize
might help.
Hmm, that didn't seem to help. I think something is setting winminheight=1 in the background somewhere which is what the conflict is, I just don't know what is setting that. Not a big deal though, I'm only experimenting with that split auto-resize functionality and am leaning towards ditching it anyway. Thanks for the suggestion.
I'm having the same problem, but I really like the (essentially) "auto-resize to make current window big" functionality that these three lines together implement. Also I love this plugin. So I'm pretty keen on finding a solution :)
In looking at the Session.vim file, it appears the "set winheight=1" line is setting things up for the lines that follow, which appear to restore the window configuration from the prior session:
set winheight=1 winwidth=1
exe 'vert 1resize ' . ((&columns * 1 + 133) / 267)
exe 'vert 2resize ' . ((&columns * 85 + 133) / 267)
exe '3resize ' . ((&lines * 3 + 38) / 76)
exe 'vert 3resize ' . ((&columns * 179 + 133) / 267)
exe '4resize ' . ((&lines * 69 + 38) / 76)
exe 'vert 4resize ' . ((&columns * 179 + 133) / 267)
I'm wondering if there's a way to perhaps change the "set winheight=1" line to something like "set winheight=minwinheight" instead? The other possibility I'm thinking is somehow make the three line winheight, minheight, winheight bit in the OP get executed after the Session.vim is finished? I don't know enough about the finer points of Vim yet, but perhaps putting it in some .after file or a special autocmd type of thingy?
Would be very grateful for the cycles of your superior Vim brain to short-circuit to an workaround or fix, otherwise I'll have to put up with it until I get further along in my Vim education :)
Okay. I couldn't stand the suspense. I know. It's a problem. I'm working on it. :)
After noodling on the after bit for a few minutes I looked around and worked out a fix.
If you put this in your .vimrc and move the winheight/minheight lines into this autocommand group it works:
" after Vim startup -------------------- {{{
augroup at_end_of_vim_setup
autocmd!
autocmd VimEnter set winheight=5
autocmd VimEnter set winminheight=3
autocmd VimEnter set winheight=75
augroup END
" }}}
@scanny nice! I'll give this a try too. Thanks for digging in :)
@scanny huh, well this solution isn't working for me. I guess it stops the error messages, but then it also stops the autoresizing stuff too... any thoughts? Are you still using this?
Thanks, Jon
Hi Jon, no, turned out that only worked long enough for me to think it was a solution. I still get the error messages now, I've just gotten used to them :)
I tend to leave sessions up for days at a time, so it's not too big of a hardship. Sure would be nice if there was a fix though. I think it's going to take Pope cycles (distantly related to the Popemobile :) to get to the bottom of this one. Might need a post-plugin hook or something, I'm not sure who writes the Session.vim and when it gets sourced.
@scanny gotcha. Say, do you use nerdtree? That really messes with opening a session for me. I know @tpope isn't a fan, but I like it :/ I've pretty much stopped using sessions because of that issue too which is unfortunate (for me anyway, lol).
Nah, I'm all into Ctrl-P for file/buffer navigation. When I occasionally need to see the directory structure I just use :e. and navigate that way. Those two give me what I need. Sessions are big for me. I have an alias 'e' set up in zsh that opens MacVim with the Session.vim in the current dir (project dirs mostly), so sessions are a pretty important feature in my world :)
Gotcha, I use ctrl-p mostly too... for some reason I just feel more comfortable seeing the directory structure on the left. Actually it helps position the code close to the center of my screen too, which is nice when editing only one buffer. Anyway, do update us if you find a solution to those loading error messages! Thanks much.
FWIW, GoldenView is a plugin which might setup winminheight (initially reported for session.vim).
Anyone found a good workaround or is the current thinking just to ignore the errors?
I've moved on to meta-ignoring. I've been ignoring the errors so long now that I started ignoring the fact I ignore them :)
@scanny How do you ignore the error or did you find another way to solve it? It's very annoying!!
I tried putting silent! set winheight
in my .vimrc, but still no luck :(
@jondkinney @scanny @blueyed @hiattp @lvarayut I've found a way to fix this. I'll be making a PR shortly to see what @tpope thinks of this. It's probably a little hackish, and I'm not sure if there are any unintended consequences of this, but in the little testing I've done it seems to work as expected.
Inside of plugin/obsession.vim
, change:
call writefile(body, g:this_obsession)
to
call writefile(filter(body, 'v:val != "set winheight=1 winwidth=1"'), g:this_obsession)
body
is just a List, so this just filters it to remove the set winheight=1
lines.
@boatrite Do you know where those lines are coming from? Is it clear from looking at the session file?
@boatrite But always? (cannot check it myself) That would new an issue then always, no? (with minwinheight)
@boatrite: That works for me!
I patched it in on the latest master and it seems to do the needful very cleanly. I would get the message every single time, so those lines seem to be placed in the session file systematically and unconditionally.
I think it's a solid fix :)
I've battled this issue for a long time and have tried a myriad of approaches to fixing it. I believe I've found a solution which does not require any alterations to to the vim-obsession plugin. Below are the relevant parts from my .vimrc
file. Hope it helps! 🙂
" Keep focus split wide, others narrow.
set winwidth=90
set winminwidth=5
" Keep focus split at max height, others minimal.
function! SetWindowHeight()
set winheight=5
set winminheight=5
set winheight=999
endfunction
" Reset window height to avoid session errors.
function! ResetWindowHeight()
set winminheight=0
set winheight=1
endfunction
" Reset window sizes to avoid errors on session load.
augroup set_window_height
autocmd!
autocmd VimLeavePre * :call ResetWindowHeight()
autocmd VimEnter * :call SetWindowHeight()
augroup END
@joshukraine Nice, I just added that to my .vimrc to try it out, and it definitely works as far as I can tell. My solution stopped working a while back for what that's worth. Not sure why. Thanks!
Edit: I actually started getting a "Not enough room" error when I switched away from my branch to the regular vim-obsession. Still playing with this.
Edit 2: So I ended up with the error still even with that snippet, so I took another look at my fix. I changed it to filter by regex and get rid of any lines matching "set winheight" or "set winminheight".
https://github.com/tpope/vim-obsession/compare/master...boatrite:zb-fix-winheight-error
Anyways, hope this helps any one else with this issue.
An idea I just had:
autocmd SourcePre Session.vim set minwinheight=1
autocmd SessionLoadPost * set minwinheight=5
This is probably oversimplified, but could be another piece in the autocmd puzzle.
Nice plugin!
I have these settings in my .vimrc courtesy of Gary Bernhardt's Destroy All Software screencast series.
When I go to load up a saved session I receive the following error:
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!