Something went wrong. Try again.
My NixVim configuration
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576local M = {}
local icon_width = 4local label_width = 52
function M.row(icon, key, label, action, label_highlight) local icon_text if type(icon) == "table" then icon_text = vim.tbl_extend("force", {}, icon, { width = icon_width }) else icon_text = { icon, hl = "icon", width = icon_width } end
return { align = "center", key = key, action = action, text = { icon_text, { label, hl = label_highlight or "desc", width = label_width }, { key, hl = "key" }, }, }end
local function root() local cwd = vim.uv.cwd() return (cwd and vim.fs.root(cwd, { ".jj", ".git" })) or cwdend
function M.summary() return { align = "center", padding = 1, text = { { require("vcs_status").context(), hl = "file" } }, }end
function M.recent_files() local items = {} local repository_root = root() local oldfiles_opts = repository_root and { filter = { [repository_root] = true } } or nil
for file in Snacks.dashboard.oldfiles(oldfiles_opts) do local number = #items + 1 local display = (repository_root and vim.fs.relpath(repository_root, file)) or vim.fn.fnamemodify(file, ":~")
if #display > 50 then display = vim.fn.pathshorten(display) end if #display > 50 then display = "…" .. display:sub(-49) end
table.insert( items, M.row( Snacks.dashboard.icon(file, "file"), tostring(number), display, ":edit " .. vim.fn.fnameescape(file), "file" ) )
if #items == 4 then break end end
return itemsend
return M