refactor: simplify dashboard config
This commit is contained in:
+6
-19
@@ -9,20 +9,11 @@ Config.now(function()
|
||||
starter.setup({
|
||||
items = {
|
||||
function()
|
||||
return vim.iter({ vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1) })
|
||||
:flatten()
|
||||
:filter(function(p) return vim.fn.isdirectory(p) == 1 end)
|
||||
:map(function(p)
|
||||
return {
|
||||
name = vim.fn.fnamemodify(p, ':t'),
|
||||
action = function()
|
||||
vim.fn.chdir(p)
|
||||
require('mini.files').open(p)
|
||||
end,
|
||||
section = 'Projects',
|
||||
}
|
||||
end)
|
||||
:totable()
|
||||
local dirs = vim.list_extend(vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1))
|
||||
return vim.iter(dirs):filter(function(p) return vim.fn.isdirectory(p) == 1 end):map(function(p)
|
||||
local open = function() vim.fn.chdir(p) require('mini.files').open(p) end
|
||||
return { name = vim.fn.fnamemodify(p, ':t'), action = open, section = 'Projects' }
|
||||
end):totable()
|
||||
end,
|
||||
|
||||
starter.sections.builtin_actions(),
|
||||
@@ -72,16 +63,12 @@ Config.later(function()
|
||||
require('mini.extra').setup()
|
||||
end)
|
||||
|
||||
-- File Explorer
|
||||
-- File Explorer & auto root
|
||||
Config.now_if_args(function()
|
||||
require('mini.files').setup()
|
||||
Config.autocmd('User', 'MiniFilesExplorerOpen', function()
|
||||
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
|
||||
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
|
||||
end, 'Add default marks')
|
||||
end)
|
||||
|
||||
-- Utilities
|
||||
Config.now_if_args(function()
|
||||
require('mini.misc').setup_auto_root()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user