summaryrefslogtreecommitdiff
path: root/config/nvim/lua/plugins/codecompanion.lua
blob: d8eec4abbad6bbff6fb3a95f465ffa3a1e1b1411 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
return {
	"olimorris/codecompanion.nvim",
	dependencies = {
		"nvim-lua/plenary.nvim",
		"nvim-treesitter/nvim-treesitter",
		{
			"ravitemer/mcphub.nvim",
			dependencies = {
				"nvim-lua/plenary.nvim",
			},
			build = "npm install -g mcp-hub@latest",
			config = function()
				require("mcphub").setup()
			end,
		},
	},
	opts = {
		opts = {
			log_level = "DEBUG", -- or "TRACE"
		},
		extensions = {
			mcphub = {
				callback = "mcphub.extensions.codecompanion",
				opts = {
					make_tools = true, -- Make individual tools (@server__tool) and server groups (@server) from MCP servers
					show_server_tools_in_chat = true, -- Show individual tools in chat completion (when make_tools=true)
					add_mcp_prefix_to_tool_names = false, -- Add mcp__ prefix (e.g `@mcp__github`, `@mcp__neovim__list_issues`)
					show_result_in_chat = true, -- Show tool results directly in chat buffer
					format_tool = nil, -- function(tool_name:string, tool: CodeCompanion.Agent.Tool) : string Function to format tool names to show in the chat buffer
					-- MCP Resources
					make_vars = true, -- Convert MCP resources to #variables for prompts
					-- MCP Prompts
					make_slash_commands = true, -- Add MCP prompts as /slash commands
				},
			},
		},
		strategies = {
			chat = {
				adapter = "scbt",
				tools = {
					opts = {
						auto_submit_errors = true, -- Send any errors to the LLM automatically?
						auto_submit_success = true, -- Send any successful output to the LLM automatically?
						default_tools = {
							"full_stack_dev",
							"mcp",
							"filesystem",
						},
					},
					opts = {
						system_promt = "Ты полезный ассистент в редакторе neovim в плагине codecompanion. Основной зык программирования - go. Отвечай всегда на русском языке.",
					},
				},
			},
			inline = {
				adapter = "scbt",
			},
		},
		memory = {
			opts = {
				chat = {
					enabled = true,
				},
			},
		},
		adapters = {
			http = {
				scbt = function()
					return require("codecompanion.adapters").extend("openai_compatible", {
						env = {
							api_key = "cmd: age -d -i ~/.ssh/id_ed25519 ~/.openai-api-key.age",
							url = "http://localhost:8888/api",
						},

						schema = {
							model = {
								default = "qwen3-235b-it",
								choices = {
									"qwen3-235b-it",
									"Qwen3-Coder-30B-A3B-Instruct-FP8",
									"qwen2-5-coder-1-5b",
								},
								num_ctx = {
									default = 120000,
								},
								think = {
									default = true,
								},
								keep_alive = {
									default = "5m",
								},
							},
						},
					})
				end,
			},
		},
	},
}