diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 130c64c..0606cf0 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -6,8 +6,10 @@ "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, "blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" }, "blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" }, + "buf": { "branch": "main", "commit": "49785647e5e0e316f3fa2c2dab7bca225579018b" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" }, + "codecompanion.nvim": { "branch": "main", "commit": "e0780fa9fda504ffb89307cabcb6cbe1ce8eb60c" }, "conform.nvim": { "branch": "master", "commit": "5ac2bb57a9096f00ca50e1a3c46020d5930319b8" }, "dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, diff --git a/nvim/lua/plugins/avante.lua b/nvim/lua/plugins/avante.lua index 7adac3a..1d06717 100644 --- a/nvim/lua/plugins/avante.lua +++ b/nvim/lua/plugins/avante.lua @@ -1,4 +1,4 @@ -return { + return { { "yetone/avante.nvim", enabled = false, -- 临时禁用 avante diff --git a/nvim/lua/plugins/codecompanion.lua b/nvim/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..805d2f6 --- /dev/null +++ b/nvim/lua/plugins/codecompanion.lua @@ -0,0 +1,59 @@ +return { + { + "olimorris/codecompanion.nvim", + enabled = false, -- 临时禁用 CodeCompanion + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { "a", nil, desc = "CodeCompanion" }, + { "ac", "CodeCompanionChat", desc = "CodeCompanion Chat" }, + { "ai", "CodeCompanionInline", desc = "CodeCompanion Inline" }, + { "am", "CodeCompanionCmd", desc = "CodeCompanion Cmd" }, + { "at", "CodeCompanionToggle", desc = "CodeCompanion Toggle" }, + }, + opts = { + -- 配置策略,使用 gemini_cli adapter + strategies = { + chat = { + adapter = "gemini_cli", -- chat 模式使用 gemini_cli + }, + inline = { + adapter = "gemini_cli", -- inline 模式使用 gemini_cli + }, + cmd = { + adapter = "gemini_cli", -- cmd 模式使用 gemini_cli + }, + }, + -- 配置 adapters + adapters = { + acp = { + gemini_cli = function() + return require("codecompanion.adapters").extend("gemini_cli", { + -- 使用 OAuth 登录方式,不使用 API key + defaults = { + auth_method = "oauth", -- 使用 OAuth 网页登录 + timeout = 20000, + }, + -- 不设置 GEMINI_API_KEY,强制使用 OAuth 登录 + env = { + -- 不设置 GEMINI_API_KEY,让 Gemini CLI 使用已缓存的 OAuth 凭证 + -- 代理配置(如果需要通过代理访问) + HTTP_PROXY = os.getenv("HTTP_PROXY") or os.getenv("http_proxy"), + HTTPS_PROXY = os.getenv("HTTPS_PROXY") or os.getenv("https_proxy"), + ALL_PROXY = os.getenv("ALL_PROXY") or os.getenv("all_proxy"), + NO_PROXY = os.getenv("NO_PROXY") or os.getenv("no_proxy"), + }, + -- Gemini CLI 命令配置 + commands = { + default = { "gemini", "cli", "--experimental-acp" }, + }, + }) + end, + }, + }, + }, + }, +} + diff --git a/nvim/lua/plugins/gemini-cli.lua b/nvim/lua/plugins/gemini-cli.lua index 7120b8f..1f8025f 100644 --- a/nvim/lua/plugins/gemini-cli.lua +++ b/nvim/lua/plugins/gemini-cli.lua @@ -1,4 +1,4 @@ -return { + return { { "marcinjahn/gemini-cli.nvim", cmd = "Gemini", -- 懒加载,使用 :Gemini 命令时加载 @@ -6,7 +6,8 @@ return { "folke/snacks.nvim", -- 必需的依赖 }, keys = { - { "aa", "Gemini ask", desc = "Ask Gemini" }, + { "a", nil, desc = "Gemini CLI" }, + { "aq", "Gemini ask", desc = "Ask Gemini" }, { "ac", "Gemini toggle", desc = "Toggle Gemini CLI" }, { "af", "Gemini add_file", desc = "Add File to Gemini" }, { "ar", "Gemini --resume", desc = "Resume Gemini" }, diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index ec52808..85205ab 100644 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -2,17 +2,18 @@ return { { "mason-org/mason.nvim", opts = function(_, opts) - vim.list_extend(opts.ensure_installed, { - "stylua", - "selene", - "luacheck", - --"bashls", - "shfmt", - --"tailwindcss", - --"tsserver", - "pylyzer", - --"cssls", - }) + vim.list_extend(opts.ensure_installed, { + "stylua", + "selene", + "luacheck", + --"bashls", + "shfmt", + --"tailwindcss", + --"tsserver", + "pylyzer", + --"cssls", + "bufls", -- Protocol Buffers LSP + }) end, }, } diff --git a/nvim/lua/plugins/nvim-lspconfig.lua b/nvim/lua/plugins/nvim-lspconfig.lua index 3fe8d6c..bc06994 100644 --- a/nvim/lua/plugins/nvim-lspconfig.lua +++ b/nvim/lua/plugins/nvim-lspconfig.lua @@ -9,6 +9,7 @@ return { inlay_hints = { enabled = false }, ---@type lspconfig.options servers = { + bufls = {}, -- Protocol Buffers LSP cssls = {}, tailwindcss = { root_dir = function(...) diff --git a/nvim/lua/plugins/protobuf.lua b/nvim/lua/plugins/protobuf.lua new file mode 100644 index 0000000..694f6fa --- /dev/null +++ b/nvim/lua/plugins/protobuf.lua @@ -0,0 +1,12 @@ +return { + -- Protocol Buffers 支持通过以下方式提供: + -- 1. 语法高亮:通过 treesitter(需要在 treesitter.lua 中添加 "proto") + -- 2. LSP 支持:通过 bufls(已在 nvim-lspconfig.lua 和 mason.lua 中配置) + -- + -- 如果需要额外的语法高亮插件,可以使用: + -- { + -- "protocolbuffers/protobuf", + -- ft = { "proto" }, + -- }, +} + diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 88ee5a1..2d8253f 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -115,9 +115,11 @@ return { local telescope = require("telescope") local actions = require("telescope.actions") local fb_actions = require("telescope").extensions.file_browser.actions - local trouble = require("trouble.providers.telescope") + local trouble = require("trouble.sources.telescope") - opts.defaults = vim.tbl_deep_extend("force", opts.defaults, { + -- 确保 opts 和其子表存在 + opts = opts or {} + opts.defaults = vim.tbl_deep_extend("force", opts.defaults or {}, { wrap_results = true, layout_strategy = "horizontal", layout_config = { prompt_position = "top" }, @@ -127,20 +129,20 @@ return { i = { [""] = actions.close, [""] = actions.close, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = trouble.open_with_trouble, - [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = trouble.open, + [""] = actions.smart_send_to_qflist + actions.open_qflist, }, n = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous, - [""] = trouble.open_with_trouble, + [""] = trouble.open, [""] = actions.smart_send_to_qflist + actions.open_qflist }, }, }) - opts.pickers = { + opts.pickers = vim.tbl_deep_extend("force", opts.pickers or {}, { diagnostics = { theme = "ivy", initial_mode = "normal", @@ -148,8 +150,8 @@ return { preview_cutoff = 9999, }, }, - } - opts.extensions = { + }) + opts.extensions = vim.tbl_deep_extend("force", opts.extensions or {}, { file_browser = { theme = "dropdown", -- disables netrw and use telescope-file-browser in its place @@ -178,7 +180,7 @@ return { }, }, }, - } + }) telescope.setup(opts) require("telescope").load_extension("fzf") require("telescope").load_extension("file_browser") diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 35f718d..93b7594 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -4,28 +4,29 @@ return { { "nvim-treesitter/nvim-treesitter", opts = { - ensure_installed = { - "astro", - "cmake", - "cpp", - "css", - "fish", - "gitignore", - "go", - "graphql", - "html", - "java", - "json", - "lua", - "php", - "rust", - "scss", - "sql", - "svelte", - "toml", - "tsx", - "yaml", - }, + ensure_installed = { + "astro", + "cmake", + "cpp", + "css", + "fish", + "gitignore", + "go", + "graphql", + "html", + "java", + "json", + "lua", + "php", + "proto", -- Protocol Buffers + "rust", + "scss", + "sql", + "svelte", + "toml", + "tsx", + "yaml", + }, -- matchup = { -- enable = true,