diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-16 20:46:57 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-16 20:46:57 +1200 |
commit | 72195cf648af3c9db85a0f864574965dc6b8409d (patch) | |
tree | 231786e5251d78c0dd38a339745716ba84f10b0f /vim/autoload | |
parent | Enhance load guard or select_old_files.vim (diff) | |
download | dotfiles-72195cf648af3c9db85a0f864574965dc6b8409d.tar.gz dotfiles-72195cf648af3c9db85a0f864574965dc6b8409d.zip |
Refactor select_old_files.vim to allow count
Diffstat (limited to 'vim/autoload')
-rw-r--r-- | vim/autoload/select_old_files.vim | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/vim/autoload/select_old_files.vim b/vim/autoload/select_old_files.vim index 518b98d4..aceff110 100644 --- a/vim/autoload/select_old_files.vim +++ b/vim/autoload/select_old_files.vim @@ -1,7 +1,17 @@ -function! select_old_files#() abort +function! select_old_files#(...) abort + if a:0 + if a:1 =~# '^\d\+$' + let limit = a:1 + else + echoerr 'Invalid count' + endif + elseif exists('g:select_old_files_limit') + let limit = g:select_old_files_limit + else + let limit = &lines - 2 + endif let oldfiles = v:oldfiles - let limit = get(g:, 'select_old_files_limit', &lines - 1) - let v:oldfiles = v:oldfiles[:limit-2] + let v:oldfiles = v:oldfiles[:limit - 1] browse oldfiles let v:oldfiles = oldfiles endfunction |