vim-startify configuration in lua with custom functions

Viewed 25

I'm trying to migrate my vimrc configuration to lua, and I'm stuck on migrating my vim-startify configuration. In particular, how can I write the gitModified and gitUntraked lists?

vimscript:

function! s:gitModified()
    let files = systemlist('git ls-files -m 2>/dev/null')
    return map(files, "{'line': v:val, 'path': v:val}")
endfunction

function! s:gitUntracked()
    let files = systemlist('git ls-files -o --exclude-standard 2>/dev/null')
    return map(files, "{'line': v:val, 'path': v:val}")
endfunction

let g:startify_lists = [
        \ { 'type': 'dir',       'header': ['   MRU '. getcwd()] },
        \ { 'type': 'sessions',  'header': ['   Sessions']       },
        \ { 'type': 'bookmarks', 'header': ['   Bookmarks']      },
        \ { 'type': function('s:gitModified'),  'header': ['   git modified']},
        \ { 'type': function('s:gitUntracked'), 'header': ['   git untracked']},
        \ { 'type': 'commands',  'header': ['   Commands']       },
        \ ]

My current lua:

vim.g.startify_lists = {
  { type = "commands", header = { "    Commands" } }, -- Commands from above
  { type = "dir", header = { "    MRU " .. vim.fn.getcwd() } }, -- MRU files from CWD
  { type = "sessions",  header = {"   Sessions"} },
  { type = "bookmarks", header = {"   Bookmarks"} },
}

Here I'm missing the two git related items.

Any idea? Thanks in advance.

0 Answers
Related