From 89fb2a1b56891d63e46b2eb162ccbca61d52aaef Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 13 May 2025 23:59:07 +0800 Subject: [PATCH] update --- home/dot_config/nvim/lua/basic/mapping.lua | 4 +- home/dot_config/nvim/lua/plugins/avante.lua | 61 +++++++++++++ home/dot_config/nvim/lua/plugins/list.lua | 2 + home/dot_config/nvim/lua/plugins/lsp.lua | 4 + home/dot_config/nvim/lua/plugins/vim-ai.lua | 99 +++++++++++++++++++++ home/dot_config/pgcli/config | 1 + home/dot_config/sway/config | 2 +- 7 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 home/dot_config/nvim/lua/plugins/avante.lua create mode 100644 home/dot_config/nvim/lua/plugins/vim-ai.lua diff --git a/home/dot_config/nvim/lua/basic/mapping.lua b/home/dot_config/nvim/lua/basic/mapping.lua index eaf41d3..eda452c 100644 --- a/home/dot_config/nvim/lua/basic/mapping.lua +++ b/home/dot_config/nvim/lua/basic/mapping.lua @@ -13,8 +13,8 @@ keymap.set('n', 'sws', 'j') keymap.set('n', 'swa', 'h') keymap.set('n', 'swd', 'l') -keymap.set('n', 'aa', 'gT') -keymap.set('n', 'dd', 'gt') +keymap.set('n', 'a', 'gT') +keymap.set('n', 'd', 'gt') keymap.set('n', '', ':%!jq .') diff --git a/home/dot_config/nvim/lua/plugins/avante.lua b/home/dot_config/nvim/lua/plugins/avante.lua new file mode 100644 index 0000000..d19cbcc --- /dev/null +++ b/home/dot_config/nvim/lua/plugins/avante.lua @@ -0,0 +1,61 @@ +-- ai 助手套件 +return { + "yetone/avante.nvim", + version = false, + lazy = true, + event = "VeryLazy", + opts = { + provider = "copilot", + ollama = { + model = "gemma3:4b", + endpoint = "http://127.0.0.1:11434", + timeout = 60000, -- Timeout in milliseconds + options = { + temperature = 0, + num_ctx = 10240, + keep_alive = "5m", + }, + }, + copilot = { + }, + }, + build = "make", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- 以下依赖项是可选的, + "echasnovski/mini.pick", -- 用于文件选择器提供者 mini.pick + "nvim-telescope/telescope.nvim", -- 用于文件选择器提供者 telescope + "hrsh7th/nvim-cmp", -- avante 命令和提及的自动完成 + "ibhagwan/fzf-lua", -- 用于文件选择器提供者 fzf + "nvim-tree/nvim-web-devicons", -- 或 echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- 用于 providers='copilot' + { + -- 支持图像粘贴 + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- 推荐设置 + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- Windows 用户必需 + use_absolute_path = true, + }, + }, + }, + { + -- 如果您有 lazy=true,请确保正确设置 + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, +} diff --git a/home/dot_config/nvim/lua/plugins/list.lua b/home/dot_config/nvim/lua/plugins/list.lua index a7f383a..58101d5 100644 --- a/home/dot_config/nvim/lua/plugins/list.lua +++ b/home/dot_config/nvim/lua/plugins/list.lua @@ -144,4 +144,6 @@ return { end }, require('plugins.vim-ai'), + -- ai 助手 + require('plugins.avante'), } diff --git a/home/dot_config/nvim/lua/plugins/lsp.lua b/home/dot_config/nvim/lua/plugins/lsp.lua index ad63e44..de59fc2 100644 --- a/home/dot_config/nvim/lua/plugins/lsp.lua +++ b/home/dot_config/nvim/lua/plugins/lsp.lua @@ -72,6 +72,10 @@ return { capabilities = capabilities, on_attach = on_attach, } + nvlsp['lua_ls'].setup{ + capabilities = capabilities, + on_attach = on_attach, + } end } diff --git a/home/dot_config/nvim/lua/plugins/vim-ai.lua b/home/dot_config/nvim/lua/plugins/vim-ai.lua new file mode 100644 index 0000000..732d55c --- /dev/null +++ b/home/dot_config/nvim/lua/plugins/vim-ai.lua @@ -0,0 +1,99 @@ +return { + "madox2/vim-ai", + config = function () + vim.g.vim_ai_roles_config_file = '/home/jay/.config/nvim/vim-ai-roles.ini' + + local vim_ai_endpoint_url = "http://localhost:11434/v1/chat/completions" + -- local vim_ai_endpoint_url = "http://192.168.88.11:11434/v1/chat/completions" + local vim_ai_model = "gemma3:12b" + local vim_ai_model_large = "deepseek-r1" + local vim_ai_temperature = 0.3 + + local vim_ai_chat_config = { + engine = "chat", + options = { + model = vim_ai_model, + temperature = vim_ai_temperature, + endpoint_url = vim_ai_endpoint_url, + auth_type = "none", + max_tokens = 0, + request_timeout = 180, + }, + ui = { + code_syntax_enabled = 1, + }, + } + + local vim_ai_edit_config = { + engine = "chat", + options = { + model = vim_ai_model, + temperature = vim_ai_temperature, + endpoint_url = vim_ai_endpoint_url, + auth_type = "none", + max_tokens = 0, + request_timeout = 180, + }, + ui = { + paste_mode = 1, + }, + } + + vim.g.vim_ai_chat = vim_ai_chat_config + vim.g.vim_ai_complete = vim_ai_edit_config + vim.g.vim_ai_edit = vim_ai_edit_config + + function git_commit_message_fn(model, intent) + model = model or vim_ai_model + intent = intent or "" + local diff = vim.fn.system('git --no-pager diff --staged') + local initial_prompt = [[ + You are a Senior Software Engineer responsible for crafting clear and informative Git commit messages. Your goal is to ensure that every commit message contributes to the maintainability and understandability of the codebase. A well-written commit message allows other developers to quickly grasp the purpose and impact of the changes. + +**Here's the structure we'll use for all commit messages:** + +1. **Subject Line (Required):** + * Use a conventional prefix: `feat:`, `fix:`, `chore:`, `refactor:`, `docs:`, `test:`, `style:`, `perf:`, `build:` + * Keep it concise – 50 characters or less. + * Use an imperative verb (e.g., "Add...", "Fix...", "Update...", "Remove..."). + +2. **Body (Optional, but recommended):** + * Start with a blank line after the subject line. + * Provide a brief explanation (3-4 bullet points) of *why* the change was made, not *what* was changed. + * Keep lines under 72 characters. + * Avoid implementation details. + +**Do not include:** Markdown, emojis, or overly detailed code descriptions. + + ]] + local prompt = [["\n" .. "**Now, generate a Git commit message based on the following changes:**\n```" ]] .. diff .. [[```]] + local range = 0 + + if not (intent == "") + then + prompt = [[Short Description:\n"]] .. intent .. prompt + end + + local config = { + engine = "chat", + options = { + model = model, + initial_prompt = initial_prompt, + endpoint_url = vim_ai_endpoint_url, + auth_type = "none", + temperature = 0.8, + request_timeout = 240, + }, + } + vim.api.nvim_call_function("vim_ai#AIRun", { range, config, prompt }) + end + + vim.api.nvim_create_user_command("GitCommitMessage", function(opts) + git_commit_message_fn(vim_ai_model, opts.args) + end, {nargs = '?'}) + vim.api.nvim_create_user_command("GitCommitMessageL", function(opts) + git_commit_message_fn(vim_ai_model_large, opts.args) + end, {nargs = '?'}) + + end +} diff --git a/home/dot_config/pgcli/config b/home/dot_config/pgcli/config index e2d775e..b836452 100644 --- a/home/dot_config/pgcli/config +++ b/home/dot_config/pgcli/config @@ -206,6 +206,7 @@ ln-lab = postgresql://postgres:eKZJFdG9L5vaREXN@192.168.88.15:32014 professorx-dev = postgresql://postgres:e8b960296e22@192.168.88.6 k8s-gcp-dev = postgresql://postgres:eKZJFdG9L5vaREXN@10.140.0.51:32008 k8s-log-collector = postgresql://postgres:j88ArUndbrAe@192.168.88.23:5432 +lab-pg = postgresql://postgres:f87fa2a74009f9b63acf65762b89b411@192.168.200.71:32750 # Format for number representation # for decimal "d" - 12345678, ",d" - 12,345,678 diff --git a/home/dot_config/sway/config b/home/dot_config/sway/config index 7d66c8d..d6aa791 100644 --- a/home/dot_config/sway/config +++ b/home/dot_config/sway/config @@ -192,7 +192,7 @@ input type:touchpad { # Switch the current container between different layout styles bindsym $mod+s layout stacking - bindsym $mod+w layout tabbed + bindsym $mod+t layout tabbed bindsym $mod+e layout toggle split # Make the current focus fullscreen