Files
darcula_nvim/nvim/lua/darcula/setup/400_mini_starter.lua
2026-03-31 12:07:49 -05:00

148 lines
4.4 KiB
Lua

-- The MIT License (MIT)
--
-- Copyright © 2026 Scott E. Graves <scott.e.graves@protonmail.com>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-- and associated documentation files (the “Software”), to deal in the Software without restriction,
-- including without limitation the rights to use, copy, modify, merge, publish, distribute,
-- sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all copies or
-- substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-- BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--
local starter = require("mini.starter")
local header_cache
local wrap_action = function(input)
local parse_items = function(items)
for idx, val in ipairs(items) do
local orig_action = val.action
items[idx].action = function()
if type(orig_action) == "string" then
vim.cmd(orig_action)
elseif type(orig_action) == "function" then
orig_action()
end
header_cache = nil
NV_Darcula_LSP_Restart()
end
end
return items
end
if type(input) == "function" then
return function()
return parse_items(input())
end
end
return parse_items(input)
end
local main_section = "Bookmarks"
local add_line_under_sections = function(content)
local out = {}
for _, line in ipairs(content) do
table.insert(out, line)
if line[1].type == "section" then
table.insert(out, {{type = "empty", string = ""}})
end
end
return out
end
starter.setup {
content_hooks = {
add_line_under_sections,
starter.gen_hook.indexing("all", {"Builtin actions", main_section}),
starter.gen_hook.aligning("left", "top"),
starter.gen_hook.padding(5, 2)
},
evaluate_single = true,
header = function()
if not header_cache then
header_cache =
table.concat(require("darcula.utils.fortune").cowsay(), "\n")
end
return header_cache
end,
items = {
wrap_action(starter.sections.builtin_actions()),
wrap_action(starter.sections.recent_files(5, true)),
wrap_action(starter.sections.recent_files(5, false)),
wrap_action(
{
{
action = "e " ..
vim.fs.joinpath(vim.env.HOME, ".desktop", "scripts", "setup.sh"),
name = "Desktop (" ..
vim.fs.joinpath(vim.env.HOME, ".desktop", "scripts", "setup.sh") ..
")",
section = main_section
},
{
action = "e " .. vim.fs.joinpath(vim.fn.stdpath("config"), "init.lua"),
name = "Lua Configuration (" ..
vim.fs.joinpath(vim.fn.stdpath("config"), "init.lua") .. ")",
section = main_section
},
{
action = "e " ..
vim.fs.joinpath(
vim.fn.stdpath("config"),
"lua",
"darcula",
"keymaps.lua"
),
name = "Maps (" ..
vim.fs.joinpath(
vim.fn.stdpath("config"),
"lua",
"darcula",
"keymaps.lua"
) ..
")",
section = main_section
},
{
action = "e " ..
vim.fs.joinpath(
vim.fn.stdpath("config"),
"lua",
"darcula",
"setup",
"305_mini_starter.lua"
),
name = "Starter (" ..
vim.fs.joinpath(
vim.fn.stdpath("config"),
"lua",
"darcula",
"setup",
"305_mini_starter.lua"
) ..
")",
section = main_section
}
}
)
},
footer = ""
}
vim.cmd("hi! link MiniStarterHeader Comment")
vim.cmd("hi! link MiniStarterItem Comment")
vim.cmd("hi! link MiniStarterItemPrefix Normal")
vim.cmd("hi! link MiniStarterQuery Search")