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

Conflicts with NERDTree menu ('m' key) #3

Closed
techniq opened this issue Sep 18, 2012 · 18 comments
Closed

Conflicts with NERDTree menu ('m' key) #3

techniq opened this issue Sep 18, 2012 · 18 comments
Assignees
Labels

Comments

@techniq
Copy link

techniq commented Sep 18, 2012

When vim-signature is installed, I am unable to toggled NERDTree's menu (m key). I tried setting g:SignatureDefaultMappings = 0, but that didn't work.

@kshenoy
Copy link
Owner

kshenoy commented Sep 20, 2012

Hey, I need to figure out how to disable the mapping of 'm' specifically in the NERDTree buffer. However, I'm really busy with school now and I don't know when I'll be able to do it.

However, for the moment, you can set g:SignatureMarkLeader to something other than 'm'.

@techniq
Copy link
Author

techniq commented Sep 21, 2012

I looked how vim-showmarks did this as I recall them not having the issue (I ran it for a while but didn't like it as well as vim-signature). It appears it has a config variable showmarks_ignore_type to specify which window types to ignore (defaults to 'help' and 'quickfix'). If I check the nerdtree window, it appears to buftype=nofile. Maybe check buftype and return early if it's nofile or one of the others (like help, quickfix, etc).

I don't have a lot of time myself to try to fix and submit a pull request, but if you don't get time in the near future, I'll take a stab at it. Thanks for your reply.

@kshenoy
Copy link
Owner

kshenoy commented Sep 22, 2012

Hey, thanks for the tip. I'd come across that when first going through vim-showmarks but didn't feel a need for it so left it out. Anyway, implemented your suggestion and checked in as dev branch. Currently it only checks if buftype=nofile.

Give it a try and let me know if it works properly. Will extend it for help and quickfix etc. if nothing is broken when I get some breathing space ;)

@ghost ghost assigned kshenoy Sep 22, 2012
@techniq
Copy link
Author

techniq commented Sep 23, 2012

I checked out dev and it fixed Nerdtree. Thanks for making the time to fix it. I'll let you know if I find any other conflicting window types.

@valeriangalliat
Copy link

Hi,

The fix introduced in this issue seems to be removed with this commit.

Is there a way to disable vim-signature in NERDTree buffer to avoid having a delay on the m key?

kshenoy pushed a commit that referenced this issue Dec 22, 2014
@kshenoy
Copy link
Owner

kshenoy commented Dec 22, 2014

Haha, that was almost 2 years ago :D

Anyway, can you give it a try now?

@valeriangalliat
Copy link

Awesome! It works now, thanks. :)

@valeriangalliat
Copy link

Oh well… when opening, closing, and opening again NERDTree, I have the following error:

Error detected while processing function signature#utils#Maps..<SNR>140_Map:                                                                                                                           
line    8:
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping
E31: No such mapping

Patched it like this, what do you think? (Added silent! before both call.)

diff --git a/plugin/signature.vim b/plugin/signature.vim
index 9d72002..04f0fa4 100644
--- a/plugin/signature.vim
+++ b/plugin/signature.vim
@@ -50,8 +50,8 @@ if has('autocmd')
     autocmd!
     autocmd BufEnter,CmdwinEnter * call signature#sign#Refresh()
     autocmd CursorHold * if g:SignaturePeriodicRefresh | call signature#sign#Refresh() | endif
-    autocmd BufEnter,FileType * if (&filetype ==? 'nerdtree') | call signature#utils#Maps('remove') | endif
-    autocmd BufLeave * if (&filetype ==? 'nerdtree') | call signature#utils#Maps('create') | endif
+    autocmd BufEnter,FileType * if (&filetype ==? 'nerdtree') | silent! call signature#utils#Maps('remove') | endif
+    autocmd BufLeave * if (&filetype ==? 'nerdtree') | silent! call signature#utils#Maps('create') | endif
   augroup END
 endif

@kshenoy
Copy link
Owner

kshenoy commented Dec 23, 2014

Oops, forgot a silent! while removing maps. Better to attack the root of the issue. Hopefully, it should be fixed now

@valeriangalliat
Copy link

Perfect!

@laishulu
Copy link

Here to reproduce the problem I met:

  1. I open a new file a.txt, then I have the m. keymap.
  2. I open the nerdtree, and then navigate back to the a.txt window, then the m. keymap is still there.
  3. I run :e b.txt, the m. keymap is gone. I run :e a.txt, the m. keymap is still absent. I open a file c.txt from nerdtree, the m. keymap is missing too.
  4. I navigate to the nerdtree window, and then navigate back to a.txt window without opening a new buffer, then the m. keymap is back again.

@kshenoy
Copy link
Owner

kshenoy commented May 30, 2016

