Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

adds a BeforeRender hook and prefix and suffix hooks to Path display strings references #153 #157

Closed
wants to merge 1 commit into from

2 participants

@swerner

This is the first thing I've ever done in Vimscript, so while I tried to stick to the style you used, sorry if there are a few places where I didn't and will gladly fix. I also had a bit of trouble choosing names for things, but went with a plugin: prefix for the functions. I am totally willing to do more, if you have more of a roadmap for hooks to add for example, please let me know.

Example usage

While the plugin is not completely finished. An example of how I'm using it is up at https://github.com/swerner/git_nerd/blob/master/git_nerd.vim

@gnujeremie

Hi @scrooloose , will you have time to try to merge this request ? :) Thx !

@swerner

I've realized since I've submitted that the way I did it was pretty bad - it only allows for one nerdtree plugin to implement a prefix or suffix along with naming convention being all over the place. I think I've got a solution, and will be updating the pull request here as soon as I get the chance (and learn the relevant parts of vimscript).

@gnujeremie

yay \o\ \o/ /o/ I'm waiting for this feature :-D

@swerner swerner closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +15 −0 plugin/NERD_tree.vim
View
15 plugin/NERD_tree.vim
@@ -69,6 +69,9 @@ call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
+call s:initVariable("g:NERDTreePrefix", 0)
+call s:initVariable("g:NERDTreeSuffix", 0)
+call s:initVariable("g:NERDTreeBeforeRender", 0)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
@@ -2174,6 +2177,14 @@ function! s:Path.cacheDisplayString()
let self.cachedDisplayString = self.cachedDisplayString . '*'
endif
+ if g:NERDTreePrefix
+ let self.cachedDisplayString = plugin:NERDTreePrefix(self) . self.cachedDisplayString
+ endif
+
+ if g:NERDTreeSuffix
+ let self.cachedDisplayString .= plugin:NERDTreeSuffix(self)
+ endif
+
let self._bookmarkNames = []
for i in s:Bookmark.Bookmarks()
if i.path.equals(self)
@@ -3734,6 +3745,10 @@ endfunction
function! s:renderView()
setlocal modifiable
+ if g:NERDTreeBeforeRender
+ call plugin:NERDTreeBeforeRender()
+ endif
+
"remember the top line of the buffer and the current line so we can
"restore the view exactly how it was
let curLine = line(".")
Something went wrong with that request. Please try again.