nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 1e93f6840a4cbbbf1130ae56357d92fc90055036
parent c6a68d4b962e747a58450ae03f7f443deb0afddf
Author: Jason Franklin <j_fra@fastmail.us>
Date:   Sat,  6 Jan 2018 09:10:10 -0500

Format the commentary in "ui.vim"

Diffstat:
Mlib/nerdtree/ui.vim | 149++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 76 insertions(+), 73 deletions(-)
diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim
@@ -1,11 +1,14 @@
-"CLASS: UI
-"============================================================
+" ============================================================================
+" CLASS: UI
+" ============================================================================
+
+
 let s:UI = {}
 let g:NERDTreeUI = s:UI
 
-"FUNCTION: s:UI.centerView() {{{2
-"centers the nerd tree window around the cursor (provided the nerd tree
-"options permit)
+" FUNCTION: s:UI.centerView() {{{2
+" centers the nerd tree window around the cursor (provided the nerd tree
+" options permit)
 function! s:UI.centerView()
     if g:NERDTreeAutoCenter
         let current_line = winline()
@@ -17,8 +20,8 @@ function! s:UI.centerView()
     endif
 endfunction
 
-"FUNCTION: s:UI._dumpHelp  {{{1
-"prints out the quick help
+" FUNCTION: s:UI._dumpHelp  {{{1
+" prints out the quick help
 function! s:UI._dumpHelp()
     if self.getShowHelp()
         let help  = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n"
@@ -93,7 +96,7 @@ function! s:UI._dumpHelp()
         let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n"
         let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n"
 
-        "add quickhelp entries for each custom key map
+        " add quickhelp entries for each custom key map
         let help .= "\"\n\" ----------------------------\n"
         let help .= "\" Custom mappings~\n"
         for i in g:NERDTreeKeyMap.All()
@@ -124,7 +127,7 @@ function! s:UI._dumpHelp()
 endfunction
 
 
-"FUNCTION: s:UI.new(nerdtree) {{{1
+" FUNCTION: s:UI.new(nerdtree) {{{1
 function! s:UI.New(nerdtree)
     let newObj = copy(self)
     let newObj.nerdtree = a:nerdtree
@@ -137,22 +140,22 @@ function! s:UI.New(nerdtree)
     return newObj
 endfunction
 
-"FUNCTION: s:UI.getPath(ln) {{{1
-"Gets the full path to the node that is rendered on the given line number
+" FUNCTION: s:UI.getPath(ln) {{{1
+" Gets the full path to the node that is rendered on the given line number
 "
-"Args:
-"ln: the line number to get the path for
+" Args:
+" ln: the line number to get the path for
 "
-"Return:
-"A path if a node was selected, {} if nothing is selected.
-"If the 'up a dir' line was selected then the path to the parent of the
-"current root is returned
+" Return:
+" A path if a node was selected, {} if nothing is selected.
+" If the 'up a dir' line was selected then the path to the parent of the
+" current root is returned
 function! s:UI.getPath(ln)
     let line = getline(a:ln)
 
     let rootLine = self.getRootLineNum()
 
-    "check to see if we have the root node
+    " check to see if we have the root node
     if a:ln == rootLine
         return self.nerdtree.root.path
     endif
@@ -163,7 +166,7 @@ function! s:UI.getPath(ln)
 
     let indent = self._indentLevelFor(line)
 
-    "remove the tree parts and the leading space
+    " remove the tree parts and the leading space
     let curFile = self._stripMarkup(line)
 
     let dir = ""
@@ -173,7 +176,7 @@ function! s:UI.getPath(ln)
         let curLine = getline(lnum)
         let curLineStripped = self._stripMarkup(curLine)
 
-        "have we reached the top of the tree?
+        " have we reached the top of the tree?
         if lnum == rootLine
             let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
             break
@@ -193,19 +196,19 @@ function! s:UI.getPath(ln)
     return toReturn
 endfunction
 
-"FUNCTION: s:UI.getLineNum(file_node){{{1
-"returns the line number this node is rendered on, or -1 if it isnt rendered
+" FUNCTION: s:UI.getLineNum(file_node){{{1
+" returns the line number this node is rendered on, or -1 if it isnt rendered
 function! s:UI.getLineNum(file_node)
-    "if the node is the root then return the root line no.
+    " if the node is the root then return the root line no.
     if a:file_node.isRoot()
         return self.getRootLineNum()
     endif
 
     let totalLines = line("$")
 
-    "the path components we have matched so far
+    " the path components we have matched so far
     let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
-    "the index of the component we are searching for
+    " the index of the component we are searching for
     let curPathComponent = 1
 
     let fullpath = a:file_node.path.str({'format': 'UI'})
@@ -213,7 +216,7 @@ function! s:UI.getLineNum(file_node)
     let lnum = self.getRootLineNum()
     while lnum > 0
         let lnum = lnum + 1
-        "have we reached the bottom of the tree?
+        " have we reached the bottom of the tree?
         if lnum ==# totalLines+1
             return -1
         endif
@@ -241,8 +244,8 @@ function! s:UI.getLineNum(file_node)
     return -1
 endfunction
 
-"FUNCTION: s:UI.getRootLineNum(){{{1
-"gets the line number of the root node
+" FUNCTION: s:UI.getRootLineNum(){{{1
+" gets the line number of the root node
 function! s:UI.getRootLineNum()
     let rootLine = 1
     while getline(rootLine) !~# '^\(/\|<\)'
@@ -251,29 +254,29 @@ function! s:UI.getRootLineNum()
     return rootLine
 endfunction
 
-"FUNCTION: s:UI.getShowBookmarks() {{{1
+" FUNCTION: s:UI.getShowBookmarks() {{{1
 function! s:UI.getShowBookmarks()
     return self._showBookmarks
 endfunction
 
-"FUNCTION: s:UI.getShowFiles() {{{1
+" FUNCTION: s:UI.getShowFiles() {{{1
 function! s:UI.getShowFiles()
     return self._showFiles
 endfunction
 
-"FUNCTION: s:UI.getShowHelp() {{{1
+" FUNCTION: s:UI.getShowHelp() {{{1
 function! s:UI.getShowHelp()
     return self._showHelp
 endfunction
 
-"FUNCTION: s:UI.getShowHidden() {{{1
+" FUNCTION: s:UI.getShowHidden() {{{1
 function! s:UI.getShowHidden()
     return self._showHidden
 endfunction
 
-"FUNCTION: s:UI._indentLevelFor(line) {{{1
+" FUNCTION: s:UI._indentLevelFor(line) {{{1
 function! s:UI._indentLevelFor(line)
-    "have to do this work around because match() returns bytes, not chars
+    " have to do this work around because match() returns bytes, not chars
     let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
     " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+
     let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs'))
@@ -281,27 +284,27 @@ function! s:UI._indentLevelFor(line)
     return leadChars / s:UI.IndentWid()
 endfunction
 
-"FUNCTION: s:UI.IndentWid() {{{1
+" FUNCTION: s:UI.IndentWid() {{{1
 function! s:UI.IndentWid()
     return 2
 endfunction
 
-"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
+" FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
 function! s:UI.isIgnoreFilterEnabled()
     return self._ignoreEnabled == 1
 endfunction
 
-"FUNCTION: s:UI.isMinimal() {{{1
+" FUNCTION: s:UI.isMinimal() {{{1
 function! s:UI.isMinimal()
     return g:NERDTreeMinimalUI
 endfunction
 
-"FUNCTION: s:UI.MarkupReg() {{{1
+" FUNCTION: s:UI.MarkupReg() {{{1
 function! s:UI.MarkupReg()
     return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
 endfunction
 
-"FUNCTION: s:UI._renderBookmarks {{{1
+" FUNCTION: s:UI._renderBookmarks {{{1
 function! s:UI._renderBookmarks()
 
     if !self.isMinimal()
@@ -322,12 +325,12 @@ function! s:UI._renderBookmarks()
     call cursor(line(".")+1, col("."))
 endfunction
 
-"FUNCTION: s:UI.restoreScreenState() {{{1
+" FUNCTION: s:UI.restoreScreenState() {{{1
 "
-"Sets the screen state back to what it was when nerdtree#saveScreenState was last
-"called.
+" Sets the screen state back to what it was when nerdtree#saveScreenState was last
+" called.
 "
-"Assumes the cursor is in the NERDTree window
+" Assumes the cursor is in the NERDTree window
 function! s:UI.restoreScreenState()
     if !has_key(self, '_screenState')
         return
@@ -342,9 +345,9 @@ function! s:UI.restoreScreenState()
     let &scrolloff=old_scrolloff
 endfunction
 
-"FUNCTION: s:UI.saveScreenState() {{{1
-"Saves the current cursor position in the current buffer and the window
-"scroll position
+" FUNCTION: s:UI.saveScreenState() {{{1
+" Saves the current cursor position in the current buffer and the window
+" scroll position
 function! s:UI.saveScreenState()
     let win = winnr()
     call g:NERDTree.CursorToTreeWin()
@@ -355,31 +358,31 @@ function! s:UI.saveScreenState()
     call nerdtree#exec(win . "wincmd w")
 endfunction
 
-"FUNCTION: s:UI.setShowHidden(val) {{{1
+" FUNCTION: s:UI.setShowHidden(val) {{{1
 function! s:UI.setShowHidden(val)
     let self._showHidden = a:val
 endfunction
 
-"FUNCTION: s:UI._stripMarkup(line){{{1
-"returns the given line with all the tree parts stripped off
+" FUNCTION: s:UI._stripMarkup(line){{{1
+" returns the given line with all the tree parts stripped off
 "
-"Args:
-"line: the subject line
+" Args:
+" line: the subject line
 function! s:UI._stripMarkup(line)
     let line = a:line
-    "remove the tree parts and the leading space
+    " remove the tree parts and the leading space
     let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
 
-    "strip off any read only flag
+    " strip off any read only flag
     let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","")
 
-    "strip off any bookmark flags
+    " strip off any bookmark flags
     let line = substitute (line, ' {[^}]*}', "","")
 
-    "strip off any executable flags
+    " strip off any executable flags
     let line = substitute (line, '*\ze\($\| \)', "","")
 
-    "strip off any generic flags
+    " strip off any generic flags
     let line = substitute (line, '\[[^]]*\]', "","")
 
     let line = substitute (line,' -> .*',"","") " remove link to
@@ -387,22 +390,22 @@ function! s:UI._stripMarkup(line)
     return line
 endfunction
 
-"FUNCTION: s:UI.render() {{{1
+" FUNCTION: s:UI.render() {{{1
 function! s:UI.render()
     setlocal modifiable
 
-    "remember the top line of the buffer and the current line so we can
-    "restore the view exactly how it was
+    " remember the top line of the buffer and the current line so we can
+    " restore the view exactly how it was
     let curLine = line(".")
     let curCol = col(".")
     let topLine = line("w0")
 
-    "delete all lines in the buffer (being careful not to clobber a register)
+    " delete all lines in the buffer (being careful not to clobber a register)
     silent 1,$delete _
 
     call self._dumpHelp()
 
-    "delete the blank line before the help and add one after it
+    " delete the blank line before the help and add one after it
     if !self.isMinimal()
         call setline(line(".")+1, "")
         call cursor(line(".")+1, col("."))
@@ -412,24 +415,24 @@ function! s:UI.render()
         call self._renderBookmarks()
     endif
 
-    "add the 'up a dir' line
+    " add the 'up a dir' line
     if !self.isMinimal()
         call setline(line(".")+1, s:UI.UpDirLine())
         call cursor(line(".")+1, col("."))
     endif
 
-    "draw the header line
+    " draw the header line
     let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
     call setline(line(".")+1, header)
     call cursor(line(".")+1, col("."))
 
-    "draw the tree
+    " draw the tree
     silent put =self.nerdtree.root.renderToString()
 
-    "delete the blank line at the top of the buffer
+    " delete the blank line at the top of the buffer
     silent 1,1delete _
 
-    "restore the view
+    " restore the view
     let old_scrolloff=&scrolloff
     let &scrolloff=0
     call cursor(topLine, 1)
@@ -441,14 +444,14 @@ function! s:UI.render()
 endfunction
 
 
-"FUNCTION: UI.renderViewSavingPosition {{{1
-"Renders the tree and ensures the cursor stays on the current node or the
-"current nodes parent if it is no longer available upon re-rendering
+" FUNCTION: UI.renderViewSavingPosition {{{1
+" Renders the tree and ensures the cursor stays on the current node or the
+" current nodes parent if it is no longer available upon re-rendering
 function! s:UI.renderViewSavingPosition()
     let currentNode = g:NERDTreeFileNode.GetSelected()
 
-    "go up the tree till we find a node that will be visible or till we run
-    "out of nodes
+    " go up the tree till we find a node that will be visible or till we run
+    " out of nodes
     while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot()
         let currentNode = currentNode.parent
     endwhile
@@ -460,7 +463,7 @@ function! s:UI.renderViewSavingPosition()
     endif
 endfunction
 
-"FUNCTION: s:UI.toggleHelp() {{{1
+" FUNCTION: s:UI.toggleHelp() {{{1
 function! s:UI.toggleHelp()
     let self._showHelp = !self._showHelp
 endfunction
@@ -515,7 +518,7 @@ function! s:UI.toggleZoom()
     endif
 endfunction
 
-"FUNCTION: s:UI.UpDirLine() {{{1
+" FUNCTION: s:UI.UpDirLine() {{{1
 function! s:UI.UpDirLine()
     return '.. (up a dir)'
 endfunction