@chenhouwu Hi, I'm able to reproduce this at my end too. Thanks for helping me get to the bottom of this. Looks like when you press <CR> on a file in NerdTree, it doesn't trigger the BufLeave event.

That is what I use to recreate maps for Signature upon leaving the NerdTree buffer. And the only reason to create and remove maps is because of the conflicting m map in NERDTree. Would you be amenable to using M in NerdTree instead of m?

If yes, add the following to your .vimrc:

let g:NERDTreeMapMenu='M'

and delete the following lines from vim-signature/plugin/signature.vim:

" To avoid conflicts with NERDTree. Figure out a cleaner way.
" Food for thought: If NERDTree creates buffer specific maps, shouldn't it override Signature's maps?
autocmd BufEnter,FileType * if (  (&filetype ==? 'nerdtree')
                         \     || (&filetype ==? 'netrw')
                         \     )
                         \|   call signature#utils#Maps('remove')
                         \| endif
autocmd BufLeave * if (  (&filetype ==? 'nerdtree')
                \     || (&filetype ==? 'netrw')
                \     )
                \|   call signature#utils#Maps('create')
                \| endif

This should at least help you avoid this issue.

@laishulu
Copy link

I like this solution. Simple and effective.

But modify the source code is not optimal, because I want to keep up with the latest codes, and local modification will prevent it if without additional care.

Is it possible to delete them in the official repository and describe this solution on the README?

@laishulu
Copy link

laishulu commented May 31, 2016

I just traced the events using the following codes.

 autocmd BufEnter,FileType * if (  (&filetype ==? 'nerdtree')
                             \     || (&filetype ==? 'netrw')
                             \     )
                    \|    echomsg "enter nerdtree"
                    \|    call signature#utils#Maps('remove')
                    \| else
                    \|    echomsg "enter file:"
                    \|    file
                    \| endif
    autocmd BufLeave * if (  (&filetype ==? 'nerdtree')
                    \     || (&filetype ==? 'netrw')
                    \     )
                    \|    echomsg "leave nerdtree"
                    \|    call signature#utils#Maps('create')
                    \| else
                    \|    echomsg "leave file:"
                    \|    file
                    \| endif

and found:

1). I open vim without open any file, I input on item a.txt in nerdtree, I got the following trace, note here file is opened twice.:

Messages maintainer: Bram Moolenaar <[email protected]>
enter file:
"[No Name]" --No lines in buffer--
enter nerdtree
"a.txt" 0L, 0C
enter file:
"a.txt" --No lines in buffer--
enter file:
"a.txt" --No lines in buffer--

2). I then navigate to the nerdtree window from the a.txt window, and press on item a.txt in nerdtree again, i.e. re-enter the a.txt buffer, I just got the following more msgs, note here bufleave for nerdtree and bufenter for a.txt are not triggered.

leave file:
"a.txt" --No lines in buffer--
enter nerdtree

3). I then navigate to the nerdtree window from the a.txt window, and press on item b.txt in nerdtree, i.e. I opened a new buffer, I got the following more msgs. note that after b.txt is opened, nerdtree is first leaved, then enter/leave minibufexplorer, and then enter nerdtree again, but actually the b.txt window is active.

leave file:
"a.txt" --No lines in buffer--
enter nerdtree
enter file:
"-MiniBufExplorer-"  --No lines in buffer--
leave file:
"a.txt" --No lines in buffer--
"b.txt" 0L, 0C
enter file:
"b.txt" --No lines in buffer--
enter file:
"b.txt" --No lines in buffer--
leave nerdtree
enter file:
"-MiniBufExplorer-"  1 line --100%--
leave file:
"-MiniBufExplorer-"  1 line --100%--
enter nerdtree

@kshenoy
Copy link
Owner

kshenoy commented May 31, 2016

Is it possible to delete them in the official repository and describe this solution on the README?

I'd like to think about it a little more before I go down this route.

Thanks for expanding and describing the two cases. I was wondering why this wasn't seen earlier. I guess it's pretty rare that someone would do something like you described in case 1 i.e. open NERDTree and jump back to the same buffer using NERDTree itself. It sounds like a bug in NERDTree since any behavior that depends on BufLeave will not get triggered. Please report it there; they might be interested in knowing about it.

@kshenoy
Copy link
Owner

kshenoy commented Jun 2, 2016

@chenhouwu, I read your this reply and wanted to make sure that I understood you correctly. Are you seeing both enter nerdtree and leave nerdtree messages being echoed or are you able to see only enter nerdtree but not leave nerdtree when you re-enter the same buffer?

@laishulu
Copy link

laishulu commented Jun 2, 2016

@kshenoy I furtherly traced the event in a more verbose way, and updated this comment

@kshenoy
Copy link
Owner

kshenoy commented Jul 8, 2016

Hi @chenhouwu I deleted that code in cfa6452 since I haven't heard back from NERDTree yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants