diff --git a/lua/core/init.lua b/lua/core/init.lua index 8edbc86..76e4424 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -2,6 +2,8 @@ -- === Editor behavior -- === +-- 关闭底部状态栏 +vim.o.laststatus = 0 -- 开启左侧数字 vim.o.number = true -- 使用相对数 @@ -76,7 +78,8 @@ autocmd BufLeave * :silent !fcitx5-remote -c -- 开启高亮复制 vim.cmd([[au TextYankPost * silent! lua vim.highlight.on_yank()]]) - +-- 主题颜色 +vim.cmd.colorscheme("catppuccin") diff --git a/lua/pack/configs/bufferline.lua b/lua/pack/configs/bufferline.lua index 73af904..ff19b8f 100644 --- a/lua/pack/configs/bufferline.lua +++ b/lua/pack/configs/bufferline.lua @@ -9,7 +9,7 @@ if vim.g.vscode then return end local P = { name = "bufferline.nvim", - deps = { "nvim-web-devicons" }, -- 确保图标库先加载 + deps = { "nvim-web-devicons" }, -- 确保图标库先加载 } -- 懒加载触发器:打开或新建文件时触发 diff --git a/lua/pack/configs/lualine.lua b/lua/pack/configs/lualine.lua new file mode 100644 index 0000000..c7dd1c8 --- /dev/null +++ b/lua/pack/configs/lualine.lua @@ -0,0 +1,57 @@ +-- === 底部状态栏 === +if vim.g.vscode then return end + +local P = { + name = "lualine.nvim", + deps = { + "nvim-tree/nvim-web-devicons", + }, +} + +-- 懒加载触发器 +vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { + callback = function() + PackUtils.load(P, function() + -- ==================== 【魔法时刻:动态融合主题】 ==================== + -- 获取当前 Neovim 的真实背景色 (Normal 高亮组) + local normal_hl = vim.api.nvim_get_hl(0, { name = "Normal" }) + -- 如果是透明背景,bg 返回 nil,我们赋值为 "NONE";否则转换为 HEX 颜色码 + local editor_bg = normal_hl.bg and string.format("#%06x", normal_hl.bg) or "NONE" + -- 加载 Lualine 的自动主题,它会自动为你提取当前主题的前景色(文字颜色) + local blended_theme = require("lualine.themes.auto") + -- 遍历主题的所有的模式 (normal, insert, visual...) 和区块 (a, b, c...) + for _, mode in pairs(blended_theme) do + for _, section in pairs(mode) do + if type(section) == "table" then + -- 强行将它们的背景色全部涂成和编辑器完全一样的颜色 + section.bg = editor_bg + end + end + end + -- ==================================================================== + require("lualine").setup({ + options = { + -- 挂载我们刚刚特制的融合主题 + theme = blended_theme, + -- 全局唯一状态栏 (不仅底部更干净,而且背景融合得更彻底) + globalstatus = true, + + always_divide_middle = false, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = {}, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { { + "lsp_status", + color = { fg = "#6C6E81" }, + }, }, + lualine_x = {}, + lualine_y = {}, + lualine_z = { "progress" }, + }, + }) + end) + end +}) diff --git a/lua/pack/plugins.lua b/lua/pack/plugins.lua index a4f2ef7..db24a6b 100644 --- a/lua/pack/plugins.lua +++ b/lua/pack/plugins.lua @@ -44,6 +44,8 @@ local specs = { 'https://github.com/cap153/peek.nvim', -- yazi.lua 文件管理器 'https://github.com/mikavilpas/yazi.nvim', + -- lualine.lua 底部状态栏 + "https://github.com/nvim-lualine/lualine.nvim", -- sudo权限保存文件 "https://github.com/lambdalisue/vim-suda", -- 查看可用键位 diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index b91f60c..7389f23 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -28,6 +28,10 @@ "rev": "11be32be3761c6263df2311afb6baa0de0863967", "src": "https://github.com/MysticalDevil/inlay-hints.nvim" }, + "lualine.nvim": { + "rev": "a905eeebc4e63fdc48b5135d3bf8aea5618fb21c", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, "mason-lspconfig.nvim": { "rev": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b", "src": "https://github.com/williamboman/mason-lspconfig.nvim"