[Nvim] Gen -> CodeCompanion
This commit is contained in:
34
.config/nvim/lua/configs/codecompanion.lua
Normal file
34
.config/nvim/lua/configs/codecompanion.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
local model = "Qwen3-Coder-30B-Instruct-IQ4_XS"
|
||||||
|
|
||||||
|
return {
|
||||||
|
adapters = {
|
||||||
|
http = {
|
||||||
|
llama_cpp = function()
|
||||||
|
return require("codecompanion.adapters").extend("openai_compatible", {
|
||||||
|
env = {
|
||||||
|
url = "http://localhost:11343",
|
||||||
|
chat_url = "/v1/chat/completions",
|
||||||
|
models_endpoint = "/v1/models",
|
||||||
|
api_key = "dummy",
|
||||||
|
},
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = model,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
interactions = {
|
||||||
|
chat = {
|
||||||
|
adapter = "llama_cpp",
|
||||||
|
},
|
||||||
|
inline = {
|
||||||
|
adapter = "llama_cpp",
|
||||||
|
},
|
||||||
|
cmd = {
|
||||||
|
adapter = "llama_cpp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ return {
|
|||||||
-- Only intended to be used for plugin development / debugging.
|
-- Only intended to be used for plugin development / debugging.
|
||||||
log_runtime = false,
|
log_runtime = false,
|
||||||
-- Filetypes this plugin will run on.
|
-- Filetypes this plugin will run on.
|
||||||
file_types = { "markdown" },
|
file_types = { "markdown", "gitcommit", "codecompanion" },
|
||||||
-- Takes buffer as input, if it returns true this plugin will not attach to the buffer
|
-- Takes buffer as input, if it returns true this plugin will not attach to the buffer
|
||||||
ignore = function()
|
ignore = function()
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ map("n", "<leader>fs", "<cmd>Telescope grep_string<CR>", { desc = "Find selected
|
|||||||
map("n", "<leader>fk", "<cmd>Telescope keymaps<CR>", { desc = "Find keymaps" })
|
map("n", "<leader>fk", "<cmd>Telescope keymaps<CR>", { desc = "Find keymaps" })
|
||||||
map("n", "<leader>fd", "<cmd>Telescope diagnostics<CR>", { desc = "Diagnostics" })
|
map("n", "<leader>fd", "<cmd>Telescope diagnostics<CR>", { desc = "Diagnostics" })
|
||||||
|
|
||||||
map({ "n", "v" }, "<leader>ge", "<cmd>Gen<CR>", { desc = "Gen.nvim" })
|
map({ "n", "v" }, "<leader>ge", "<cmd>CodeCompanion<CR>", { desc = "CodeCompanion" })
|
||||||
|
map({ "n", "v" }, "<leader>ga", "<cmd>CodeCompanionActions<CR>", { desc = "CodeCompanion actions" })
|
||||||
|
map("n", "<leader>gc", "<cmd>CodeCompanionChat Toggle<CR>", { desc = "CodeCompanion chat" })
|
||||||
|
map("v", "<leader>gc", "<cmd>CodeCompanionChat Add<CR>", { desc = "Send selection to CodeCompanion chat" })
|
||||||
|
|
||||||
-- P paste with
|
-- P paste with
|
||||||
-- global marks
|
-- global marks
|
||||||
|
|||||||
@@ -12,66 +12,21 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Custom Parameters (with defaults)
|
|
||||||
{
|
{
|
||||||
"David-Kunz/gen.nvim",
|
"olimorris/codecompanion.nvim",
|
||||||
cmd = "Gen",
|
version = "^19.0.0",
|
||||||
opts = {
|
lazy = false,
|
||||||
-- model = "llama3.2:3b", -- The default model to use.
|
dependencies = {
|
||||||
model = "qwen3-coder:30b",
|
"nvim-lua/plenary.nvim",
|
||||||
quit_map = "q", -- set keymap to close the response window
|
"nvim-treesitter/nvim-treesitter",
|
||||||
retry_map = "<c-r>", -- set keymap to re-send the current prompt
|
|
||||||
accept_map = "<c-cr>", -- set keymap to replace the previous selection with the last result
|
|
||||||
-- host = "localhost", -- The host running the Ollama service.
|
|
||||||
host = "192.168.0.204", -- The host running the Ollama service.
|
|
||||||
port = "11434", -- The port on which the Ollama service is listening.
|
|
||||||
display_mode = "vertical-split", -- The display mode. Can be "float" or "split" or "horizontal-split" or "vertical-split".
|
|
||||||
show_prompt = true, -- Shows the prompt submitted to Ollama. Can be true (3 lines) or "full".
|
|
||||||
show_model = true, -- Displays which model you are using at the beginning of your chat session.
|
|
||||||
no_auto_close = false, -- Never closes the window automatically.
|
|
||||||
file = false, -- Write the payload to a temporary file to keep the command short.
|
|
||||||
hidden = false, -- Hide the generation window (if true, will implicitly set `prompt.replace = true`), requires Neovim >= 0.10
|
|
||||||
-- Function to initialize Ollama
|
|
||||||
command = function(options)
|
|
||||||
local body = { model = options.model, stream = true }
|
|
||||||
return "curl --silent --no-buffer -X POST http://"
|
|
||||||
.. options.host
|
|
||||||
.. ":"
|
|
||||||
.. options.port
|
|
||||||
.. "/api/chat -d $body"
|
|
||||||
end,
|
|
||||||
-- The command for the Ollama service. You can use placeholders $prompt, $model and $body (shellescaped).
|
|
||||||
-- This can also be a command string.
|
|
||||||
-- The executed command must return a JSON object with { response, context }
|
|
||||||
-- (context property is optional).
|
|
||||||
-- list_models = '<omitted lua function>', -- Retrieves a list of model names
|
|
||||||
result_filetype = "markdown", -- Configure filetype of the result buffer
|
|
||||||
debug = false, -- Prints errors and the command which is run.
|
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
opts = function()
|
||||||
require("gen").setup(opts)
|
return require "configs.codecompanion"
|
||||||
|
|
||||||
local prompts = require("gen").prompts
|
|
||||||
|
|
||||||
prompts["Markdown_links"] = {
|
|
||||||
prompt = "Make markdown links wherever you find link in the following text, and generate the namas accordingly:\n$text",
|
|
||||||
replace = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
prompts["Optimize code"] = {
|
|
||||||
prompt = "Check if code can be optimized for speed and readability:\n$text",
|
|
||||||
replace = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
prompts["Genetrate types "] = {
|
|
||||||
prompt = "Check if types are correct in this code, fix and optimize if something is needed:\n$text",
|
|
||||||
replace = true,
|
|
||||||
}
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MeanderingProgrammer/render-markdown.nvim",
|
"MeanderingProgrammer/render-markdown.nvim",
|
||||||
ft = { "markdown", "gitcommit" },
|
ft = { "markdown", "gitcommit", "codecompanion" },
|
||||||
opts = function()
|
opts = function()
|
||||||
return require "configs.render-markdown"
|
return require "configs.render-markdown"
|
||||||
end,
|
end,
|
||||||
|
|||||||
Reference in New Issue
Block a user