Permalink
Browse files

v:oldfiles in choices

  • Loading branch information...
1 parent fd69b0f commit de062f1f51630db9038c8048d8f00c0a3b5a269f @adaszko committed Mar 18, 2013
Showing with 14 additions and 3 deletions.
  1. +1 −0 README.md
  2. +13 −3 autoload/chbuf.vim
View
@@ -30,6 +30,7 @@ Just add a mapping of your choice to `.vimrc`:
To Do
=====
+ * Spaces should indicate start of another pattern
* Implement matching algorithm more suitable for buffer names
* Make functions script-private once they are sufficiently tested
* Tiny screencast
View
@@ -1,4 +1,3 @@
-" TODO Include v:oldfiles in buffers list
" TODO Make <C-s>, <C-v> and <C-t> open splits or tab respectively for selected buffer
@@ -36,8 +35,9 @@ function! SwitchToPath() dict " {{{
execute 'silent' 'edit' self.path
endfunction " }}}
-function! BufferFromPath(path) " {{{
- return {'switch': function('SwitchToPath')}
+function! BufferFromPath(path, score) " {{{
+ let name = split(a:path, s:directory_separator)[-1]
+ return {'path': a:path, 'name': name, 'score': a:score, 'switch': function('SwitchToPath')}
endfunction " }}}
function! ScoredBuffers() " {{{
@@ -71,6 +71,16 @@ function! ScoredBuffers() " {{{
call add(result, BufferFromNumber(buffer, name, score))
endfor
+ for path in v:oldfiles
+ let score = 0
+
+ if !filereadable(path)
+ let score -= 100
+ endif
+
+ call add(result, BufferFromPath(path, score))
+ endfor
+
return result
endfunction " }}}

0 comments on commit de062f1

Please sign in to comment.