Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore NERDTree window and others #139

Closed
adelarsq opened this issue Nov 28, 2019 · 17 comments · Fixed by #653
Closed

Ignore NERDTree window and others #139

adelarsq opened this issue Nov 28, 2019 · 17 comments · Fixed by #653

Comments

@adelarsq
Copy link

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 and ClapOnExit autocommands, but I still didn't have time to test.

@liuchengxu
Copy link
Owner

I don't understand what your exact request is.

@adelarsq
Copy link
Author

adelarsq commented Nov 28, 2019

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
Copy link
Owner

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

@alerque
Copy link
Contributor

alerque commented Nov 28, 2019

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
Copy link
Author

adelarsq commented Dec 3, 2019

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
Copy link
Owner

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

@adelarsq
Copy link
Author

adelarsq commented Dec 3, 2019

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

@liuchengxu
Copy link
Owner

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
Copy link
Author

adelarsq commented Jan 3, 2020

Related in some way weirongxu/coc-explorer@6fa5a3d

@tssm
Copy link

tssm commented Jan 17, 2020

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
Copy link

Stale issue message

@macintacos
Copy link

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? junegunn/fzf#453

@alerque
Copy link
Contributor

alerque commented Sep 11, 2020

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

@liuchengxu liuchengxu reopened this Sep 12, 2020
@liuchengxu
Copy link
Owner

That bot should be shut down.

Yeah, also find it a bit of annoying.

@liuchengxu
Copy link
Owner

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
Copy link
Contributor

alerque commented Mar 6, 2021

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
Copy link
Owner

liuchengxu commented Mar 6, 2021

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 junegunn/fzf#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.

liuchengxu added a commit that referenced this issue Mar 11, 2021
* Add ClapOnInitialize hook

Close #139

* Update doc
liuchengxu pushed a commit that referenced this issue Aug 17, 2021
* initial commit

* updated formatting

* added links

* updated node link

* updated repo location

* updated readme

* Update konomi-milestone-1.md

Co-authored-by: willesxm <willeslau@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants