1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2017-09-02 12:43:18 +02:00
parent 3be3af28e5
commit 7fc202ec88
64 changed files with 1659 additions and 525 deletions

View File

@ -1,56 +1,18 @@
The NERD Tree
The NERDTree
=============
Intro
-----
Introduction
------------
The NERD tree allows you to explore your filesystem and to open files and
directories. It presents the filesystem to you in the form of a tree which you
manipulate with the keyboard and/or mouse. It also allows you to perform
simple filesystem operations.
The NERDTree is a file system explorer for the Vim editor. Using this plugin,
users can visually browse complex directory hierarchies, quickly open files for
reading or editing, and perform basic file system operations.
The following features and functionality are provided by the NERD tree:
This plugin can also be extended with custom mappings using a special API. The
details of this API and of other NERDTree features are described in the
included documentation.
* Files and directories are displayed in a hierarchical tree structure
* Different highlighting is provided for the following types of nodes:
* files
* directories
* sym-links
* windows .lnk files
* read-only files
* executable files
* Many (customisable) mappings are provided to manipulate the tree:
* Mappings to open/close/explore directory nodes
* Mappings to open files in new/existing windows/tabs
* Mappings to change the current root of the tree
* Mappings to navigate around the tree
* ...
* Directories and files can be bookmarked.
* Most NERD tree navigation can also be done with the mouse
* Filtering of tree content (can be toggled at runtime)
* custom file filters to prevent e.g. vim backup files being displayed
* optional displaying of hidden files (. files)
* files can be "turned off" so that only directories are displayed
* The position and size of the NERD tree window can be customised
* The order in which the nodes in the tree are listed can be customised.
* A model of your filesystem is created/maintained as you explore it. This
has several advantages:
* All filesystem information is cached and is only re-read on demand
* If you revisit a part of the tree that you left earlier in your
session, the directory nodes will be opened/closed as you left them
* The script remembers the cursor position and window position in the NERD
tree so you can toggle it off (or just close the tree window) and then
reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
as you left it
* You can have a separate NERD tree for each tab, share trees across tabs,
or a mix of both.
* By default the script overrides the default file browser (netrw), so if
you :edit a directory a (slightly modified) NERD tree will appear in the
current window
* A programmable menu system is provided (simulates right clicking on a node)
* one default menu plugin is provided to perform basic filesystem
operations (create/delete/move/copy files/directories)
* There's an API for adding your own keymappings
![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png)
Installation
------------
@ -66,10 +28,8 @@ Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:he
apt-vim install -y https://github.com/scrooloose/nerdtree.git
Faq
---
F.A.Q.
------
> Is there any support for `git` flags?

View File

@ -293,23 +293,26 @@ function! s:Bookmark.str()
endfunction
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1
" Make the node for this bookmark the new tree root
" Set the root of the given NERDTree to the node for this Bookmark. If a node
" for this Bookmark does not exist, a new one is initialized.
function! s:Bookmark.toRoot(nerdtree)
if self.validate()
try
let targetNode = self.getNode(a:nerdtree, 1)
let l:targetNode = self.getNode(a:nerdtree, 1)
call l:targetNode.closeChildren()
catch /^NERDTree.BookmarkedNodeNotFoundError/
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
let l:targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
endtry
call a:nerdtree.changeRoot(targetNode)
call a:nerdtree.changeRoot(l:targetNode)
endif
endfunction
" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1
" Make the node for this bookmark the new tree root
" Class method that makes the Bookmark with the given name the root of
" specified NERDTree.
function! s:Bookmark.ToRoot(name, nerdtree)
let bookmark = s:Bookmark.BookmarkFor(a:name)
call bookmark.toRoot(a:nerdtree)
let l:bookmark = s:Bookmark.BookmarkFor(a:name)
call l:bookmark.toRoot(a:nerdtree)
endfunction
" FUNCTION: Bookmark.validate() {{{1

View File

