add dashboard

This commit is contained in:
lucy 2026-04-09 16:45:21 +02:00
commit c6a756fea7

128
init.lua
View file

@ -14,6 +14,7 @@ opt.tabstop = 8
vim.opt.expandtab = true vim.opt.expandtab = true
vim.g.tinted_background_transparent = 0 vim.g.tinted_background_transparent = 0
opt.swapfile = false opt.swapfile = false
opt.winborder = "single"
opt.shiftwidth = 8 opt.shiftwidth = 8
vim.diagnostic.config({ vim.diagnostic.config({
@ -36,7 +37,19 @@ vim.pack.add({
"https://github.com/mason-org/mason.nvim.git", "https://github.com/mason-org/mason.nvim.git",
{ src = "https://github.com/Saghen/blink.cmp", version = "v1" }, { src = "https://github.com/Saghen/blink.cmp", version = "v1" },
}) })
-- function to set colorsceme
local default_theme = "base16-oceanicnext"
local function get_tinty_theme()
local theme_name = vim.fn.system("cat /home/lucy/.local/share/tinted-theming/tinty/current_scheme")
if vim.v.shell_error ~= 0 then
return default_theme
else
return vim.trim(theme_name)
end
end
vim.cmd("colorscheme " .. get_tinty_theme())
-- set up qmlls to point to the right binary
vim.lsp.config("qmlls", { vim.lsp.config("qmlls", {
cmd = { "qmlls6" }, cmd = { "qmlls6" },
}) })
@ -63,11 +76,113 @@ require("bufferline").setup({
}, },
}, },
}) })
require("lualine").setup()
require("snacks").setup({ require("snacks").setup({
notifier = { enabled = true }, notifier = { enabled = true },
statuscolumn = { enabled = true }, statuscolumn = { enabled = true },
picker = {}, picker = {},
styles = {
dashboard = {
wo = {
statusline = "%!v:lua.require'lualine'.statusline()", -- Use lualine
},
},
},
dashboard = {
enabled = true,
width = 60,
row = nil, -- dashboard position. nil for center
col = nil, -- dashboard position. nil for center
pane_gap = 4, -- empty columns between vertical panes
autokeys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -- autokey sequence
-- These settings are used by some built-in sections
preset = {
-- Defaults to a picker that supports `fzf-lua`, `telescope.nvim` and `mini.pick`
---@type fun(cmd:string, opts:table)|nil
pick = nil,
-- Used by the `keys` section to show keymaps.
-- Set your custom keymaps here.
-- When using a function, the `items` argument are the default keymaps.
---@type snacks.dashboard.Item[]
keys = {
{
icon = "",
key = "f",
desc = "Find File",
action = ":lua Snacks.dashboard.pick('files')",
},
{ icon = "", key = "n", desc = "New File", action = ":ene | startinsert" },
{
icon = "",
key = "g",
desc = "Find Text",
action = ":lua Snacks.dashboard.pick('live_grep')",
},
{
icon = "",
key = "r",
desc = "Recent Files",
action = ":lua Snacks.dashboard.pick('oldfiles')",
},
{
icon = "",
key = "c",
desc = "Config",
action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})",
},
{ icon = "", key = "s", desc = "Restore Session", section = "session" },
{
icon = "󰒲 ",
key = "L",
desc = "Lazy",
action = ":Lazy",
enabled = package.loaded.lazy ~= nil,
},
{ icon = "", key = "q", desc = "Quit", action = ":qa" },
},
-- Used by the `header` section
header = [[
⠀⠀⠀⠀⠀⠀⣠⡤⠶⠒⠛⠉⠙⠛⠒⠶⢤⣀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠁⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠙⢦⡀⠀⠀⠀
⠀⠀⠀⠀⣀⣠⠤⠤⡴⠻⢓⣶⠦⠤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀
⣀⡠⠴⠊⠁⠀⠀⠀⠀⠀⠒⠽⠀⠀⠀⠉⢙⠒⢢⡄⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀
⠘⢆⠉⠑⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢆⠁⣠⠎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇
⠀⠈⠓⠦⠁⢀⣀⠀⠀⠀⠀⠀⠀⣀⣀⢸⡊⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻
⠀⠀⠀⡸⠀⠉⠀⠙⠆⠀⠀⠀⠏⠀⠈⠀⢇⠀⠀⠀⠀⠀⠀⠀⢀⠔⠀⠀⠀⣼
⠀⠀⠀⠹⣄⠀⠠⣤⡡⠪⡭⠃⡤⢤⡄⡰⠋⠀⠀⠀⣀⡠⠴⠊⠁⠀⠀⠀⢠⠇
⠀⠀⢠⢿⣠⠟⠓⠛⠉⠛⡟⠛⠛⠛⠛⠒⠒⠚⠉⠉⠁⠀⠀⠀⠀⠀⢀⡴⠋⠀
⠀⠀⠈⠛⢯⣀⣀⣀⡤⠤⠤⠤⢤⣤⣀⣀⣀⣀⣀⣀⣀⣤⠤⠴⠒⠋⠁⠀⠀⠀
]],
},
-- item field formatters
formats = {
icon = function(item)
if item.file and item.icon == "file" or item.icon == "directory" then
return Snacks.dashboard.icon(item.file, item.icon)
end
return { item.icon, width = 2, hl = "icon" }
end,
footer = { "%s", align = "center" },
header = { "%s", align = "center" },
file = function(item, ctx)
local fname = vim.fn.fnamemodify(item.file, ":~")
fname = ctx.width and #fname > ctx.width and vim.fn.pathshorten(fname) or fname
if #fname > ctx.width then
local dir = vim.fn.fnamemodify(fname, ":h")
local file = vim.fn.fnamemodify(fname, ":t")
if dir and file then
file = file:sub(-(ctx.width - #dir - 2))
fname = dir .. "/…" .. file
end
end
local dir, file = fname:match("^(.*)/(.+)$")
return dir and { { dir .. "/", hl = "dir" }, { file, hl = "file" } } or { { fname, hl = "file" } }
end,
},
sections = {
{ section = "header" },
{ section = "keys", gap = 1, padding = 1 },
},
},
}) })
require("lspsaga").setup({ require("lspsaga").setup({
symbol_in_winbar = { enable = true }, symbol_in_winbar = { enable = true },
@ -148,17 +263,6 @@ map("t", "<esc>", "<c-\\><c-n>")
map("i", "<C-space>", vim.lsp.completion.get, { desc = "trigger autocompletion" }) map("i", "<C-space>", vim.lsp.completion.get, { desc = "trigger autocompletion" })
-- tinty function -- tinty function
local default_theme = "base16-oceanicnext"
local function get_tinty_theme()
local theme_name = vim.fn.system("cat /home/lucy/.local/share/tinted-theming/tinty/current_scheme")
if vim.v.shell_error ~= 0 then
return default_theme
else
return vim.trim(theme_name)
end
end
local function handle_focus_gained() local function handle_focus_gained()
local new_theme_name = get_tinty_theme() local new_theme_name = get_tinty_theme()