tpope / vim-obsession

obsession.vim: continuously updated session files
http://www.vim.org/scripts/script.php?script_id=4472
1.76k stars 70 forks source link

Doubled up files #34

Closed jones77 closed 7 years ago

jones77 commented 7 years ago

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
tpope commented 7 years ago

The session file itself looks correct. It's either a Vim bug or, far more likely, some plugin or your vimrc throwing a spanner into the works.

jones77 commented 7 years ago

Yup, sorry, staring me in the face:

$ grep Session.vim ~/.[av]* 2>/dev/null
/c/Users/James/.aliases:    if (( $# == 0 )) && [[ -f Session.vim ]]
/c/Users/James/.aliases:        vim $jj_vim_options -S Session.vim
/c/Users/James/.vimrc::if !empty(glob("Session.vim")) && argc() == 0
/c/Users/James/.vimrc::   source Session.vim
$

Used two different solutions across space and time and merged 'em together, d'oh.