@ -1,15 +1,20 @@
"CLASS: Opener
"============================================================
" ============================================================================
" CLASS: Opener
"
" The Opener class defines an API for "opening" operations.
" ============================================================================
let s:Opener = {}
let g:NERDTreeOpener = s:Opener
"FUNCTION: s:Opener._bufInWindows(bnum){{{1
"[[STOLEN FROM VTREEEXPLORER.VIM]]
"Determine the number of windows open to this buffer number.
"Care of Yegappan Lakshman. Thanks!
" FUNCTION: s:Opener._bufInWindows(bnum) {{{1
" [[STOLEN FROM VTREEEXPLORER.VIM]]
" Determine the number of windows open to this buffer number.
" Care of Yegappan Lakshman. Thanks!
"
"Args:
"bnum: the subject buffers buffer number
" Args:
" bnum: the subject buffers buffer number
function! s:Opener._bufInWindows(bnum)
let cnt = 0
let winnum = 1
@ -26,14 +31,15 @@ function! s:Opener._bufInWindows(bnum)
return cnt
endfunction
"FUNCTION: Opener._checkToCloseTree(newtab) {{{1
"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
"if the tree should be closed now.
" FUNCTION: Opener._checkToCloseTree(newtab) {{{1
" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
" if the tree should be closed now.
"
"Args:
"a:newtab - boolean. If set, only close the tree now if we are opening the
"target in a new tab. This is needed because we have to close tree before we
"leave the tab
" Args:
" a:newtab - boolean. If set, only close the tree now if we are opening the
" target in a new tab. This is needed because we have to close tree before we
" leave the tab
function! s:Opener._checkToCloseTree(newtab)
if self._keepopen
return
@ -44,9 +50,8 @@ function! s:Opener._checkToCloseTree(newtab)
endif
endfunction
"FUNCTION: s:Opener._firstUsableWindow(){{{1
"find the window number of the first normal window
" FUNCTION: s:Opener._firstUsableWindow() {{{1
" find the window number of the first normal window
function! s:Opener._firstUsableWindow()
let i = 1
while i <= winnr("$")
@ -62,7 +67,7 @@ function! s:Opener._firstUsableWindow()
return -1
endfunction
"FUNCTION: Opener._gotoTargetWin() {{{1
" FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin()
if b:NERDTree.isWinTree()
if self._where == 'v'
@ -89,12 +94,12 @@ function! s:Opener._gotoTargetWin()
endif
endfunction
"FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1
"Returns 0 if opening a file from the tree in the given window requires it to
"be split, 1 otherwise
" FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1
" Returns 0 if opening a file from the tree in the given window requires it to
" be split, 1 otherwise
"
"Args:
"winnumber: the number of the window in question
" Args:
" winnumber: the number of the window in question
function! s:Opener._isWindowUsable(winnumber)
"gotta split if theres only one window (i.e. the NERD tree)
if winnr("$") ==# 1
@ -120,21 +125,21 @@ function! s:Opener._isWindowUsable(winnumber)
return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2
endfunction
"FUNCTION: Opener.New(path, opts) {{{1
"Args:
" FUNCTION: Opener.New(path, opts) {{{1
" Args:
"
"a:path: The path object that is to be opened.
" a:path: The path object that is to be opened.
"
"a:opts:
" a:opts:
"
"A dictionary containing the following keys (all optional):
" 'where': Specifies whether the node should be opened in new split/tab or in
" the previous window. Can be either 'v' or 'h' or 't' (for open in
" new tab)
" 'reuse': if a window is displaying the file then jump the cursor there. Can
" 'all', 'currenttab' or empty to not reuse.
" 'keepopen': dont close the tree window
" 'stay': open the file, but keep the cursor in the tree win
" A dictionary containing the following keys (all optional):
" 'where': Specifies whether the node should be opened in new split/tab or in
" the previous window. Can be either 'v' or 'h' or 't' (for open in
" new tab)
" 'reuse': if a window is displaying the file then jump the cursor there. Can
" 'all', 'currenttab' or empty to not reuse.
" 'keepopen': dont close the tree window
" 'stay': open the file, but keep the cursor in the tree win
function! s:Opener.New(path, opts)
let newObj = copy(self)
@ -155,7 +160,7 @@ function! s:Opener.New(path, opts)
return newObj
endfunction
"FUNCTION: Opener._newSplit() {{{1
" FUNCTION: Opener._newSplit() {{{1
function! s:Opener._newSplit()
" Save the user's settings for splitbelow and splitright
let savesplitbelow=&splitbelow
@ -215,23 +220,27 @@ function! s:Opener._newSplit()
let &splitright=savesplitright
endfunction
"FUNCTION: Opener._newVSplit() {{{1
" FUNCTION: Opener._newVSplit() {{{1
function! s:Opener._newVSplit()
let winwidth = winwidth(".")
if winnr("$")==#1
let winwidth = g:NERDTreeWinSize
let l:winwidth = winwidth('.')
if winnr('$') == 1
let l:winwidth = g:NERDTreeWinSize
endif
call nerdtree#exec("wincmd p")
call nerdtree#exec('wincmd p')
vnew
"resize the nerd tree back to the original size
let l:currentWindowNumber = winnr()
" Restore the NERDTree to its original width.
call g:NERDTree.CursorToTreeWin()
exec("silent vertical resize ". winwidth)
call nerdtree#exec('wincmd p')
execute 'silent vertical resize ' . l:winwidth
call nerdtree#exec(l:currentWindowNumber . 'wincmd w')
endfunction
"FUNCTION: Opener.open(target) {{{1
" FUNCTION: Opener.open(target) {{{1
function! s:Opener.open(target)
if self._path.isDirectory
call self._openDirectory(a:target)
@ -240,7 +249,7 @@ function! s:Opener.open(target)
endif
endfunction
"FUNCTION: Opener._openFile() {{{1
" FUNCTION: Opener._openFile() {{{1
function! s:Opener._openFile()
if self._reuseWindow()
return
@ -253,7 +262,7 @@ function! s:Opener._openFile()
endif
endfunction
"FUNCTION: Opener._openDirectory(node) {{{1
" FUNCTION: Opener._openDirectory(node) {{{1
function! s:Opener._openDirectory(node)
if self._nerdtree.isWinTree()
call self._gotoTargetWin()
@ -274,7 +283,7 @@ function! s:Opener._openDirectory(node)
endif
endfunction
"FUNCTION: Opener._previousWindow() {{{1
" FUNCTION: Opener._previousWindow() {{{1
function! s:Opener._previousWindow()
if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1
call self._newSplit()
@ -294,16 +303,16 @@ function! s:Opener._previousWindow()
endif
endfunction
"FUNCTION: Opener._restoreCursorPos(){{{1
" FUNCTION: Opener._restoreCursorPos() {{{1
function! s:Opener._restoreCursorPos()
call nerdtree#exec('normal ' . self._tabnr . 'gt')
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w')
endfunction
"FUNCTION: Opener._reuseWindow(){{{1
"put the cursor in the first window we find for this file
" FUNCTION: Opener._reuseWindow() {{{1
" put the cursor in the first window we find for this file
"
"return 1 if we were successful
" return 1 if we were successful
function! s:Opener._reuseWindow()
if empty(self._reuse)
return 0
@ -334,7 +343,7 @@ function! s:Opener._reuseWindow()
return 0
endfunction
"FUNCTION: Opener._saveCursorPos(){{{1
" FUNCTION: Opener._saveCursorPos() {{{1
function! s:Opener._saveCursorPos()
let self._bufnr = bufnr("")
let self._tabnr = tabpagenr()

