vim-startify icon indicating copy to clipboard operation
vim-startify copied to clipboard

how can I display Specify directory in the start screen

Open rmGFW opened this issue 3 years ago • 2 comments

how can I display Specify directory

rmGFW avatar Nov 10 '20 06:11 rmGFW

I want start screen can list all the file under directory /path/to/my/dir

rmGFW avatar Nov 10 '20 06:11 rmGFW

Doesn't the built-in type dir) suffice? Else you could always add an Funcref type and implement the method yourself like.

Something like:

let s:max_files_amount = 100

" List all files in current directory with optional amount
function! s:list_files_current_directory(...) abort
    let l:file_amount = get(a:, 1, s:max_files_amount)

    " Ensure boundries 0 < v <= max
    if l:file_amount > s:max_files_amount
        let l:file_amount = s:max_files_amount
    elseif l:file_amount <= 0
        let l:file_amount = 1
    endif

    let l:all_files = split(globpath('.', '*'), '\n')
    return map(l:all_files[:l:file_amount-1], '{"line": v:val, "cmd": "edit " . v:val }')
endfunction

let g:startify_lists = [
    \ { 'header': ['   Most recently used files in current dir: '. getcwd()], 'type': 'dir' },
    \ { 'header': ['   All files in current directory'],                      'type': function('s:list_files_current_directory', [20]) },
    \ ]

jvgrootveld avatar Dec 15 '20 07:12 jvgrootveld