Files
LazyVim/lua/lazyvim/plugins/ui.lua

271 lines
9.7 KiB
Lua

return {
-- better vim.notify
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>nd",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Delete all Notifications",
},
},
config = {
timeout = 3000,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
},
},
-- better vim.ui
{
"stevearc/dressing.nvim",
init = function()
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.select = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.select(...)
end
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.input = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.input(...)
end
end,
},
-- bufferline
{
"akinsho/nvim-bufferline.lua",
event = "BufAdd",
config = {
options = {
diagnostics = "nvim_lsp",
always_show_bufferline = false,
diagnostics_indicator = function(_, _, diag)
local icons = require("lazyvim.config.settings").icons.diagnostics
local ret = (diag.error and icons.Error .. diag.error .. " " or "")
.. (diag.warning and icons.Warn .. diag.warning or "")
return vim.trim(ret)
end,
offsets = {
{
filetype = "neo-tree",
text = "Neo-tree",
highlight = "Directory",
text_align = "left",
},
},
},
},
},
-- statusline
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
config = {
options = {
globalstatus = true,
disabled_filetypes = { statusline = { "lazy", "alpha" } },
},
},
},
-- indent guides for Neovim
{
"lukas-reineke/indent-blankline.nvim",
event = "BufReadPre",
config = {
-- char = "▏",
char = "",
filetype_exclude = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy" },
show_trailing_blankline_indent = false,
show_current_context = false,
},
},
-- active indent guide and indent text objects
{
"echasnovski/mini.indentscope",
event = "BufReadPre",
config = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy" },
callback = function()
vim.b.miniindentscope_disable = true
end,
})
require("mini.indentscope").setup({
-- symbol = "▏",
symbol = "",
options = { try_as_border = true },
})
end,
},
-- noicer ui
{
"folke/noice.nvim",
event = "VeryLazy",
config = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
},
},
presets = {
bottom_search = true,
command_palette = true,
long_message_to_split = true,
},
},
-- stylua: ignore
keys = {
{ "<S-Enter>", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" },
{ "<leader>nl", function() require("noice").cmd("last") end, desc = "Noice Last Message" },
{ "<leader>nh", function() require("noice").cmd("history") end, desc = "Noice History" },
{ "<leader>na", function() require("noice").cmd("all") end, desc = "Noice All" },
{ "<c-f>", function() if not require("noice.lsp").scroll(4) then return "<c-f>" end end, silent = true, expr = true },
{ "<c-b>", function() if not require("noice.lsp").scroll(-4) then return "<c-b>" end end, silent = true, expr = true },
},
},
-- start screen
{
"echasnovski/mini.starter",
enabled = false,
event = "VimEnter",
config = function()
local logo = table.concat({
"██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z",
"██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z",
"██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z",
"██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z",
"███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║",
"╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝",
}, "\n")
local pad = string.rep(" ", 22)
local new_section = function(name, action, section)
return { name = name, action = action, section = pad .. section }
end
local starter = require("mini.starter")
--stylua: ignore
local config = {
evaluate_single = true,
header = logo,
items = {
new_section("Find file", "Telescope find_files", "Telescope"),
new_section("Recent files", "Telescope oldfiles", "Telescope"),
new_section("Grep text", "Telescope live_grep", "Telescope"),
new_section("init.lua", "e $MYVIMRC", "Config"),
new_section("Lazy", "Lazy", "Config"),
new_section("New file", "ene | startinsert", "Built-in"),
new_section("Quit", "qa", "Built-in"),
},
content_hooks = {
starter.gen_hook.adding_bullet(pad .. "", false),
starter.gen_hook.aligning("center", "center"),
},
}
-- close Lazy and re-open when starter is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
pattern = "MiniStarterOpened",
callback = function()
require("lazy").show()
end,
})
end
starter.setup(config)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
local pad_footer = string.rep(" ", 8)
MiniStarter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(MiniStarter.refresh)
end,
})
end,
},
-- dashboard
{
"goolord/alpha-nvim",
event = "VimEnter",
config = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
]]
dashboard.section.header.val = vim.split(logo, "\n")
dashboard.section.buttons.val = {
dashboard.button("f", "" .. " Find file", ":Telescope find_files <CR>"),
dashboard.button("n", "" .. " New file", ":ene <BAR> startinsert <CR>"),
dashboard.button("r", "" .. " Recent files", ":Telescope oldfiles <CR>"),
dashboard.button("g", "" .. " Find text", ":Telescope live_grep <CR>"),
dashboard.button("c", "" .. " Config", ":e $MYVIMRC <CR>"),
dashboard.button("l", "" .. " Lazy", ":Lazy<CR>"),
dashboard.button("q", "" .. " Quit", ":qa<CR>"),
}
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.footer.opts.hl = "Type"
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.opts.layout[1].val = 8
vim.b.miniindentscope_disable = true
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
pattern = "AlphaReady",
callback = function()
require("lazy").show()
end,
})
end
require("alpha").setup(dashboard.opts)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
},
-- icons
"nvim-tree/nvim-web-devicons",
-- ui components
"MunifTanjim/nui.nvim",
}