-- ============================================================================= -- ui.lua — UI 美化套件(VSCode 风格核心) -- ============================================================================= -- 【全新文件】这是从参考配置提取 + 定制的 UI 套件。 -- 包含:bufferline(标签栏)、lualine(状态栏)、noice(命令行)、 -- nvim-notify(通知)、dashboard(启动页)、dressing(输入框)。 -- 【修复】🔧 bufferline/lualine/dashboard 改为 lazy=false 立即加载, -- 避免 nvim . 打开目录时 UI 不显示。 return { -- ───────────────────────────────────────────── -- bufferline: 顶部标签栏(VSCode 核心) -- ───────────────────────────────────────────── { "akinsho/bufferline.nvim", version = "*", -- 🔧 修复:去掉 event = "BufReadPre",改为立即加载 lazy = false, dependencies = { "nvim-tree/nvim-web-devicons", -- ✅ 新增:提供 Bdelete 命令,让 close_command 能正常工作 "famiu/bufdelete.nvim", }, config = function() require("bufferline").setup({ options = { mode = "buffers", style_preset = require("bufferline").style_preset.default, themable = true, numbers = "none", close_command = "Bdelete!", right_mouse_command = "Bdelete!", indicator = { style = "icon", icon = "▎" }, buffer_close_icon = "󰅖", modified_icon = "●", close_icon = "", left_trunc_marker = "", right_trunc_marker = "", max_name_length = 18, max_prefix_length = 15, truncate_names = true, tab_size = 18, diagnostics = "nvim_lsp", diagnostics_update_in_insert = false, -- ✅ 适配 oil.nvim 和 nvim-tree:左侧文件浏览器偏移 offsets = { { filetype = "oil", text = "文件浏览器", highlight = "Directory", text_align = "left", }, { filetype = "NvimTree", text = "文件树", highlight = "Directory", text_align = "left", }, }, color_icons = true, show_buffer_icons = true, show_buffer_close_icons = true, show_close_icon = false, show_tab_indicators = true, persist_buffer_sort = true, separator_style = "thin", enforce_regular_tabs = false, always_show_bufferline = true, hover = { enabled = true, delay = 200, reveal = { "close" }, }, }, }) end, }, -- ───────────────────────────────────────────── -- lualine: 底部状态栏(VSCode 核心) -- ───────────────────────────────────────────── { "nvim-lualine/lualine.nvim", -- 🔧 修复:改为立即加载,确保一打开就有状态栏 lazy = false, dependencies = { "nvim-tree/nvim-web-devicons", }, opts = { options = { component_separators = "|", section_separators = "", globalstatus = true, theme = "tokyonight", }, sections = { lualine_a = { "mode" }, lualine_b = { "branch", "diff", "diagnostics" }, lualine_c = { { "filename", path = 1 } }, lualine_x = { "encoding", "fileformat", "filetype" }, lualine_y = { "progress" }, lualine_z = { "location" }, }, }, }, -- ───────────────────────────────────────────── -- noice.nvim: 命令行美化 -- ───────────────────────────────────────────── { "folke/noice.nvim", event = "VeryLazy", opts = { cmdline = { view = "cmdline_popup", format = { search_down = { icon = " " }, search_up = { icon = " " }, }, }, messages = { enabled = true, view = "notify", view_error = "notify", view_warn = "notify", }, popupmenu = { enabled = true, backend = "nui", }, presets = { bottom_search = false, command_palette = true, long_message_to_split = true, inc_rename = true, lsp_doc_border = true, }, }, dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify", }, }, -- ───────────────────────────────────────────── -- nvim-notify: 通知美化 -- ───────────────────────────────────────────── { "rcarriga/nvim-notify", lazy = false, -- 🔧 修复:立即加载,让 noice 能用 opts = { timeout = 3000, max_width = 50, render = "compact", stages = "fade", }, config = function(_, opts) local notify = require("notify") notify.setup(opts) vim.notify = notify end, }, -- ───────────────────────────────────────────── -- dressing.nvim: 输入框美化 -- ───────────────────────────────────────────── { "stevearc/dressing.nvim", event = "VeryLazy", opts = {}, }, -- ───────────────────────────────────────────── -- dashboard-nvim: 启动首页 -- ───────────────────────────────────────────── { "nvimdev/dashboard-nvim", lazy = false, -- 🔧 修复:必须立即加载才能在启动时显示 dependencies = { "nvim-tree/nvim-web-devicons" }, opts = { theme = "doom", config = { header = { "", " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗ ██╗██╗███╗ ███╗", " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║ ██║██║████╗ ████║", " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║ ██║██║██╔████╔██║", " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝╚██╗ ██╔╝██║██║╚██╔╝██║", " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║", " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝", "", }, center = { { icon = " ", key = "f", desc = "查找文件", action = "Telescope find_files" }, { icon = " ", key = "r", desc = "最近文件", action = "Telescope oldfiles" }, { icon = " ", key = "g", desc = "全局搜索", action = "Telescope live_grep" }, { icon = " ", key = "l", desc = "插件管理", action = "Lazy" }, { icon = " ", key = "m", desc = "LSP 管理", action = "Mason" }, { icon = " ", key = "q", desc = "退出", action = "qa" }, }, footer = { " atdunbg · Neovim" }, }, }, }, -- ───────────────────────────────────────────── -- 通用依赖(多个插件共用) -- ───────────────────────────────────────────── { "nvim-lua/plenary.nvim", lazy = true }, { "MunifTanjim/nui.nvim", lazy = true }, }