Add 2 autocmds - NERDTreeInit and NERDTreeNewRoot. These are called when
a tree is created and when the root is changed. The goal is to give the
fugitive plugin something to listen for so it can add the G* commands to
nerdtree buffers in git repo dirs.
Previously if we used the gi/gs mappings on a dir node/bookmark the
cursor would end up in the new window. Now it stays in the current
window as expected
KeyMap.bind() does not gracefully handle use of '<>' notation. For
example, trying to call NERDTreeAddKeyMap() with a 'key' argument of
'<Leader>e'. There were some workarounds KeyMap.bind() to help with
this by specifically allowing you to leave off the '<>' parts for
'<C-...>', '<M-...>' and mouse mappings and it would add them back for
you before creating the mapping. This commit reverts some of that logic
and simply says that if the key starts with '<', replace it with <lt>.
These calls to NERDTreeAddKeyMap use the same callback as when these
keys are mapped with a 'scope' of "Node." This should not pose a
problem though as s:previewNodeCurrent, s:previewNodeHSplit and
s:previewNodeVSplit all just call the passed in node's open() method,
which gets passed on to an Opener object.
The core issue is that in some versions of vim resolve() will remove trailing
slashes, while in others it will not. This lead to commit
bc745b6e99 attempting to address a double slash
problem. However, that broke symlink detection on systems where resolve()
removes trailing slashes. This new function just calls vim's resolve()
function, but removes trailing slashes if they exist.
Previously we are doing this every time a nerdtree window was created -
which is wrong and was removing custom mappings from users that overrode
default key mappings.
Now we only generate the defaults once.
Older versions of vim require you to unlet a dictionary function if you
are replacing it (i.e. overriding it in a prototype OO scenario). The
unlet call got lost in the recent refactoring.
Move the code to split windows and open nodes and bookmarks out into a
dedicated class. This will remove duplication and remove and centralise
a concern from the other classes.