This commit is contained in:
jay 2025-05-13 23:59:07 +08:00
parent 1dd35ed47a
commit 89fb2a1b56
7 changed files with 170 additions and 3 deletions

View File

@ -13,8 +13,8 @@ keymap.set('n', '<leader>sws', '<c-w>j')
keymap.set('n', '<leader>swa', '<c-w>h') keymap.set('n', '<leader>swa', '<c-w>h')
keymap.set('n', '<leader>swd', '<c-w>l') keymap.set('n', '<leader>swd', '<c-w>l')
keymap.set('n', '<leader>aa', 'gT') keymap.set('n', '<leader><leader>a', 'gT')
keymap.set('n', '<leader>dd', 'gt') keymap.set('n', '<leader><leader>d', 'gt')
keymap.set('n', '<F9>', ':%!jq .<CR>') keymap.set('n', '<F9>', ':%!jq .<CR>')

View File

@ -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" },
},
},
}

View File

@ -144,4 +144,6 @@ return {
end end
}, },
require('plugins.vim-ai'), require('plugins.vim-ai'),
-- ai 助手
require('plugins.avante'),
} }

View File

@ -72,6 +72,10 @@ return {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
} }
nvlsp['lua_ls'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
end end
} }

View File

@ -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
}

View File

@ -206,6 +206,7 @@ ln-lab = postgresql://postgres:eKZJFdG9L5vaREXN@192.168.88.15:32014
professorx-dev = postgresql://postgres:e8b960296e22@192.168.88.6 professorx-dev = postgresql://postgres:e8b960296e22@192.168.88.6
k8s-gcp-dev = postgresql://postgres:eKZJFdG9L5vaREXN@10.140.0.51:32008 k8s-gcp-dev = postgresql://postgres:eKZJFdG9L5vaREXN@10.140.0.51:32008
k8s-log-collector = postgresql://postgres:j88ArUndbrAe@192.168.88.23:5432 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 # Format for number representation
# for decimal "d" - 12345678, ",d" - 12,345,678 # for decimal "d" - 12345678, ",d" - 12,345,678

View File

@ -192,7 +192,7 @@ input type:touchpad {
# Switch the current container between different layout styles # Switch the current container between different layout styles
bindsym $mod+s layout stacking bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed bindsym $mod+t layout tabbed
bindsym $mod+e layout toggle split bindsym $mod+e layout toggle split
# Make the current focus fullscreen # Make the current focus fullscreen