add proof of concept for path flags API and add git modified flags

This commit is contained in:
Martin Grenfell
2014-07-05 00:29:45 +01:00
parent d162c08fd7
commit a7428eba38
6 changed files with 124 additions and 5 deletions

View File

@@ -24,6 +24,13 @@ function! s:Path.AbsolutePathFor(str)
return toReturn
endfunction
"FUNCTION: Path.addFlag(flag) {{{1
function! s:Path.addFlag(flag)
if index(self._flags, a:flag) == -1
call add(self._flags, a:flag)
endif
endfunction
"FUNCTION: Path.bookmarkNames() {{{1
function! s:Path.bookmarkNames()
if !exists("self._bookmarkNames")
@@ -33,8 +40,10 @@ function! s:Path.bookmarkNames()
endfunction
"FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString()
let self.cachedDisplayString = self.getLastPathComponent(1)
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self._flagString()
let self.cachedDisplayString .= self.getLastPathComponent(1)
if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
@@ -350,6 +359,15 @@ function! s:Path.getSortOrderIndex()
return s:NERDTreeSortStarIndex
endfunction
"FUNCTION: Path._flagString() {{{1
function! s:Path._flagString()
if empty(self._flags)
return ""
endif
return '[' . join(self._flags, ',') . ']'
endfunction
"FUNCTION: Path.isUnixHiddenFile() {{{1
"check for unix hidden files
function! s:Path.isUnixHiddenFile()
@@ -460,6 +478,7 @@ function! s:Path.New(path)
call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
let newPath.cachedDisplayString = ""
let newPath._flags = []
return newPath
endfunction
@@ -480,6 +499,14 @@ function! s:Path.Resolve(path)
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
endfunction
"FUNCTION: Path.removeFlag(flag) {{{1
function! s:Path.removeFlag(flag)
let i = index(self._flags, a:flag)
if i >= 0
call remove(self._flags, i)
endif
endfunction
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
"
"
@@ -537,6 +564,7 @@ endfunction
"FUNCTION: Path.refresh() {{{1
function! s:Path.refresh()
call self.readInfoFromDisk(self.str())
call g:NERDTreeRefreshNotifier.NotifyListeners(self)
call self.cacheDisplayString()
endfunction