View File

@ -1,13 +1,20 @@
"we need to use this number many times for sorting... so we calculate it only
"once here
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
" ============================================================================
" CLASS: Path
"
" The Path class provides an abstracted representation of a file system
" pathname. Various operations on pathnames are provided and a number of
" representations of a given path name can be accessed here.
" ============================================================================
" This constant is used throughout this script for sorting purposes.
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
lockvar s:NERDTreeSortStarIndex
"CLASS: Path
"============================================================
let s:Path = {}
let g:NERDTreePath = s:Path
"FUNCTION: Path.AbsolutePathFor(str) {{{1
" FUNCTION: Path.AbsolutePathFor(str) {{{1
function! s:Path.AbsolutePathFor(str)
let prependCWD = 0
if nerdtree#runningWindows()
@ -24,7 +31,7 @@ function! s:Path.AbsolutePathFor(str)
return toReturn
endfunction
"FUNCTION: Path.bookmarkNames() {{{1
" FUNCTION: Path.bookmarkNames() {{{1
function! s:Path.bookmarkNames()
if !exists("self._bookmarkNames")
call self.cacheDisplayString()
@ -32,7 +39,7 @@ function! s:Path.bookmarkNames()
return self._bookmarkNames
endfunction
"FUNCTION: Path.cacheDisplayString() {{{1
" FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self.getLastPathComponent(1)
@ -59,7 +66,7 @@ function! s:Path.cacheDisplayString() abort
endif
endfunction
"FUNCTION: Path.changeToDir() {{{1
" FUNCTION: Path.changeToDir() {{{1
function! s:Path.changeToDir()
let dir = self.str({'format': 'Cd'})
if self.isDirectory ==# 0
@ -74,16 +81,16 @@ function! s:Path.changeToDir()
endtry
endfunction
"FUNCTION: Path.compareTo() {{{1
" FUNCTION: Path.compareTo() {{{1
"
"Compares this Path to the given path and returns 0 if they are equal, -1 if
"this Path is "less than" the given path, or 1 if it is "greater".
" Compares this Path to the given path and returns 0 if they are equal, -1 if
" this Path is "less than" the given path, or 1 if it is "greater".
"
"Args:
"path: the path object to compare this to
" Args:
" path: the path object to compare this to
"
"Return:
"1, -1 or 0
" Return:
" 1, -1 or 0
function! s:Path.compareTo(path)
let thisPath = self.getLastPathComponent(1)
let thatPath = a:path.getLastPathComponent(1)
@ -118,16 +125,16 @@ function! s:Path.compareTo(path)
endif
endfunction
"FUNCTION: Path.Create(fullpath) {{{1
" FUNCTION: Path.Create(fullpath) {{{1
"
"Factory method.
" Factory method.
"
"Creates a path object with the given path. The path is also created on the
"filesystem. If the path already exists, a NERDTree.Path.Exists exception is
"thrown. If any other errors occur, a NERDTree.Path exception is thrown.
" Creates a path object with the given path. The path is also created on the
" filesystem. If the path already exists, a NERDTree.Path.Exists exception is
" thrown. If any other errors occur, a NERDTree.Path exception is thrown.
"
"Args:
"fullpath: the full filesystem path to the file/dir to create
" Args:
" fullpath: the full filesystem path to the file/dir to create
function! s:Path.Create(fullpath)
"bail if the a:fullpath already exists
if isdirectory(a:fullpath) || filereadable(a:fullpath)
@ -155,12 +162,12 @@ function! s:Path.Create(fullpath)
return s:Path.New(a:fullpath)
endfunction
"FUNCTION: Path.copy(dest) {{{1
" FUNCTION: Path.copy(dest) {{{1
"
"Copies the file/dir represented by this Path to the given location
" Copies the file/dir represented by this Path to the given location
"
"Args:
"dest: the location to copy this dir/file to
" Args:
" dest: the location to copy this dir/file to
function! s:Path.copy(dest)
if !s:Path.CopyingSupported()
throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS"
@ -181,20 +188,20 @@ function! s:Path.copy(dest)
endif
endfunction
"FUNCTION: Path.CopyingSupported() {{{1
" FUNCTION: Path.CopyingSupported() {{{1
"
"returns 1 if copying is supported for this OS
" returns 1 if copying is supported for this OS
function! s:Path.CopyingSupported()
return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd'))
endfunction
"FUNCTION: Path.copyingWillOverwrite(dest) {{{1
" FUNCTION: Path.copyingWillOverwrite(dest) {{{1
"
"returns 1 if copy this path to the given location will cause files to
"overwritten
" returns 1 if copy this path to the given location will cause files to
" overwritten
"
"Args:
"dest: the location this path will be copied to
" Args:
" dest: the location this path will be copied to
function! s:Path.copyingWillOverwrite(dest)
if filereadable(a:dest)
return 1
@ -208,13 +215,13 @@ function! s:Path.copyingWillOverwrite(dest)
endif
endfunction
"FUNCTION: Path.createParentDirectories(path) {{{1
" FUNCTION: Path.createParentDirectories(path) {{{1
"
"create parent directories for this path if needed
"without throwing any errors if those directories already exist
" create parent directories for this path if needed
" without throwing any errors if those directories already exist
"
"Args:
"path: full path of the node whose parent directories may need to be created
" Args:
" path: full path of the node whose parent directories may need to be created
function! s:Path.createParentDirectories(path)
let dir_path = fnamemodify(a:path, ':h')
if !isdirectory(dir_path)
@ -222,11 +229,11 @@ function! s:Path.createParentDirectories(path)
endif
endfunction
"FUNCTION: Path.delete() {{{1
" FUNCTION: Path.delete() {{{1
"
"Deletes the file or directory represented by this path.
" Deletes the file or directory represented by this path.
"
"Throws NERDTree.Path.Deletion exceptions
" Throws NERDTree.Path.Deletion exceptions
function! s:Path.delete()
if self.isDirectory
@ -250,10 +257,10 @@ function! s:Path.delete()
endfor
endfunction
"FUNCTION: Path.displayString() {{{1
" FUNCTION: Path.displayString() {{{1
"
"Returns a string that specifies how the path should be represented as a
"string
" Returns a string that specifies how the path should be represented as a
" string
function! s:Path.displayString()
if self.cachedDisplayString ==# ""
call self.cacheDisplayString()
@ -262,14 +269,14 @@ function! s:Path.displayString()
return self.cachedDisplayString
endfunction
"FUNCTION: Path.edit() {{{1
" FUNCTION: Path.edit() {{{1
function! s:Path.edit()
exec "edit " . self.str({'format': 'Edit'})
endfunction
"FUNCTION: Path.extractDriveLetter(fullpath) {{{1
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
"
"If running windows, cache the drive letter for this path
" If running windows, cache the drive letter for this path
function! s:Path.extractDriveLetter(fullpath)
if nerdtree#runningWindows()
if a:fullpath =~ '^\(\\\\\|\/\/\)'
@ -285,14 +292,14 @@ function! s:Path.extractDriveLetter(fullpath)
endfunction
"FUNCTION: Path.exists() {{{1
"return 1 if this path points to a location that is readable or is a directory
" FUNCTION: Path.exists() {{{1
" return 1 if this path points to a location that is readable or is a directory
function! s:Path.exists()
let p = self.str()
return filereadable(p) || isdirectory(p)
endfunction
"FUNCTION: Path._escChars() {{{1
" FUNCTION: Path._escChars() {{{1
function! s:Path._escChars()
if nerdtree#runningWindows()
return " `\|\"#%&,?()\*^<>$"
@ -301,12 +308,12 @@ function! s:Path._escChars()
return " \\`\|\"#%&,?()\*^<>[]$"
endfunction
"FUNCTION: Path.getDir() {{{1
" FUNCTION: Path.getDir() {{{1
"
"Returns this path if it is a directory, else this paths parent.
" Returns this path if it is a directory, else this paths parent.
"
"Return:
"a Path object
" Return:
" a Path object
function! s:Path.getDir()
if self.isDirectory
return self
@ -315,12 +322,12 @@ function! s:Path.getDir()
endif
endfunction
"FUNCTION: Path.getParent() {{{1
" FUNCTION: Path.getParent() {{{1
"
"Returns a new path object for this paths parent
" Returns a new path object for this paths parent
"
"Return:
"a new Path object
" Return:
" a new Path object
function! s:Path.getParent()
if nerdtree#runningWindows()
let path = self.drive . '\' . join(self.pathSegments[0:-2], '\')
@ -331,13 +338,13 @@ function! s:Path.getParent()
return s:Path.New(path)
endfunction
"FUNCTION: Path.getLastPathComponent(dirSlash) {{{1
" FUNCTION: Path.getLastPathComponent(dirSlash) {{{1
"
"Gets the last part of this path.
" Gets the last part of this path.
"
"Args:
"dirSlash: if 1 then a trailing slash will be added to the returned value for
"directory nodes.
" Args:
" dirSlash: if 1 then a trailing slash will be added to the returned value for
" directory nodes.
function! s:Path.getLastPathComponent(dirSlash)
if empty(self.pathSegments)
return ''
@ -349,8 +356,8 @@ function! s:Path.getLastPathComponent(dirSlash)
return toReturn
endfunction
"FUNCTION: Path.getSortOrderIndex() {{{1
"returns the index of the pattern in g:NERDTreeSortOrder that this path matches
" FUNCTION: Path.getSortOrderIndex() {{{1
" returns the index of the pattern in g:NERDTreeSortOrder that this path matches
function! s:Path.getSortOrderIndex()
let i = 0
while i < len(g:NERDTreeSortOrder)
@ -362,8 +369,8 @@ function! s:Path.getSortOrderIndex()
return s:NERDTreeSortStarIndex
endfunction
"FUNCTION: Path._splitChunks(path) {{{1
"returns a list of path chunks
" FUNCTION: Path._splitChunks(path) {{{1
" returns a list of path chunks
function! s:Path._splitChunks(path)
let chunks = split(a:path, '\(\D\+\|\d\+\)\zs')
let i = 0
@ -377,8 +384,8 @@ function! s:Path._splitChunks(path)
return chunks
endfunction
"FUNCTION: Path.getSortKey() {{{1
"returns a key used in compare function for sorting
" FUNCTION: Path.getSortKey() {{{1
" returns a key used in compare function for sorting
function! s:Path.getSortKey()
if !exists("self._sortKey")
let path = self.getLastPathComponent(1)
@ -399,14 +406,14 @@ function! s:Path.getSortKey()
endfunction
"FUNCTION: Path.isUnixHiddenFile() {{{1
"check for unix hidden files
" FUNCTION: Path.isUnixHiddenFile() {{{1
" check for unix hidden files
function! s:Path.isUnixHiddenFile()
return self.getLastPathComponent(0) =~# '^\.'
endfunction
"FUNCTION: Path.isUnixHiddenPath() {{{1
"check for unix path with hidden components
" FUNCTION: Path.isUnixHiddenPath() {{{1
" check for unix path with hidden components
function! s:Path.isUnixHiddenPath()
if self.getLastPathComponent(0) =~# '^\.'
return 1
@ -420,8 +427,8 @@ function! s:Path.isUnixHiddenPath()
endif
endfunction
"FUNCTION: Path.ignore(nerdtree) {{{1
"returns true if this path should be ignored
" FUNCTION: Path.ignore(nerdtree) {{{1
" returns true if this path should be ignored
function! s:Path.ignore(nerdtree)
"filter out the user specified paths to ignore
if a:nerdtree.ui.isIgnoreFilterEnabled()
@ -450,8 +457,8 @@ function! s:Path.ignore(nerdtree)
return 0
endfunction
"FUNCTION: Path._ignorePatternMatches(pattern) {{{1
"returns true if this path matches the given ignore pattern
" FUNCTION: Path._ignorePatternMatches(pattern) {{{1
" returns true if this path matches the given ignore pattern
function! s:Path._ignorePatternMatches(pattern)
let pat = a:pattern
if strpart(pat,len(pat)-7) == '[[dir]]'
@ -469,10 +476,10 @@ function! s:Path._ignorePatternMatches(pattern)
return self.getLastPathComponent(0) =~# pat
endfunction
"FUNCTION: Path.isAncestor(path) {{{1
"return 1 if this path is somewhere above the given path in the filesystem.
" FUNCTION: Path.isAncestor(path) {{{1
" return 1 if this path is somewhere above the given path in the filesystem.
"
"a:path should be a dir
" a:path should be a dir
function! s:Path.isAncestor(path)
if !self.isDirectory
return 0
@ -483,8 +490,8 @@ function! s:Path.isAncestor(path)
return stridx(that, this) == 0
endfunction
"FUNCTION: Path.isUnder(path) {{{1
"return 1 if this path is somewhere under the given path in the filesystem.
" FUNCTION: Path.isUnder(path) {{{1
" return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path)
if a:path.isDirectory == 0
return 0
@ -495,7 +502,7 @@ function! s:Path.isUnder(path)
return stridx(this, that . s:Path.Slash()) == 0
endfunction
"FUNCTION: Path.JoinPathStrings(...) {{{1
" FUNCTION: Path.JoinPathStrings(...) {{{1
function! s:Path.JoinPathStrings(...)
let components = []
for i in a:000
@ -504,19 +511,19 @@ function! s:Path.JoinPathStrings(...)
return '/' . join(components, '/')
endfunction
"FUNCTION: Path.equals() {{{1
" FUNCTION: Path.equals() {{{1
"
"Determines whether 2 path objects are "equal".
"They are equal if the paths they represent are the same
" Determines whether 2 path objects are "equal".
" They are equal if the paths they represent are the same
"
"Args:
"path: the other path obj to compare this with
" Args:
" path: the other path obj to compare this with
function! s:Path.equals(path)
return self.str() ==# a:path.str()
endfunction
"FUNCTION: Path.New() {{{1
"The Constructor for the Path object
" FUNCTION: Path.New() {{{1
" The Constructor for the Path object
function! s:Path.New(path)
let newPath = copy(self)
@ -528,26 +535,37 @@ function! s:Path.New(path)
return newPath
endfunction
"FUNCTION: Path.Slash() {{{1
"return the slash to use for the current OS
" FUNCTION: Path.Slash() {{{1
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! s:Path.Slash()
return nerdtree#runningWindows() ? '\' : '/'
if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
return '/'
endif
return '\'
endif
return '/'
endfunction
"FUNCTION: Path.Resolve() {{{1
"Invoke the vim resolve() function and return the result
"This is necessary because in some versions of vim resolve() removes trailing
"slashes while in other versions it doesn't. This always removes the trailing
"slash
" FUNCTION: Path.Resolve() {{{1
" Invoke the vim resolve() function and return the result
" This is necessary because in some versions of vim resolve() removes trailing
" slashes while in other versions it doesn't. This always removes the trailing
" slash
function! s:Path.Resolve(path)
let tmp = resolve(a:path)
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
endfunction
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
" FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
"
"
"Throws NERDTree.Path.InvalidArguments exception.
" Throws NERDTree.Path.InvalidArguments exception.
function! s:Path.readInfoFromDisk(fullpath)
call self.extractDriveLetter(a:fullpath)
@ -598,22 +616,22 @@ function! s:Path.readInfoFromDisk(fullpath)
endif
endfunction
"FUNCTION: Path.refresh(nerdtree) {{{1
" FUNCTION: Path.refresh(nerdtree) {{{1
function! s:Path.refresh(nerdtree)
call self.readInfoFromDisk(self.str())
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
"FUNCTION: Path.refreshFlags(nerdtree) {{{1
" FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
"FUNCTION: Path.rename() {{{1
" FUNCTION: Path.rename() {{{1
"
"Renames this node on the filesystem
" Renames this node on the filesystem
function! s:Path.rename(newPath)
if a:newPath ==# ''
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
@ -632,28 +650,28 @@ function! s:Path.rename(newPath)
call g:NERDTreeBookmark.Write()
endfunction
"FUNCTION: Path.str() {{{1
" FUNCTION: Path.str() {{{1
" Return a string representation of this Path object.
"
"Returns a string representation of this Path
" Args:
" This function takes a single dictionary (optional) with keys and values that
" specify how the returned pathname should be formatted.
"
"Takes an optional dictionary param to specify how the output should be
"formatted.
"
"The dict may have the following keys:
" The dictionary may have the following keys:
" 'format'
" 'escape'
" 'truncateTo'
"
"The 'format' key may have a value of:
" 'Cd' - a string to be used with the :cd command
" 'Edit' - a string to be used with :e :sp :new :tabedit etc
" 'UI' - a string used in the NERD tree UI
" The 'format' key may have a value of:
" 'Cd' - a string to be used with ":cd" and similar commands
" 'Edit' - a string to be used with ":edit" and similar commands
" 'UI' - a string to be displayed in the NERDTree user interface
"
"The 'escape' key, if specified will cause the output to be escaped with
"shellescape()
" The 'escape' key, if specified, will cause the output to be escaped with
" Vim's internal "shellescape()" function.
"
"The 'truncateTo' key causes the resulting string to be truncated to the value
"'truncateTo' maps to. A '<' char will be prepended.
" The 'truncateTo' key shortens the length of the path to that given by the
" value associated with 'truncateTo'. A '<' is prepended.
function! s:Path.str(...)
let options = a:0 ? a:1 : {}
let toReturn = ""
@ -688,7 +706,7 @@ function! s:Path.str(...)
return toReturn
endfunction
"FUNCTION: Path._strForUI() {{{1
" FUNCTION: Path._strForUI() {{{1
function! s:Path._strForUI()
let toReturn = '/' . join(self.pathSegments, '/')
if self.isDirectory && toReturn != '/'
@ -697,37 +715,37 @@ function! s:Path._strForUI()
return toReturn
endfunction
"FUNCTION: Path._strForCd() {{{1
"
" returns a string that can be used with :cd
" FUNCTION: Path._strForCd() {{{1
" Return a string representation of this Path that is suitable for use as an
" argument to Vim's internal ":cd" command.
function! s:Path._strForCd()
return escape(self.str(), self._escChars())
return fnameescape(self.str())
endfunction
"FUNCTION: Path._strForEdit() {{{1
"
"Return: the string for this path that is suitable to be used with the :edit
"command
" FUNCTION: Path._strForEdit() {{{1
" Return a string representation of this Path that is suitable for use as an
" argument to Vim's internal ":edit" command.
function! s:Path._strForEdit()
let p = escape(self.str(), self._escChars())
"make it relative
let p = fnamemodify(p, ':.')
" Make the path relative to the current working directory, if possible.
let l:result = fnamemodify(self.str(), ':.')
"handle the edge case where the file begins with a + (vim interprets
"the +foo in `:e +foo` as an option to :edit)
if p[0] == "+"
let p = '\' . p
" On Windows, the drive letter may be removed by "fnamemodify()". Add it
" back, if necessary.
if nerdtree#runningWindows() && l:result[0] == s:Path.Slash()
let l:result = self.drive . l:result
endif
if p ==# ''
let p = '.'
let l:result = fnameescape(l:result)
if empty(l:result)
let l:result = '.'
endif
return p
return l:result
endfunction
"FUNCTION: Path._strForGlob() {{{1
" FUNCTION: Path._strForGlob() {{{1
function! s:Path._strForGlob()
let lead = s:Path.Slash()
@ -744,24 +762,22 @@ function! s:Path._strForGlob()
return toReturn
endfunction
"FUNCTION: Path._str() {{{1
"
"Gets the string path for this path object that is appropriate for the OS.
"EG, in windows c:\foo\bar
" in *nix /foo/bar
" FUNCTION: Path._str() {{{1
" Return the absolute pathname associated with this Path object. The pathname
" returned is appropriate for the underlying file system.
function! s:Path._str()
let lead = s:Path.Slash()
let l:separator = s:Path.Slash()
let l:leader = l:separator
"if we are running windows then slap a drive letter on the front
if nerdtree#runningWindows()
let lead = self.drive . '\'
let l:leader = self.drive . l:separator
endif
return lead . join(self.pathSegments, s:Path.Slash())
return l:leader . join(self.pathSegments, l:separator)
endfunction
"FUNCTION: Path.strTrunk() {{{1
"Gets the path without the last segment on the end.
" FUNCTION: Path.strTrunk() {{{1
" Gets the path without the last segment on the end.
function! s:Path.strTrunk()
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
endfunction
@ -782,13 +798,13 @@ function! s:Path.tabnr()
return 0
endfunction
"FUNCTION: Path.WinToUnixPath(pathstr){{{1
"Takes in a windows path and returns the unix equiv
" FUNCTION: Path.WinToUnixPath(pathstr){{{1
" Takes in a windows path and returns the unix equiv
"
"A class level method
" A class level method
"
"Args:
"pathstr: the windows path to convert
" Args:
" pathstr: the windows path to convert
function! s:Path.WinToUnixPath(pathstr)
if !nerdtree#runningWindows()
return a:pathstr

