mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

Quickfix window displaces NERDTree #66

Open jondkinney opened 11 years ago

jondkinney commented 11 years ago

Things get weird when I search with NERDTree open and then open one of the results in a split:

Screen Shot 2013-02-26 at 12 05 40 PM

kassio commented 10 years ago

Could you check if this still happening with master version!? I'll close it for now, but feel free to reopen it if necessary.

jondkinney commented 8 years ago

@kassio this seems to be happening again. Though it is replacing the nerdtree split now instead of going next to it. Any thoughts?

kassio commented 8 years ago

Sorry, but I don't contribute for this project anymore. I hope the new contributors can help you. :smile:

ches commented 8 years ago

Are you able to reproduce consistently, and provide exact steps (key sequence, etc.) to do so?

olalonde commented 8 years ago

3 years later, I am still scared every time I type :Ack

QMonkey commented 8 years ago

@ches It always happens after I switch window from NERDTree to Ack quickfix, and then press v to open one of the results in a vsplit window.

QMonkey commented 8 years ago

displaces

tczf1128 commented 8 years ago

same problem

ches commented 8 years ago

Aha! Well at last… I realized I couldn't reproduce because I use let NERDTreeWinPos = 'right' and that isn't affected 😇

Here's a workaround for now, set this in your vimrc:

" Split rightward so as not to displace a left NERDTree
let g:ack_mappings = {
      \  'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
      \ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J' }

The plugin's defaults get merged with yours if you've set g:ack_mappings. I don't love the way this is done or the way we expose this mappings configuration, but that's a matter for another day. Also, you will probably start to notice #150, but one thing at a time…

jondkinney commented 8 years ago

@ches Thanks for this. I think using v is working for me now (sort of...I have to press j or k after, probably because it's overriding visual select or something). However, I most frequently hit enter after searching which still replaces the NERDTree with the file it's pulling up from quickfix. I'll try to see if I can adapt your mappings to account for <cr>. But just wanted to mention that that is my use case and is still being problematic.

ches commented 8 years ago

I think using v is working for me now (sort of...I have to press j or k after, probably because it's overriding visual select or something)

Odd, I'm not seeing this.

However, I most frequently hit enter after searching which still replaces the NERDTree with the file it's pulling up from quickfix.

This one is just going to be a wontfix for the core plugin I'm afraid, after all NERDTree is just a window and introducing special cases for detecting it and who knows what else would become a total mess. Plain :vimgrep would be the same story, not a fault of ack.vim. Hopefully adding a mapping can work for you though, or training yourself not to start searches with NERDTree focused 😄

I should mention another possibility for anyone following: it sort of sucks to say "use another plugin", but I increasingly feel that something like QFEnter is the right way instead of ack.vim duplicating this functionality and having it not work in other quickfix windows or even when re-opening the same one. See my mini-rant on #170, you might try installing QFEnter, disabling ack.vim's quickfix mappings, and see if that works out better for you. You still might need some tweaking for the NERDTree-was-last-focused case though…

jondkinney commented 8 years ago

Ah, yes, I am already trained to not start searches with NERDTree focused. Learned that one a long time ago :) So here's what I actually want enter to do... leave my current tab alone, put the first result open in a new tab with the quickfix window below so I can ]q through them (with unimpaired). This mapping is a little slow...but definitely does exactly what I want! The third line is my addition to your existing suggestion. If you have any ways to improve this / speed it up I'm all ears! Thanks again for following up on this.

" Split rightward so as not to displace a left NERDTree
let g:ack_mappings = {
      \  'v':  '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
      \ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J',
      \ '<cr>': '<C-W><CR>:cclose<CR><C-W>T:copen<CR>' }
ches commented 8 years ago

Hmm, you might shorten the jumping around slightly with '<C-W><CR>:cclose<CR><C-W>T:copen<CR>'

But what I think I'd do in this case is just define a mapping to start the whole thing off in a new tab:

nnoremap <Leader>a :tabnew <Bar> Ack<Space>

" And/or abbreviation
abbr TAck tabnew <Bar> Ack