2025-01-13 15:25:52 +00:00
|
|
|
> [!IMPORTANT]
|
|
|
|
> A free large language model(LLM) plugin that allows you to interact with LLM in Neovim.
|
|
|
|
>
|
|
|
|
> The main functions include but are not limited to:
|
|
|
|
>
|
|
|
|
> - AI chat
|
|
|
|
> - Word translation
|
|
|
|
> - Code explanation
|
|
|
|
> - Code optimization
|
|
|
|
> - Test case generation
|
|
|
|
> - AI translation
|
|
|
|
> - Generation of git commit messages
|
|
|
|
> - Generation of docstrings
|
|
|
|
|
|
|
|
Link: [Github:Kurama622/llm.nvim](https://github.com/Kurama622/llm.nvim)
|
|
|
|
|
|
|
|
# Install
|
|
|
|
|
|
|
|
- lazy.nvim
|
|
|
|
|
|
|
|
```lua
|
|
|
|
return {
|
|
|
|
{
|
|
|
|
"Kurama622/llm.nvim",
|
|
|
|
dependencies = { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim" },
|
2025-01-21 02:16:30 +00:00
|
|
|
cmd = { "LLMSessionToggle", "LLMSelectedTextHandler", "LLMAppHandler" },
|
2025-01-13 15:25:52 +00:00
|
|
|
config = function()
|
|
|
|
require("llm").setup({
|
|
|
|
url = "https://api.deepseek.com/chat/completions",
|
|
|
|
model = "deepseek-chat",
|
|
|
|
api_type = "openai",
|
|
|
|
max_tokens = 4096,
|
|
|
|
temperature = 0.3,
|
|
|
|
top_p = 0.7,
|
|
|
|
|
|
|
|
prompt = "You are a helpful Chinese assistant.",
|
|
|
|
|
|
|
|
prefix = {
|
|
|
|
user = { text = " ", hl = "Title" },
|
|
|
|
assistant = { text = " ", hl = "Added" },
|
|
|
|
},
|
|
|
|
|
|
|
|
-- history_path = "/tmp/llm-history",
|
|
|
|
save_session = true,
|
|
|
|
max_history = 15,
|
|
|
|
max_history_name_length = 20,
|
|
|
|
|
|
|
|
-- stylua: ignore
|
|
|
|
keys = {
|
|
|
|
-- The keyboard mapping for the input window.
|
|
|
|
["Input:Submit"] = { mode = "n", key = "<cr>" },
|
|
|
|
["Input:Cancel"] = { mode = {"n", "i"}, key = "<C-c>" },
|
|
|
|
["Input:Resend"] = { mode = {"n", "i"}, key = "<C-r>" },
|
|
|
|
|
|
|
|
-- only works when "save_session = true"
|
|
|
|
["Input:HistoryNext"] = { mode = {"n", "i"}, key = "<C-j>" },
|
|
|
|
["Input:HistoryPrev"] = { mode = {"n", "i"}, key = "<C-k>" },
|
|
|
|
|
|
|
|
-- The keyboard mapping for the output window in "split" style.
|
|
|
|
["Output:Ask"] = { mode = "n", key = "i" },
|
|
|
|
["Output:Cancel"] = { mode = "n", key = "<C-c>" },
|
|
|
|
["Output:Resend"] = { mode = "n", key = "<C-r>" },
|
|
|
|
|
|
|
|
-- The keyboard mapping for the output and input windows in "float" style.
|
|
|
|
["Session:Toggle"] = { mode = "n", key = "<leader>ac" },
|
|
|
|
["Session:Close"] = { mode = "n", key = {"<esc>", "Q"} },
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
keys = {
|
|
|
|
{ "<leader>ac", mode = "n", "<cmd>LLMSessionToggle<cr>" },
|
|
|
|
{ "<leader>ae", mode = "v", "<cmd>LLMSelectedTextHandler 请解释下面这段代码<cr>" },
|
|
|
|
{ "<leader>ts", mode = "x", "<cmd>LLMSelectedTextHandler 英译汉<cr>" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|