View File

@ -56,12 +56,12 @@ function! s:TreeDirNode.close()
endfunction
" FUNCTION: TreeDirNode.closeChildren() {{{1
" Closes all the child dir nodes of this node
" Recursively close any directory nodes that are descendants of this node.
function! s:TreeDirNode.closeChildren()
for i in self.children
if i.path.isDirectory
call i.close()
call i.closeChildren()
for l:child in self.children
if l:child.path.isDirectory
call l:child.close()
call l:child.closeChildren()
endif
endfor
endfunction
@ -220,13 +220,6 @@ function! s:TreeDirNode.getChildIndex(path)
return -1
endfunction
" FUNCTION: TreeDirNode.getDirChildren() {{{1
" Return a list of all child nodes from "self.children" that are of type
" TreeDirNode.
function! s:TreeDirNode.getDirChildren()
return filter(self.children, 'v:val.path.isDirectory == 1')
endfunction
" FUNCTION: TreeDirNode._glob(pattern, all) {{{1
" Return a list of strings naming the descendants of the directory in this
" TreeDirNode object that match the specified glob pattern.
@ -250,7 +243,7 @@ function! s:TreeDirNode._glob(pattern, all)
let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.')
" On Windows, the drive letter may be removed by "fnamemodify()".
if nerdtree#runningWindows() && l:pathSpec[0] == '\'
if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash()
let l:pathSpec = self.path.drive . l:pathSpec
endif
endif

