diff --git a/lua/core/init.lua b/lua/core/init.lua index b14155c..585f9d4 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -9,7 +9,7 @@ vim.opt.conceallevel = 2 -- 使用相对数 vim.o.relativenumber = true -- 高亮当前行 -vim.o.cursorline = true +vim.o.cursorline = false -- 一行不能完全显示时自动换行 vim.o.wrap = true -- 在最后一行显示一些内容 diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua index db30692..fe01272 100644 --- a/lua/core/keymap.lua +++ b/lua/core/keymap.lua @@ -207,7 +207,7 @@ mapcmd("sc", "set spell!") -- 运行代码 vim.cmd([[ au filetype dart noremap r :wall:Telescope flutter commands - au filetype python noremap r :wall:set splitbelow:sp:term python % + au filetype python noremap r :wall:set splitbelow:sp:term uv run % au filetype go noremap r :wall:set splitbelow:sp:term go run % au filetype markdown noremap r :MarkdownPreview au filetype rust noremap r :wall:set splitbelow:sp:term cargo run diff --git a/lua/lazy/index.lua b/lua/lazy/index.lua index 416bbbd..ba2f8bd 100644 --- a/lua/lazy/index.lua +++ b/lua/lazy/index.lua @@ -29,7 +29,7 @@ require("lazy").setup({ require("lazy.plugins.fittencode"), -- 免费大语言模型 (LLM) 支持 require("lazy.plugins.llm"), - -- command line浮动弹窗 + -- command line浮动弹窗noice require("lazy.plugins.cmdline"), -- 代码函数名称浏览时固定,`[c`可以跳转到上下文 require("lazy.plugins.stickyScroll"), @@ -50,7 +50,7 @@ require("lazy").setup({ -- treesitter语法高亮 require("lazy.plugins.treesitter"), -- rainbow彩虹括号 - require("lazy.plugins.rainbow"), + require("lazy.plugins.rainbowbracket"), -- tabular,使用:Tab /=来格式化等号之类,特使符号要转义如:Tabularize /\/ require("lazy.plugins.tabular"), -- surround,各种对字符的包裹{} [] '' @@ -59,12 +59,14 @@ require("lazy").setup({ require("lazy.plugins.pairs"), -- flutter require("lazy.plugins.flutter"), - -- 底部状态栏+主题 themes + -- 主题 themes require("lazy.plugins.themes"), + -- 顶部标签页,文件缓冲区 + require("lazy.plugins.bufferline"), + -- 底部状态栏 + require("lazy.plugins.bottombar"), -- 注释插件 require("lazy.plugins.comment"), - -- 文件缓冲标签栏 - require("lazy.plugins.bufferline"), -- explorer tree 文件列表,现在已使用yazi require("lazy.plugins.filemanager"), -- crtl+g快捷键在neovim中启动lazygit @@ -77,18 +79,17 @@ require("lazy").setup({ require("lazy.plugins.color"), -- sudo write require("lazy.plugins.suda"), - -- jump使用flash.nvim插件实现,f单个字母时按f下一处,建议先esc退出再可视模式此时才可以继续使用f,斜杠粘贴整个单词查找的时候不好用 + -- jump使用flash.nvim插件实现 require("lazy.plugins.jump"), -- 多光标 require("lazy.plugins.multicursor"), -- which-key使用多个字母快捷键停留时会提示 require("lazy.plugins.whichkey"), - -- 用于改进在 Neovim 中查看 Markdown 文件的插件 - -- require("lazy.plugins.render-markdown"), -- 顶部的winbar,可以鼠标点击 - -- require("lazy.plugins.winbar"), - -- cw推荐的indent缩进线hlchunk,可以根据线条的款式来分辨缩进 - -- require("lazy.plugins.indent"), + require("lazy.plugins.winbar"), + -- 用于改进在 Neovim 中查看 Markdown 文件的插件 + require("lazy.plugins.markview"), + -- require("lazy.plugins.render-markdown"), -- mcp server插件 -- require("lazy.plugins.mcphub"), -- 像cursor一样使用neovim diff --git a/lua/lazy/plugins/blinkcmp.lua b/lua/lazy/plugins/blinkcmp.lua index 0b3c7d9..8c4c661 100644 --- a/lua/lazy/plugins/blinkcmp.lua +++ b/lua/lazy/plugins/blinkcmp.lua @@ -15,6 +15,8 @@ return { [""] = { "select_and_accept", "fallback" }, }, completion = { + -- 不预选第一个项目,选中后自动插入该项目文本 + list = { selection = { preselect = false, auto_insert = true } }, -- 自动显示补全窗口,仅在输入命令时显示菜单,而搜索或使用其他输入菜单时则不显示 menu = { auto_show = function(ctx) diff --git a/lua/lazy/plugins/bottombar.lua b/lua/lazy/plugins/bottombar.lua new file mode 100644 index 0000000..2a6b201 --- /dev/null +++ b/lua/lazy/plugins/bottombar.lua @@ -0,0 +1,25 @@ +-- === +-- === 底部状态栏 +-- === +return { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + opts = { + options = { + theme = "catppuccin", + always_divide_middle = false, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "lsp_status" }, + lualine_x = {}, + lualine_y = { "encoding", "fileformat", "progress" }, + lualine_z = { "location" }, + }, + }, +} diff --git a/lua/lazy/plugins/filemanager.lua b/lua/lazy/plugins/filemanager.lua index 2f99242..9199cd1 100644 --- a/lua/lazy/plugins/filemanager.lua +++ b/lua/lazy/plugins/filemanager.lua @@ -1,13 +1,50 @@ -- === --- === explorer tree 文件列表 +-- === explorer tree 文件列表 -- === - +---@type LazySpec return { - "mikavilpas/yazi.nvim", -- 使用yazi替代joshuto和ranger,仍然使用fm-nvim来启动lazygit + "mikavilpas/yazi.nvim", event = "VeryLazy", - keys = { - { "tt", "Yazi", desc = "Toggle Yazi" }, + dependencies = { + -- check the installation instructions at + -- https://github.com/folke/snacks.nvim + "folke/snacks.nvim", }, - config = function() - end + keys = { + -- 👇 in this section, choose your own keymappings! + { + "tt", + mode = { "n", "v" }, + "Yazi", + desc = "Open yazi at the current file", + }, + }, + ---@type YaziConfig | {} + opts = { + -- if you want to open yazi instead of netrw, see below for more info + open_for_directories = false, + keymaps = { + show_help = "", + }, + }, + -- 👇 if you use `open_for_directories=true`, this is recommended + init = function() + -- More details: https://github.com/mikavilpas/yazi.nvim/issues/802 + -- vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + end, } +-- return { +-- "rolv-apneseth/tfm.nvim", +-- event = "VeryLazy", +-- opts = { +-- enable_cmds = true, +-- }, +-- keys = { +-- { +-- "tt", +-- ":Tfm", +-- desc = "TFM - new tab", +-- }, +-- }, +-- } diff --git a/lua/lazy/plugins/fittencode.lua b/lua/lazy/plugins/fittencode.lua index acd765e..9fb2998 100644 --- a/lua/lazy/plugins/fittencode.lua +++ b/lua/lazy/plugins/fittencode.lua @@ -10,10 +10,10 @@ return { keymaps = { inline = { [''] = 'accept_all_suggestions', -- 接受所有建议 - [''] = 'accept_line', -- 接受当前行 - -- [''] = 'accept_word', -- 接受当前单词 - [''] = 'revoke_line', -- 撤销当前行 - -- [''] = 'revoke_word', -- 撤销当前单词 + -- [''] = 'accept_line', -- 接受当前行 + [''] = 'accept_word', -- 接受当前单词 + -- [''] = 'revoke_line', -- 撤销当前行 + [''] = 'revoke_word', -- 撤销当前单词 [''] = 'triggering_completion', -- 触发补全 }, }, diff --git a/lua/lazy/plugins/fold.lua b/lua/lazy/plugins/fold.lua index cb03379..4908a04 100644 --- a/lua/lazy/plugins/fold.lua +++ b/lua/lazy/plugins/fold.lua @@ -1,5 +1,5 @@ -- ufo关于折叠的设置 -vim.o.foldcolumn = '0' -- '0' is not bad,其他的会有奇怪的数字 +vim.o.foldcolumn = "0" -- '0' is not bad,其他的会有奇怪的数字 vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value vim.o.foldlevelstart = 99 vim.o.foldenable = true @@ -7,22 +7,21 @@ vim.o.foldenable = true vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] return { - 'kevinhwang91/nvim-ufo', - dependencies = 'kevinhwang91/promise-async', + "kevinhwang91/nvim-ufo", + dependencies = "kevinhwang91/promise-async", config = function() -- Option 3: treesitter as a main provider instead -- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, -- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` - require('ufo').setup({ - provider_selector = function(bufnr, filetype, buftype) - return {'treesitter', 'indent'} - end + require("ufo").setup({ + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } + end, }) -- 键盘映射,这里的按键会打开或折叠全部的可折叠位置 - vim.keymap.set('n', 'zR', require('ufo').openAllFolds) - vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) - vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds) - vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0) - end + vim.keymap.set("n", "zR", require("ufo").openAllFolds) + vim.keymap.set("n", "zM", require("ufo").closeAllFolds) + vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds) + vim.keymap.set("n", "zm", require("ufo").closeFoldsWith) -- closeAllFolds == closeFoldsWith(0) + end, } - diff --git a/lua/lazy/plugins/indent.lua b/lua/lazy/plugins/indent.lua deleted file mode 100644 index 6c9cccd..0000000 --- a/lua/lazy/plugins/indent.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - "shellRaining/hlchunk.nvim", - -- 确保这个插件在lsp之后加载,不然会显示为蓝色的线 - event = "VeryLazy", - config = function() - vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { pattern = "*", command = "EnableHL", }) - require('hlchunk').setup({ - chunk = { - enable = true, - use_treesitter = true, - style = { - { fg = "#806d9c" }, - }, - }, - indent = { - chars = { "│", "¦", "┆", "┊", }, - use_treesitter = false, - }, - -- 不显示缩进空白处的点点 - blank = { - enable = false, - }, - -- 让左侧数字高亮 - line_num = { - use_treesitter = true, - }, - }) - end -} diff --git a/lua/lazy/plugins/indentrainbow.lua b/lua/lazy/plugins/indentrainbow.lua index 8731f25..8be0465 100644 --- a/lua/lazy/plugins/indentrainbow.lua +++ b/lua/lazy/plugins/indentrainbow.lua @@ -5,39 +5,29 @@ return { }, config = function() opts = {} - -- Other blankline configuration here - require("ibl").setup(require("indent-rainbowline").make_opts(opts,{ - -- How transparent should the rainbow colors be. 1 is completely opaque, 0 is invisible. 0.07 by default - color_transparency = 0.15, - -- The 24-bit colors to mix with the background. Specified in hex. - -- { 0xffff40, 0x79ff79, 0xff79ff, 0x4fecec, } by default - colors = {"0xff0000","0x00ff00","0x0000ff","0xffff40","0x79ff79","0xff79ff","0x4fecec"}, - })) + local highlight = { + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", + } - -- local highlight = { - -- "RainbowRed", - -- "RainbowYellow", - -- "RainbowBlue", - -- "RainbowOrange", - -- "RainbowGreen", - -- "RainbowViolet", - -- "RainbowCyan", - -- } + local hooks = require("ibl.hooks") + -- create the highlight groups in the highlight setup hook, so they are reset + -- every time the colorscheme changes + hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#61AFEF" }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#C678DD" }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#E06C75" }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#E5C07B" }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) + end) - -- local hooks = require "ibl.hooks" - -- -- create the highlight groups in the highlight setup hook, so they are reset - -- -- every time the colorscheme changes - -- hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - -- vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) - -- vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) - -- vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) - -- vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) - -- vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) - -- vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) - -- vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) - -- end) - - -- require("ibl").setup { indent = { highlight = highlight } } - end + require("ibl").setup({ indent = { highlight = highlight } }) + end, } - diff --git a/lua/lazy/plugins/jump.lua b/lua/lazy/plugins/jump.lua index 475f985..d0df994 100644 --- a/lua/lazy/plugins/jump.lua +++ b/lua/lazy/plugins/jump.lua @@ -1,8 +1,16 @@ return { "folke/flash.nvim", - event = "VeryLazy", + event = "VeryLazy", config = function() - require('flash').setup { + -- 下面映射可以通过取消f和t,但是会覆盖原本的退出可视模式等功能 + -- local map = vim.keymap.set + -- map({ "n", "x", "o" }, "", function() + -- local char = require("flash.plugins.char") + -- if char.state then + -- char.state:hide() + -- end + -- end, { desc = "Cancel Flash Char" }) + require("flash").setup({ labels = "arstdhneioqwfpgjluyzxcvbkm", modes = { -- options used when flash is activated through @@ -12,8 +20,7 @@ return { -- You can always toggle when searching with `require("flash").toggle()` enabled = false, }, - } - } - end + }, + }) + end, } - diff --git a/lua/lazy/plugins/lspconfig.lua b/lua/lazy/plugins/lspconfig.lua index f347c06..52e53ac 100644 --- a/lua/lazy/plugins/lspconfig.lua +++ b/lua/lazy/plugins/lspconfig.lua @@ -1,63 +1,66 @@ return { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', + "neovim/nvim-lspconfig", dependencies = { - { 'neovim/nvim-lspconfig' }, - { 'saghen/blink.cmp' }, - { 'williamboman/mason.nvim' }, - { 'williamboman/mason-lspconfig.nvim' }, + { "saghen/blink.cmp" }, + { "williamboman/mason.nvim" }, { "MysticalDevil/inlay-hints.nvim", event = "LspAttach", config = function() require("inlay-hints").setup() - end - } + end, + }, }, config = function() -- 打算启用的语言服务列表 local servers = { - 'marksman', -- 任意标题aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题h可以预览 - 'lua_ls', - 'rust_analyzer', - 'pylsp', -- Mason对应的安装名称是python-lsp-server - -- 'gopls', + markdown = { "marksman" }, -- 任意标题aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题h可以预览 + lua = { "lua_ls", "lua-language-server" }, -- Mason对应的安装名称是lua-language-server + rust = { "rust_analyzer", "rust-analyzer" }, + python = { "pylsp", "python-lsp-server" }, + -- golang={'gopls'}, } - -- lsp_zero的相关配置 - local lsp_zero = require('lsp-zero') - lsp_zero.on_attach(function(client, bufnr) - lsp_zero.default_keymaps({ buffer = bufnr }) - local opts = { buffer = bufnr } - vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) -- h显示提示文档 - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) -- gd跳转到定义的位置 - vim.keymap.set('n', 'go', vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置 - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置 - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) -- rn变量重命名 - -- vim.keymap.set({ 'n', 'x' }, 'f', function() vim.lsp.buf.format({ async = true }) end, opts) -- f进行代码格式化 - vim.keymap.set('n', 'aw', vim.lsp.buf.code_action, opts) -- aw可以在出现警告或错误的地方打开建议的修复方法 - vim.keymap.set('n', 'd', vim.diagnostic.open_float, opts) -- d浮动窗口显示所在行警告或错误信息 - vim.keymap.set('n', '-', vim.diagnostic.goto_prev, opts) -- -跳转到上一处警告或错误的地方 - vim.keymap.set('n', '=', vim.diagnostic.goto_next, opts) -- +跳转到下一处警告或错误的地方 - end) - -- “符号栏”是行号旁边的装订线中的一个空格。当一行中出现警告或错误时,Neovim 会向您显示一个字母 - lsp_zero.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '»' - }) + vim.keymap.set("n", "h", vim.lsp.buf.hover, opts) -- h显示提示文档 + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- gd跳转到定义的位置 + vim.keymap.set("n", "go", vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置 + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置 + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- rn变量重命名 + vim.keymap.set("n", "aw", vim.lsp.buf.code_action, opts) -- aw可以在出现警告或错误的地方打开建议的修复方法 + vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) -- d浮动窗口显示所在行警告或错误信息 + vim.keymap.set("n", "-", vim.diagnostic.goto_prev, opts) -- -跳转到上一处警告或错误的地方 + vim.keymap.set("n", "=", vim.diagnostic.goto_next, opts) -- +跳转到下一处警告或错误的地方 + -- vim.keymap.set({ 'n', 'x' }, 'f', function() vim.lsp.buf.format({ async = true }) end, opts) -- f进行代码格式化 + -- 通过mason来自动安装语言服务器,可以在对应的代码运行LspIstall来安装可用的语言服务器 - require('mason').setup({}) - require('mason-lspconfig').setup({ - ensure_installed = servers -- 直接把前面的servers列表传递过来 - }) - -- cmp相关配置,通过for读取servers列表循环批量激活语言服务 - local lspconfig = require('lspconfig') - for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - capabilities = require('blink.cmp').get_lsp_capabilities(), + require("mason").setup({}) + local mr = require("mason-registry") + local capabilities = require("blink.cmp").get_lsp_capabilities() + + -- cmp相关配置 + local lspconfig = require("lspconfig") + for lang_group_name, server_names_arr in pairs(servers) do + -- 使用Mason批量安装语言服务器 + local mason_name = server_names_arr[2] or server_names_arr[1] -- Second for Mason, or fallback to first + local p = mr.get_package(mason_name) + if p then -- Check if package actually exists in mason-registry + if not p:is_installed() then + vim.notify( + "Installing Mason package: " .. mason_name .. " (for language: " .. lang_group_name .. ")", + vim.log.levels.INFO + ) + p:install() -- This is synchronous + vim.notify(mason_name .. " installed successfully.", vim.log.levels.INFO) + end + else + vim.notify("Mason package not found: " .. mason_name, vim.log.levels.WARN) + end + + -- 批量激活语言服务 + local lsp = server_names_arr[1] -- First element is for lspconfig + lspconfig[lsp].setup({ + capabilities = capabilities, -- Use the memoized capabilities settings = { - gopls = { + ["gopls"] = { hints = { -- gopls开启hints rangeVariableTypes = true, parameterNames = true, @@ -66,23 +69,23 @@ return { compositeLiteralFields = true, compositeLiteralTypes = true, functionTypeParameters = true, - } + }, }, - Lua = { - hint = { -- Lua开启hints + ["Lua"] = { + hint = { -- Lua开启hints enable = true, -- necessary }, diagnostics = { -- 忽略掉vim配置时一些全局变量语言服务器找不到的警告 globals = { - 'vim', - 'require', - 'opts', + "vim", + "require", + "opts", }, }, }, }, - } + }) end - end + end, } diff --git a/lua/lazy/plugins/markview.lua b/lua/lazy/plugins/markview.lua new file mode 100644 index 0000000..421c2c0 --- /dev/null +++ b/lua/lazy/plugins/markview.lua @@ -0,0 +1,12 @@ +-- For `plugins/markview.lua` users. +return { + "OXY2DEV/markview.nvim", + lazy = false, + opts = { + headings = { + heading_1 = { sign = "" }, + heading_2 = { sign = "" }, + }, + code_blocks = { sign = false }, + }, +} diff --git a/lua/lazy/plugins/rainbow.lua b/lua/lazy/plugins/rainbow.lua deleted file mode 100644 index e5e0789..0000000 --- a/lua/lazy/plugins/rainbow.lua +++ /dev/null @@ -1,21 +0,0 @@ --- === --- === rainbow,彩虹括号,必须要保证安装了treesitter,我分开是为了方便通过文件查找配置 --- === - -return { - 'p00f/nvim-ts-rainbow', - config = function() - require("nvim-treesitter.configs").setup { - rainbow = { - -- `false` will disable the whole extension - enable = true, - -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for - extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean - max_file_lines = nil, -- Do not enable for files with more than n lines, int - -- colors = {}, -- table of hex strings - -- termcolors = {} -- table of colour name strings - } - } - end -} - diff --git a/lua/lazy/plugins/rainbowbracket.lua b/lua/lazy/plugins/rainbowbracket.lua new file mode 100644 index 0000000..a5db6ee --- /dev/null +++ b/lua/lazy/plugins/rainbowbracket.lua @@ -0,0 +1,10 @@ +-- === +-- === rainbow,彩虹括号,必须要保证安装了treesitter,我分开是为了方便通过文件查找配置 +-- === + +return { + "HiPhish/rainbow-delimiters.nvim", + config = function() + require("rainbow-delimiters.setup").setup({}) + end, +} diff --git a/lua/lazy/plugins/themes.lua b/lua/lazy/plugins/themes.lua index 1a36dba..134d301 100644 --- a/lua/lazy/plugins/themes.lua +++ b/lua/lazy/plugins/themes.lua @@ -1,253 +1,38 @@ -- === --- === 底部状态栏+onedark主题 +-- === 主题 -- === - return { - 'nvim-lualine/lualine.nvim', - dependencies = { - 'kyazdani42/nvim-web-devicons', -- 图标 - 'navarasu/onedark.nvim', -- onedark主题 - }, - config = function() - -- Eviline config for lualine - -- Author: shadmansaleh - -- Credit: glepnir - local lualine = require('lualine') - - -- Color table for highlights - -- stylua: ignore - local colors = { - bg = '#202328', - fg = '#bbc2cf', - yellow = '#ECBE7B', - cyan = '#008080', - darkblue = '#081633', - green = '#98be65', - orange = '#FF8800', - violet = '#a9a1e1', - magenta = '#c678dd', - blue = '#51afef', - red = '#ec5f67', - } - - local conditions = { - buffer_not_empty = function() - return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 - end, - hide_in_width = function() - return vim.fn.winwidth(0) > 80 - end, - check_git_workspace = function() - local filepath = vim.fn.expand('%:p:h') - local gitdir = vim.fn.finddir('.git', filepath .. ';') - return gitdir and #gitdir > 0 and #gitdir < #filepath - end, - } - - -- Config - local config = { - options = { - -- Disable sections and component separators - component_separators = '', - section_separators = '', - theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighted by c theme . So we - -- are just setting default looks o statusline - normal = { c = { fg = colors.fg, bg = colors.bg } }, - inactive = { c = { fg = colors.fg, bg = colors.bg } }, - }, - }, - sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - -- These will be filled later - lualine_c = {}, - lualine_x = {}, - }, - inactive_sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - lualine_c = {}, - lualine_x = {}, - }, - } - - -- Inserts a component in lualine_c at left section - local function ins_left(component) - table.insert(config.sections.lualine_c, component) - end - - -- Inserts a component in lualine_x ot right section - local function ins_right(component) - table.insert(config.sections.lualine_x, component) - end - - ins_left { - function() - return '▊' - end, - color = { fg = colors.blue }, -- Sets highlighting of component - padding = { left = 0, right = 1 }, -- We don't need space before this - } - - ins_left { - -- mode component - function() - return '' - end, - color = function() - -- auto change color according to neovims mode - local mode_color = { - n = colors.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.orange, - S = colors.orange, - [''] = colors.orange, - ic = colors.yellow, - R = colors.violet, - Rv = colors.violet, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red, + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + opts = { + transparent_background = true, + custom_highlights = function(colors) + return { + LineNr = { fg = colors.surface2 }, + Visual = { bg = colors.overlay0 }, + Search = { bg = colors.surface2 }, + IncSearch = { bg = colors.lavender }, + CurSearch = { bg = colors.lavender }, + MatchParen = { bg = colors.lavender, fg = colors.base, bold = true }, } - return { fg = mode_color[vim.fn.mode()] } end, - padding = { right = 1 }, - } - - ins_left { - -- filesize component - 'filesize', - cond = conditions.buffer_not_empty, - } - - ins_left { - 'filename', - cond = conditions.buffer_not_empty, - color = { fg = colors.magenta, gui = 'bold' }, - } - - ins_left { 'location' } - - ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } - - ins_left { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ' }, - diagnostics_color = { - color_error = { fg = colors.red }, - color_warn = { fg = colors.yellow }, - color_info = { fg = colors.cyan }, + integrations = { + barbar = true, + blink_cmp = true, + gitsigns = true, + mason = true, + noice = true, + notify = true, + nvimtree = true, + rainbow_delimiters = true, }, - } + }, + config = function(_, opts) + require("catppuccin").setup(opts) - -- Insert mid section. You can make any number of sections in neovim :) - -- for lualine it's any number greater then 2 - ins_left { - function() - return '%=' - end, - } - - ins_left { - -- Lsp server name . - function() - local msg = 'No Active Lsp' - local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') - local clients = vim.lsp.get_active_clients() - if next(clients) == nil then - return msg - end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return client.name - end - end - return msg - end, - icon = ' LSP:', - color = { fg = '#ffffff', gui = 'bold' }, - } - - -- Add components to right sections - ins_right { - 'o:encoding', -- option component same as &encoding in viml - fmt = string.upper, -- I'm not sure why it's upper case either ;) - cond = conditions.hide_in_width, - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'fileformat', - fmt = string.upper, - icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'branch', - icon = '', - color = { fg = colors.violet, gui = 'bold' }, - } - - ins_right { - 'diff', - -- Is it me or the symbol for modified us really weird - symbols = { added = ' ', modified = '柳 ', removed = ' ' }, - diff_color = { - added = { fg = colors.green }, - modified = { fg = colors.orange }, - removed = { fg = colors.red }, - }, - cond = conditions.hide_in_width, - } - - ins_right { - function() - return '▊' - end, - color = { fg = colors.blue }, - padding = { left = 1 }, - } - - -- Now don't forget to initialize lualine - lualine.setup(config) - - - -- === - -- === 主题配置 theme - -- === - -- vim.cmd 'colorscheme space-vim-dark' - -- 使用灰色注释 - vim.cmd 'hi Comment guifg=#5C6370 ctermfg=59' - -- 使用透明背景 - -- vim.cmd 'hi Normal ctermbg=NONE guibg=NONE' - -- vim.cmd 'hi LineNr ctermbg=NONE guibg=NONE' - -- vim.cmd 'hi SignColumn ctermbg=NONE guibg=NONE' - - -- dark,darker,cool,deep,warm,warmer - require('onedark').setup { - style = 'darker' - } - require('onedark').load() - end + vim.cmd.colorscheme("catppuccin") + end, + }, } - diff --git a/lua/lazy/plugins/topbar.lua b/lua/lazy/plugins/topbar.lua new file mode 100644 index 0000000..9ebbca9 --- /dev/null +++ b/lua/lazy/plugins/topbar.lua @@ -0,0 +1,13 @@ +return { + "romgrk/barbar.nvim", + dependencies = { + "lewis6991/gitsigns.nvim", -- OPTIONAL: for git status + "nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons + }, + init = function() + vim.g.barbar_auto_setup = true + end, + opts = { + }, + version = "^1.0.0", -- optional: only update when a new 1.x version is released +}