diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index c2f7f1c..0e509b2 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -15,7 +15,7 @@ function! nerdtree#version(...) let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) let l:line = 0 while l:line <= len(l:changelog) - if l:changelog[l:line] =~ '\d\+\.\d\+' + if l:changelog[l:line] =~# '\d\+\.\d\+' let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') break @@ -122,15 +122,15 @@ function! nerdtree#compareNodesBySortKey(n1, n2) " Compare chunks upto common length. " If chunks have different type, the one which has " integer type is the lesser. - if type(sortKey1[i]) == type(sortKey2[i]) + if type(sortKey1[i]) ==# type(sortKey2[i]) if sortKey1[i] <# sortKey2[i] return - 1 elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif type(sortKey1[i]) == v:t_number + elseif type(sortKey1[i]) ==# v:t_number return -1 - elseif type(sortKey2[i]) == v:t_number + elseif type(sortKey2[i]) ==# v:t_number return 1 endif let i = i + 1 @@ -175,7 +175,7 @@ endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 function! nerdtree#has_opt(options, name) - return has_key(a:options, a:name) && a:options[a:name] == 1 + return has_key(a:options, a:name) && a:options[a:name] ==# 1 endfunction " FUNCTION: nerdtree#loadClassFiles() {{{2 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 96d0fa7..b500230 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -146,7 +146,7 @@ endfunction " Associate the current node with the given name function! nerdtree#ui_glue#bookmarkNode(...) let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} let name = a:1 if empty(name) let name = currentNode.path.getLastPathComponent(0) @@ -187,7 +187,7 @@ endfunction function! nerdtree#ui_glue#clearBookmarks(bookmarks) if a:bookmarks ==# '' let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} call currentNode.clearBookmarks() endif else @@ -236,7 +236,7 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1 exec 'buffer ' . b:NERDTree.previousBuf() else if winnr('$') > 1 @@ -258,7 +258,7 @@ function! s:deleteBookmark(bookmark) echo | redraw let l:selection = confirm(l:message, l:choices, 1, 'Warning') - if l:selection != 1 + if l:selection !=# 1 call nerdtree#echo('bookmark not deleted') return endif @@ -335,7 +335,7 @@ endfunction "Checks if the click should open the current node function! s:handleLeftClick() let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} "the dir arrows are multibyte chars, and vim's string functions only "deal with single bytes - so split the line up with the hack below and diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index ccb6f98..b457a8a 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -93,7 +93,7 @@ function! s:Bookmark.CacheBookmarks(silent) for i in bookmarkStrings "ignore blank lines - if i != '' + if i !=# '' let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') @@ -123,13 +123,13 @@ endfunction " option. Supports the s:Bookmark.SortBookmarksList() method. function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) let l:result = 0 - if g:NERDTreeBookmarksSort == 1 + if g:NERDTreeBookmarksSort ==# 1 if a:firstBookmark.name ? a:secondBookmark.name let l:result = 1 endif - elseif g:NERDTreeBookmarksSort == 2 + elseif g:NERDTreeBookmarksSort ==# 2 if a:firstBookmark.name <# a:secondBookmark.name let l:result = -1 elseif a:firstBookmark.name ># a:secondBookmark.name @@ -198,7 +198,7 @@ endfunction function! s:Bookmark.GetSelected() let line = getline('.') let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') - if name != line + if name !=# line try return s:Bookmark.BookmarkFor(name) catch /^NERDTree.BookmarkNotFoundError/ diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 5c96c61..f3268c2 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -53,7 +53,7 @@ function! s:KeyMap.bind() endif let keymapInvokeString = escape(keymapInvokeString, '\') - let premap = self.key == '' ? ' ' : ' ' + let premap = self.key ==# '' ? ' ' : ' ' exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' endfunction @@ -66,7 +66,7 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) == type(function('tr')) ? self.callback : function(self.callback) + let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) if a:0 call Callback(a:1) else @@ -143,7 +143,7 @@ function! s:KeyMap.Create(options) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) "dont override other mappings unless the 'override' option is given - if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + if get(opts, 'override', 0) ==# 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) return end diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index a3b168b..ca93efa 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -45,12 +45,12 @@ function! s:MenuController.showMenu() call self._restoreOptions() " Redraw when Ctrl-C or Esc is received. - if !l:done || self.selection == -1 + if !l:done || self.selection ==# -1 redraw! endif endtry - if self.selection != -1 + if self.selection !=# -1 let l:m = self._current() call l:m.execute() endif @@ -73,7 +73,7 @@ function! s:MenuController._echoPrompt() echo '=========================================================' for i in range(0, len(self.menuItems)-1) - if self.selection == i + if self.selection ==# i echo '> ' . self.menuItems[i].text else echo ' ' . self.menuItems[i].text @@ -92,20 +92,20 @@ endfunction "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) - if a:key == g:NERDTreeMenuDown + if a:key ==# g:NERDTreeMenuDown call self._cursorDown() - elseif a:key == g:NERDTreeMenuUp + elseif a:key ==# g:NERDTreeMenuUp call self._cursorUp() - elseif a:key == nr2char(27) "escape + elseif a:key ==# nr2char(27) "escape let self.selection = -1 return 1 - elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j + elseif a:key ==# "\r" || a:key ==# "\n" "enter and ctrl-j return 1 else let index = self._nextIndexFor(a:key) - if index != -1 + if index !=# -1 let self.selection = index - if len(self._allIndexesFor(a:key)) == 1 + if len(self._allIndexesFor(a:key)) ==# 1 return 1 endif endif @@ -120,7 +120,7 @@ function! s:MenuController._allIndexesFor(shortcut) let toReturn = [] for i in range(0, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut call add(toReturn, i) endif endfor @@ -133,13 +133,13 @@ endfunction "current cursor location and wraps around to the top again if need be function! s:MenuController._nextIndexFor(shortcut) for i in range(self.selection+1, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor for i in range(0, self.selection) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 03878a4..a48f6a8 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -37,13 +37,13 @@ function! s:NERDTree.Close() return endif - if winnr('$') != 1 + if winnr('$') !=# 1 " Use the window ID to identify the currently active window or fall " back on the buffer ID if win_getid/win_gotoid are not available, in " which case we'll focus an arbitrary window showing the buffer. let l:useWinId = exists('*win_getid') && exists('*win_gotoid') - if winnr() == s:NERDTree.GetWinNum() + if winnr() ==# s:NERDTree.GetWinNum() call nerdtree#exec('wincmd p', 1) let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') call nerdtree#exec('wincmd p', 1) @@ -160,17 +160,17 @@ endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 + return s:NERDTree.GetWinNum() !=# -1 endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 function! s:NERDTree.isTabTree() - return self._type == 'tab' + return self._type ==# 'tab' endfunction "FUNCTION: s:NERDTree.isWinTree() {{{1 function! s:NERDTree.isWinTree() - return self._type == 'window' + return self._type ==# 'window' endfunction "FUNCTION: s:NERDTree.MustBeOpen() {{{1 diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index d9a8868..d8dba34 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -45,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab) return endif - if (a:newtab && self._where == 't') || !a:newtab + if (a:newtab && self._where ==# 't') || !a:newtab call g:NERDTree.CloseIfQuitOnOpen() endif endfunction @@ -56,7 +56,7 @@ function! s:Opener._firstUsableWindow() let i = 1 while i <= winnr('$') let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# '' \ && !getwinvar(i, '&previewwindow') \ && (!getbufvar(bnum, '&modified') || &hidden) return i @@ -70,23 +70,23 @@ endfunction " FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() - if self._where == 'v' + if self._where ==# 'v' call self._newVSplit() - elseif self._where == 'h' + elseif self._where ==# 'h' call self._newSplit() - elseif self._where == 't' + elseif self._where ==# 't' tabnew endif else call self._checkToCloseTree(1) - if self._where == 'v' + if self._where ==# 'v' call self._newVSplit() - elseif self._where == 'h' + elseif self._where ==# 'h' call self._newSplit() - elseif self._where == 't' + elseif self._where ==# 't' tabnew - elseif self._where == 'p' + elseif self._where ==# 'p' call self._previousWindow() endif @@ -108,7 +108,7 @@ function! s:Opener._isWindowUsable(winnumber) let oldwinnr = winnr() call nerdtree#exec(a:winnumber . 'wincmd p', 1) - let specialWindow = getbufvar('%', '&buftype') != '' || getwinvar('%', '&previewwindow') + let specialWindow = getbufvar('%', '&buftype') !=# '' || getwinvar('%', '&previewwindow') let modified = &modified call nerdtree#exec(oldwinnr . 'wincmd p', 1) @@ -247,7 +247,7 @@ function! s:Opener._openDirectory(node) else if empty(self._where) call b:NERDTree.changeRoot(a:node) - elseif self._where == 't' + elseif self._where ==# 't' call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) @@ -296,13 +296,13 @@ function! s:Opener._reuseWindow() "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') - if winnr != -1 + if winnr !=# -1 call nerdtree#exec(winnr . 'wincmd w', 0) call self._checkToCloseTree(0) return 1 endif - if self._reuse == 'currenttab' + if self._reuse ==# 'currenttab' return 0 endif diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index a77331f..6a23c7b 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -25,7 +25,7 @@ function! s:Path.AbsolutePathFor(pathStr) if l:prependWorkingDir let l:result = getcwd() - if l:result[-1:] == s:Path.Slash() + if l:result[-1:] ==# s:Path.Slash() let l:result = l:result . a:pathStr else let l:result = l:result . s:Path.Slash() . a:pathStr @@ -57,7 +57,7 @@ function! s:Path.cacheDisplayString() abort call add(self._bookmarkNames, i.name) endif endfor - if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 + if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks ==# 1 let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' endif @@ -87,7 +87,7 @@ function! s:Path.changeToDir() endif try - if g:NERDTreeUseTCD && exists(':tcd') == 2 + if g:NERDTreeUseTCD && exists(':tcd') ==# 2 execute 'tcd ' . dir call nerdtree#echo("Tab's CWD is now: " . getcwd()) else @@ -201,7 +201,7 @@ function! s:Path.copy(dest) let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) let success = system(cmd) - if v:shell_error != 0 + if v:shell_error !=# 0 throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" endif endfunction @@ -258,7 +258,7 @@ function! s:Path.delete() let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) let success = system(cmd) - if v:shell_error != 0 + if v:shell_error !=# 0 throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" endif else @@ -269,7 +269,7 @@ function! s:Path.delete() let success = delete(self.str()) endif - if success != 0 + if success !=# 0 throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" endif endif @@ -303,7 +303,7 @@ endfunction " If running windows, cache the drive letter for this path function! s:Path.extractDriveLetter(fullpath) if nerdtree#runningWindows() - if a:fullpath =~ '^\(\\\\\|\/\/\)' + if a:fullpath =~# '^\(\\\\\|\/\/\)' "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') let self.drive = substitute(self.drive, '/', '\', 'g') @@ -402,7 +402,7 @@ function! s:Path._splitChunks(path) let i = 0 while i < len(chunks) "convert number literals to numbers - if match(chunks[i], '^\d\+$') == 0 + if match(chunks[i], '^\d\+$') ==# 0 let chunks[i] = str2nr(chunks[i]) endif let i = i + 1 @@ -418,16 +418,16 @@ function! s:Path.getSortKey() let metadata = [] for tag in g:NERDTreeSortOrder if tag =~? '\[\[-\?timestamp\]\]' - let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[-\?size\]\]' - let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[extension\]\]' let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') - let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)] + let metadata += [self.isDirectory ? '' : (extension ==# '' ? nr2char(str2nr('0x10ffff',16)) : extension)] endif endfor - if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]' + if g:NERDTreeSortOrder[0] =~# '\[\[.*\]\]' " Apply tags' sorting first if specified first. let self._sortKey = metadata + [self.getSortOrderIndex()] else @@ -501,7 +501,7 @@ function! s:Path.ignore(nerdtree) endfor for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) == type(function('tr')) ? Callback : function(Callback) + let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback) if Callback({'path': self, 'nerdtree': a:nerdtree}) return 1 endif @@ -524,12 +524,12 @@ endfunction " 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]]' + if strpart(pat,len(pat)-7) ==# '[[dir]]' if !self.isDirectory return 0 endif let pat = strpart(pat,0, len(pat)-7) - elseif strpart(pat,len(pat)-8) == '[[file]]' + elseif strpart(pat,len(pat)-8) ==# '[[file]]' if self.isDirectory return 0 endif @@ -550,19 +550,19 @@ function! s:Path.isAncestor(path) let this = self.str() let that = a:path.str() - return stridx(that, this) == 0 + 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! s:Path.isUnder(path) - if a:path.isDirectory == 0 + if a:path.isDirectory ==# 0 return 0 endif let this = self.str() let that = a:path.str() - return stridx(this, that . s:Path.Slash()) == 0 + return stridx(this, that . s:Path.Slash()) ==# 0 endfunction " FUNCTION: Path.JoinPathStrings(...) {{{1 @@ -665,7 +665,7 @@ function! s:Path.readInfoFromDisk(fullpath) let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent "if the last part of the path is a symlink then flag it as such - let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) + let self.isSymLink = (s:Path.Resolve(hardPath) !=# hardPath) if self.isSymLink let self.symLinkDest = s:Path.Resolve(fullpath) @@ -706,7 +706,7 @@ function! s:Path.rename(newPath) call s:Path.createParentDirectories(a:newPath) let success = rename(self.str(), a:newPath) - if success != 0 + if success !=# 0 throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath endif call self.readInfoFromDisk(a:newPath) @@ -779,7 +779,7 @@ endfunction " FUNCTION: Path._strForUI() {{{1 function! s:Path._strForUI() let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' + if self.isDirectory && toReturn !=# '/' let toReturn = toReturn . '/' endif return toReturn @@ -802,7 +802,7 @@ function! s:Path._strForEdit() " On Windows, the drive letter may be removed by "fnamemodify()". Add it " back, if necessary. - if nerdtree#runningWindows() && l:result[0] == s:Path.Slash() + if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash() let l:result = self.drive . l:result endif diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index f59c064..1502ea7 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -14,7 +14,7 @@ let g:NERDTreeDirNode = s:TreeDirNode " Class method that returns the highest cached ancestor of the current root. function! s:TreeDirNode.AbsoluteTreeRoot() let currentNode = b:NERDTree.root - while currentNode.parent != {} + while currentNode.parent !=# {} let currentNode = currentNode.parent endwhile return currentNode @@ -100,7 +100,7 @@ function! s:TreeDirNode.displayString() let l:cascade = self.getCascade() for l:dirNode in l:cascade let l:next = l:dirNode.path.displayString() - let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','') + let l:label .= l:label ==# '' ? l:next : substitute(l:next,'^.','','') endfor " Select the appropriate open/closed status indicator symbol. @@ -133,7 +133,7 @@ function! s:TreeDirNode.findNode(path) if self.path.isDirectory for i in self.children let retVal = i.findNode(a:path) - if retVal != {} + if retVal !=# {} return retVal endif endfor @@ -169,7 +169,7 @@ function! s:TreeDirNode.getCascadeRoot() while !empty(l:parent) && !l:parent.isRoot() - if index(l:parent.getCascade(), self) == -1 + if index(l:parent.getCascade(), self) ==# -1 break endif @@ -258,7 +258,7 @@ endfunction " Return a list of all child nodes from 'self.children' that are of type " TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. function! s:TreeDirNode.getDirChildren() - return filter(copy(self.children), 'v:val.path.isDirectory == 1') + return filter(copy(self.children), 'v:val.path.isDirectory ==# 1') endfunction " FUNCTION: TreeDirNode._glob(pattern, all) {{{1 @@ -278,13 +278,13 @@ function! s:TreeDirNode._glob(pattern, all) " Construct a path specification such that globpath() will return " relative pathnames, if possible. - if self.path.str() == getcwd() + if self.path.str() ==# getcwd() let l:pathSpec = ',' else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') " On Windows, the drive letter may be removed by fnamemodify(). - if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() + if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash() let l:pathSpec = self.path.drive . l:pathSpec endif endif @@ -293,11 +293,11 @@ function! s:TreeDirNode._glob(pattern, all) " See ':h version7.txt' and ':h version8.txt' for details on the " development of the glob() and globpath() functions. - if v:version > 704 || (v:version == 704 && has('patch654')) + if v:version > 704 || (v:version ==# 704 && has('patch654')) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) - elseif v:version == 704 && has('patch279') + elseif v:version ==# 704 && has('patch279') let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) - elseif v:version > 702 || (v:version == 702 && has('patch051')) + elseif v:version > 702 || (v:version ==# 702 && has('patch051')) let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) let l:globList = split(l:globString, "\n") else @@ -315,13 +315,13 @@ function! s:TreeDirNode._glob(pattern, all) " If l:file has a trailing slash, then its :tail will be ''. Use " :h to drop the slash and the empty string after it; then use :t " to get the directory name. - if l:tail == '' + if l:tail ==# '' let l:tail = fnamemodify(l:file, ':h:t') endif - if l:tail == '.' || l:tail == '..' + if l:tail ==# '.' || l:tail ==# '..' call add(l:toRemove, l:file) - if len(l:toRemove) == 2 + if len(l:toRemove) ==# 2 break endif endif @@ -341,7 +341,7 @@ endfunction unlet s:TreeDirNode.GetSelected function! s:TreeDirNode.GetSelected() let currentDir = g:NERDTreeFileNode.GetSelected() - if currentDir != {} && !currentDir.isRoot() + if currentDir !=# {} && !currentDir.isRoot() if currentDir.path.isDirectory ==# 0 let currentDir = currentDir.parent endif @@ -373,7 +373,7 @@ endfunction " FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 " returns 1 if this node has any childre, 0 otherwise.. function! s:TreeDirNode.hasVisibleChildren() - return self.getVisibleChildCount() != 0 + return self.getVisibleChildCount() !=# 0 endfunction " FUNCTION: TreeDirNode.isCascadable() {{{1 @@ -383,7 +383,7 @@ endfunction " 2. If the parent is a symlink or is bookmarked, you end up with unparsable " text, and NERDTree cannot get the path of any child node. function! s:TreeDirNode.isCascadable() - if g:NERDTreeCascadeSingleChildDir == 0 + if g:NERDTreeCascadeSingleChildDir ==# 0 return 0 endif @@ -398,7 +398,7 @@ function! s:TreeDirNode.isCascadable() endfor let c = self.getVisibleChildren() - return len(c) == 1 && c[0].path.isDirectory + return len(c) ==# 1 && c[0].path.isDirectory endfunction " FUNCTION: TreeDirNode._initChildren() {{{1 @@ -447,7 +447,7 @@ endfunction " path: dir that the node represents " nerdtree: the tree the node belongs to function! s:TreeDirNode.New(path, nerdtree) - if a:path.isDirectory != 1 + if a:path.isDirectory !=# 1 throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' endif @@ -510,7 +510,7 @@ function! s:TreeDirNode.openAlong(...) while node.path.isDirectory call node.open(opts) let level += 1 - if node.getVisibleChildCount() == 1 + if node.getVisibleChildCount() ==# 1 let node = node.getChildByIndex(0, 1) else break @@ -567,7 +567,7 @@ function! s:TreeDirNode.refresh() "create a new path and see if it exists in this nodes children let path = g:NERDTreePath.New(i) let newNode = self.getChild(path) - if newNode != {} + if newNode !=# {} call newNode.refresh() call add(newChildNodes, newNode) @@ -622,7 +622,7 @@ function! s:TreeDirNode.reveal(path, ...) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) " We may be looking for a newly-saved file that isn't in the tree yet. - if n == {} + if n ==# {} call self.refresh() let n = self.findNode(a:path) endif @@ -676,7 +676,7 @@ function! s:TreeDirNode.toggleOpen(...) if self.isOpen ==# 1 call self.close() else - if g:NERDTreeCascadeOpenSingleChildDir == 0 + if g:NERDTreeCascadeOpenSingleChildDir ==# 0 call self.open(opts) else call self.openAlong(opts) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6dc0d21..fc9db71 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -157,7 +157,7 @@ function! s:UI.getPath(ln) let rootLine = self.getRootLineNum() - if a:ln == rootLine + if a:ln ==# rootLine return self.nerdtree.root.path endif @@ -182,7 +182,7 @@ function! s:UI.getPath(ln) let curLineStripped = self._stripMarkup(curLine) " have we reached the top of the tree? - if lnum == rootLine + if lnum ==# rootLine let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir break endif @@ -219,7 +219,7 @@ function! s:UI.getLineNum(node) let l:currentLine = getline(l:lineNumber) let l:indentLevel = self._indentLevelFor(l:currentLine) - if l:indentLevel != l:currentPathComponent + if l:indentLevel !=# l:currentPathComponent continue endif @@ -229,7 +229,7 @@ function! s:UI.getLineNum(node) " Directories: If the current path 'starts with' the full path, then " either the paths are equal or the line is a cascade containing the " full path. - if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 + if l:fullPath[-1:] ==# '/' && stridx(l:currentPath, l:fullPath) ==# 0 return l:lineNumber endif @@ -240,7 +240,7 @@ function! s:UI.getLineNum(node) " Otherwise: If the full path starts with the current path and the " current path is a directory, we add a new path component. - if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/' + if stridx(l:fullPath, l:currentPath) ==# 0 && l:currentPath[-1:] ==# '/' let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') call add(l:pathComponents, l:currentLine) let l:currentPathComponent += 1 @@ -296,7 +296,7 @@ endfunction " FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 function! s:UI.isIgnoreFilterEnabled() - return self._ignoreEnabled == 1 + return self._ignoreEnabled ==# 1 endfunction " FUNCTION: s:UI.isMinimal() {{{1 @@ -317,7 +317,7 @@ function! s:UI._renderBookmarks() call cursor(line('.')+1, col('.')) endif - if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 + if g:NERDTreeBookmarksSort ==# 1 || g:NERDTreeBookmarksSort ==# 2 call g:NERDTreeBookmark.SortBookmarksList() endif @@ -443,13 +443,13 @@ function! s:UI.renderViewSavingPosition() " 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() + while currentNode !=# {} && !currentNode.isVisible() && !currentNode.isRoot() let currentNode = currentNode.parent endwhile call self.render() - if currentNode != {} + if currentNode !=# {} call currentNode.putCursorHere(0, 0) endif endfunction diff --git a/nerdtree_plugin/exec_menuitem.vim b/nerdtree_plugin/exec_menuitem.vim index 20083e0..fb6c486 100644 --- a/nerdtree_plugin/exec_menuitem.vim +++ b/nerdtree_plugin/exec_menuitem.vim @@ -32,7 +32,7 @@ function! NERDTreeExecFile() let cmd = treenode.path.str({'escape': 1}) let cmd = input(':!', cmd . ' ') - if cmd != '' + if cmd !=# '' exec ':!' . cmd else echo 'Aborted' diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index b2eda5a..3ecfa81 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -51,27 +51,27 @@ endif "Args: "action: the action that is being performed, e.g. 'delete' function! s:inputPrompt(action) - if a:action == 'add' + if a:action ==# 'add' let title = 'Add a childnode' let info = "Enter the dir/file name to be created. Dirs end with a '/'" let minimal = 'Add node:' - elseif a:action == 'copy' + elseif a:action ==# 'copy' let title = 'Copy the current node' let info = 'Enter the new path to copy the node to:' let minimal = 'Copy to:' - elseif a:action == 'delete' + elseif a:action ==# 'delete' let title = 'Delete the current node' let info = 'Are you sure you wish to delete the node:' let minimal = 'Delete?' - elseif a:action == 'deleteNonEmpty' + elseif a:action ==# 'deleteNonEmpty' let title = 'Delete the current node' let info = "STOP! Directory is not empty! To delete, type 'yes'" let minimal = 'Delete directory?' - elseif a:action == 'move' + elseif a:action ==# 'move' let title = 'Rename the current node' let info = 'Enter the new path for the node:' let minimal = 'Move to:' @@ -114,9 +114,9 @@ function! s:promptToDelBuffer(bufnum, msg) let l:listedBufferCount = 0 endif if l:listedBufferCount > 1 - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':bnext! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1) else - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':enew! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1) endif call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) @@ -146,7 +146,7 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore @@ -330,7 +330,7 @@ function! NERDTreeCopyNode() let prompt = s:inputPrompt('copy') let newNodePath = input(prompt, currentNode.path.str(), 'file') - if newNodePath != '' + if newNodePath !=# '' "strip trailing slash let newNodePath = substitute(newNodePath, '\/$', '', '') @@ -369,7 +369,7 @@ endfunction function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() if has('clipboard') - if &clipboard == 'unnamedplus' + if &clipboard ==# 'unnamedplus' let @+ = l:nodePath else let @* = l:nodePath @@ -383,7 +383,7 @@ endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") endif endfunction @@ -391,7 +391,7 @@ endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("open -R '" . treenode.path.str() . "'") endif endfunction @@ -399,7 +399,7 @@ endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("open '" . treenode.path.str() . "'") endif endfunction @@ -408,7 +408,7 @@ endfunction function! NERDTreeRevealFileLinux() let treenode = g:NERDTreeFileNode.GetSelected() let parentnode = treenode.parent - if parentnode != {} + if parentnode !=# {} call system("xdg-open '" . parentnode.path.str() . "' &") endif endfunction @@ -416,7 +416,7 @@ endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("xdg-open '" . treenode.path.str() . "' &") endif endfunction diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim index 29de1e7..36d5427 100644 --- a/nerdtree_plugin/vcs.vim +++ b/nerdtree_plugin/vcs.vim @@ -34,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~ '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:\\\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~ '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8264efa..9b4df5d 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -91,7 +91,7 @@ call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') if has('conceal') call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") -elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") +elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") else call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") @@ -184,7 +184,7 @@ if g:NERDTreeHijackNetrw augroup END endif -if g:NERDTreeChDirMode == 3 +if g:NERDTreeChDirMode ==# 3 augroup NERDTreeChDirOnTabSwitch autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif augroup END