View File

@ -21,7 +21,7 @@ endfunction
"prints out the quick help
function! s:UI._dumpHelp()
if self.getShowHelp()
let help = "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n"
let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n"
let help .= "\" ============================\n"
let help .= "\" File node mappings~\n"
let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"

View File

@ -212,14 +212,40 @@ endfunction
" FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information avaialable")
let l:node = g:NERDTreeFileNode.GetSelected()
if !empty(l:node)
let l:save_shell = &shell
set shell&
if exists('+shellslash')
let l:save_shellslash = &shellslash
set noshellslash
endif
let l:command = 'DIR /Q '
\ . shellescape(l:node.path.str())
\ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'
let l:metadata = split(system(l:command), "\n")
if v:shell_error == 0
call nerdtree#echo(l:metadata[0])
else
call nerdtree#echoError('shell command failed')
endif
let &shell = l:save_shell
if exists('l:save_shellslash')
let &shellslash = l:save_shellslash
endif
return
endif
call nerdtree#echo('node not recognized')
endfunction
" FUNCTION: NERDTreeCopyNode() {{{1

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -8,7 +8,7 @@ execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
"quickhelp syntax elements
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1
syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1
syn match NERDTreeHelpTitle #" .*\~$#ms=s+2,me=e-1
syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1
syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
@ -22,8 +22,8 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'