mattboehm / vim-accordion

A vim window manager for people who love splits
101 stars 3 forks source link

Unstack not opening Glog --reverse highlights #42

Closed danshumaker closed 6 years ago

danshumaker commented 6 years ago

Sorry, just imagine your trying to help your grandmother.

I'm trying to follow this: "The easiest way to open versions of a file is to run fugitive's :Glog --reverse, highlight the desired changes in the quickfix list, and hit the unstack shortcut".

:Glog --reverse works fine. I then hit enter to make glog put the files commits into the quick fix list. I then run :cw to bring up the quickfix list. I then hit v to start visual highlighting. jjjj to select the next three lines of commits for that file. I then hit leader s and nothing happens (my leader is space). Sounds simple and yet doesn't work. Any ideas? Leader definition:

nnoremap <space> <Nop>
let mapleader = " "

" clear spaces
nnoremap <leader><space> :noh<cr>

Perhaps the issue is in the unstack definition???

let g:unstack_mapkey="<leader>s"

I've confirmed I have both vim-accordion and unstack plugins installed (the helps work). ref: https://github.com/tpope/vim-fugitive/issues/329

mattboehm commented 6 years ago

Sorry for the delay in noticing this.

The easiest thing you can do to debug is try running :nmap <space>s and see :set operatorfunc=unstack#Unstack<cr>g@. My guess is that you'll either see a different mapping (because something else remapped it) or that you'll see No mapping found, in which case you could try just running :nmap and scanning the list for Unstack. If you see a mapping for \s or something, then perhaps the plugin is registering the binding before you set mapleader. If you don't see any mappings for Unstack, double-check that the :UnstackFromClipboard command auto-completes.

Please let me know what running the above commands reveals. When I have some spare time, I'll see what I can do to reproduce things on my end or improve the code for keybinding.

danshumaker commented 6 years ago

Hi Matt, When I nmap <space>s I get three lines printed. What is the precedence? Is the first one the only that's active? The first line is the unstack command. The second and third are my personal ones.

n  <Space>s    * :set operatorfunc=unstack#Unstack<CR>g@
n  <Space>ss     :mks! ~/.vim/ds.vimsession<CR>
n  <Space>     * <Nop>  

When typing :Unstack<tab> it DOES autocomplete to give the four different unstack commands to choose from (from clipboard, from selection, from text, and from tmux).

However when I manually execute the :UnstackFromClipboard command (after copying/yanking several lines in the Glog --reverse quicklist ) I get this error:

Error detected while processing function unstack#UnstackFromText:
line   10:
No stack trace found!     
mattboehm commented 6 years ago

Ah, gotcha.

I think what's happening is that when you type <Space>s, vim is waiting to see whether or not you're going to type a second s to determine which command to run. You should test this theory by temporarily unmapping <Space>ss (:nunmap <Space>ss). You can also look into the timeout and timeoutlen settings. However, assuming the test fixes your issue, the easiest thing to do would be to choose a different mapping for :mks (perhaps <Space>S?)

:UnstackFromClipboard isn't working because I figure out the file name/line number for quickfix entries through a vim API rather than by running a regex over the text (since the formats of those entries can vary.)

Anyway, let me know if changing the mapping or messing with the timeout settings fixes the problem for you. Good luck!

danshumaker commented 6 years ago

Hmm, did the unmap and didn't see a change. Is there a debug mode or something I can turn on? For fear that my words are failing me I've included a link to a demo screen-recording of the fail. Before I had been trying it without the explicit unstack mapping set in my vimrc assuming that the plugin installation took care of that. The demo movie shows my .vimrc first and then a git log example.

https://www.dropbox.com/s/pwg0pwu0qxpswem/vim-accordian-issue-42-fail-demo.mov?dl=0

mattboehm commented 6 years ago

Thanks, that helps. I notice that you get an error message saying that the file is not modifiable, which definitely sounds like an issue of the wrong mapping being triggered.

Could you tell me the output of :vmap <Space>s? Your video helped me realize that we are actually concerned about the mappings for visual mode.

The definitive way to rule out mapping issues would be to run vnoremap <F10> :<c-u>call unstack#Unstack(visualmode())<cr>, select the lines, and hit F10 (or substitute F10 for any single unused key of your choice.)

danshumaker commented 6 years ago

Hmm, I thought perhaps all my other settings were getting in the way so I stripped my .vimrc down to almost nothing. Still no dice. A little bit longer demo with audio. I did try the f10 mapping.

https://www.dropbox.com/s/p5g52lje4y1mu0l/vim-accordion-issue-42-strip-down.mov?dl=0

mattboehm commented 6 years ago

Thanks again for the video.

You're absolutely right; I tried making a fresh environment on my end and am seeing the same problem. I must be working on an older version of Fugitive locally or something. I'll get to work trying to debug this.

mattboehm commented 6 years ago

I've merged the fix in https://github.com/mattboehm/vim-unstack/pull/31 . Apparently, I was using an outdated version of unstack on my local machine, and a while back someone updated the code to only support files that the filereadable() function recognizes as readable, which broke Fugitive's files as they contain the fugitive:// protocol.

Thank you so much for reporting the bug and helping out and recording those videos! Sorry to put you through so much work for what turned out to be a bug in my code.

mattboehm commented 6 years ago

@danshumaker let me know if you still run into issues after doing a :PlugUpdate.

danshumaker commented 6 years ago

@mattboehm Woo Hoo! Thank you for sticking with it and fixing it! Works like a charm now.

mattboehm commented 6 years ago

Awesome, thanks again and happy Vimming!