liuchengxu / vim-clap

:clap: Modern performant fuzzy picker, tree-sitter highlighting, and more, for both Vim and NeoVim
https://liuchengxu.github.io/vim-clap/
MIT License
2.11k stars 87 forks source link

Ignore NERDTree window and others #139

Closed adelarsq closed 3 years ago

adelarsq commented 4 years ago

I use NERDTree a lot on my workflow. Always that the focus is on it and I call Clap choosing a file the file is opened on the NERDTree's window.

Would be nice if it was possible to ignore the NERDTree window, and others, opening the file only on the allowed window.

For now I close the NERDTree's window and I open again after the file been opened. I think it's possible to solve with ClapOnEnter andClapOnExit autocommands, but I still didn't have time to test.

liuchengxu commented 4 years ago

I don't understand what your exact request is.

adelarsq commented 4 years ago

The focus is on the NERTree's window on the left side. So I execute Clap files:

Captura de Tela 2019-11-27 às 23 04 40

The file is opened on the NERDTree's window on the left side, instead from the Startify's window on the right side:

Captura de Tela 2019-11-27 às 23 07 31
liuchengxu commented 4 years ago

What if you have more than two windows, how to know in which window the selected file should be opend?

alerque commented 4 years ago

This is also a problem for tagbar. If there is anything that can be done from the tagbar (or NERDtree) side of things let us know. I don't know exactly how to handle the case of multiple open panes besides these utility panes, but somehow the utility panes know where to send you back when you open a file or navigate to a header from inside them, so it should be possible to capture or pass that information to Clap so it can open files in the correct target pane as well.

adelarsq commented 4 years ago

First we need a list from all windows in the current tab. So we can get the filetype for each window and ignore if the window appears in the ignored list. So on the Clap return it can change the focus for the first window on the new list.

The follow filetypes can be ignored I think:

liuchengxu commented 4 years ago

You still can't guarantee the first one of new list is desired.

adelarsq commented 4 years ago

The only way that I think is by precedence. By position would be better, but I don't know if its possible.

liuchengxu commented 4 years ago

Actually the position is not a clear rule, e.g., some people like the window on the right side, while some may prefer the one on the left or at the bottom. I'm not interested in this feature myself, but I can accept PR :(.

adelarsq commented 4 years ago

Related in some way https://github.com/weirongxu/coc-explorer/commit/6fa5a3d98edc73725a48e490d9be5fe8d48b57b5

tssm commented 4 years ago

I think this is highly controversial. If it is implemented it should be based on a list of buffers that the user specifies. I use Neovim terminal a lot, as well as Startify, Quick Fix, Vista and FileBeagle. When I open a file with Clap I expect it to be open in the window with focus, even if it is one the above list.

github-actions[bot] commented 4 years ago

Stale issue message

macintacos commented 4 years ago

Surprised that this was closed out; I'm very interested in this feature, since it always throws me for a loop when my file drawer (in this case, NERDTree) is taken over by a file I was trying to open.

FWIW, there are a variety of solutions that folks came up with in this thread for FZF; I'm still really not good with vimscript so it's a bit tough for me to figure out how to make it apply to vim-clap. Maybe someone in this thread knows? https://github.com/junegunn/fzf/issues/453

alerque commented 4 years ago

This issue should be reopened. That bot should be shut down.

liuchengxu commented 4 years ago

That bot should be shut down.

Yeah, also find it a bit of annoying.

liuchengxu commented 3 years ago

Try #653, you can change the focus to other windows when opening clap as follows:

autocmd User ClapOnInitialize call TryStartFromOtherWindow()

function! TryStartFromOtherWindow() abort
  " Filter the windows you want to ignore
  if bufname('%') ==# 'NERD_tree' || &filetype ==# 'coc-explorer'
    " Move the focus on the window you prefer.
    noautocmd wincmd l

    " Reset the start window of clap.
    let g:clap.start.bufnr = bufnr('')
    let g:clap.start.winid = win_getid()
    let g:clap.start.old_pos = getpos('.')
  endif
endfunction
alerque commented 3 years ago

That's looking promising (haven't test driven it yet, but the concept looks about right). But I would argue this should be included by default. I would think it vanishingly rare that anybody would want their special purpose panes taken over by Clap. My guess is the expected behavior 99% of the time is going to be to use whatever the most recent buffer in the buffer history is that does not match one of the ignore list. Such a list could be prepopulated with at least a dozen or so of the more popular plugins that create special panes.

liuchengxu commented 3 years ago

We can reach some consensus about the ignore list, but which window we prefer in this scenario is not pretty standard, we can see there are various user requests in https://github.com/junegunn/fzf/issues/453, so my opinion is just to let people themselves decide the list that should be ignored and what to do when they ignore them.