mirror of
				https://github.com/mitchell/dotfiles.git
				synced 2025-11-03 21:25:26 +00:00 
			
		
		
		
	refactor: Use helper function to create adapters
This commit is contained in:
		
							parent
							
								
									f8d58198c0
								
							
						
					
					
						commit
						ef8b5dc97f
					
				| 
						 | 
					@ -1,5 +1,14 @@
 | 
				
			||||||
-- lua/plugins/tools.lua
 | 
					-- lua/plugins/tools.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function create_adapter(adapter_type, name, opts)
 | 
				
			||||||
 | 
					  return require("codecompanion.adapters").extend(adapter_type, {
 | 
				
			||||||
 | 
					    name = name,
 | 
				
			||||||
 | 
					    schema = opts.schema or {},
 | 
				
			||||||
 | 
					    env = opts.env or {},
 | 
				
			||||||
 | 
					    parameters = opts.parameters or {},
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					return {
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"olimorris/codecompanion.nvim",
 | 
							"olimorris/codecompanion.nvim",
 | 
				
			||||||
| 
						 | 
					@ -23,22 +32,19 @@ return {
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			adapters = {
 | 
								adapters = {
 | 
				
			||||||
				ollama = function()
 | 
									ollama = function()
 | 
				
			||||||
					return require("codecompanion.adapters").extend("ollama", {
 | 
										return create_adapter("ollama", "ollama", {
 | 
				
			||||||
						name = "ollama",
 | 
					 | 
				
			||||||
						env = { url = "http://192.168.1.165:11434" },
 | 
											env = { url = "http://192.168.1.165:11434" },
 | 
				
			||||||
						parameters = { sync = true },
 | 
											parameters = { sync = true },
 | 
				
			||||||
						schema = { num_ctx = { default = 8192 } },
 | 
											schema = { num_ctx = { default = 8192 } },
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
				gemini_pro = function()
 | 
									gemini_pro = function()
 | 
				
			||||||
					return require("codecompanion.adapters").extend("gemini", {
 | 
										return create_adapter("gemini", "gemini_pro", {
 | 
				
			||||||
						name = "gemini_pro",
 | 
					 | 
				
			||||||
						schema = { model = { default = "gemini-2.5-pro-preview-05-06" } },
 | 
											schema = { model = { default = "gemini-2.5-pro-preview-05-06" } },
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
				gemini_none = function()
 | 
									gemini_none = function()
 | 
				
			||||||
					return require("codecompanion.adapters").extend("gemini", {
 | 
										return create_adapter("gemini", "gemini_none", {
 | 
				
			||||||
						name = "gemini_none",
 | 
					 | 
				
			||||||
						schema = {
 | 
											schema = {
 | 
				
			||||||
							model = { default = "gemini-2.5-flash-preview-05-20" },
 | 
												model = { default = "gemini-2.5-flash-preview-05-20" },
 | 
				
			||||||
							reasoning_effort = { default = "none" },
 | 
												reasoning_effort = { default = "none" },
 | 
				
			||||||
| 
						 | 
					@ -47,8 +53,7 @@ return {
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
				gemini_high = function()
 | 
									gemini_high = function()
 | 
				
			||||||
					return require("codecompanion.adapters").extend("gemini", {
 | 
										return create_adapter("gemini", "gemini_high", {
 | 
				
			||||||
						name = "gemini_high",
 | 
					 | 
				
			||||||
						schema = {
 | 
											schema = {
 | 
				
			||||||
							model = { default = "gemini-2.5-flash-preview-05-20" },
 | 
												model = { default = "gemini-2.5-flash-preview-05-20" },
 | 
				
			||||||
							reasoning_effort = { default = "high" },
 | 
												reasoning_effort = { default = "high" },
 | 
				
			||||||
| 
						 | 
					@ -56,8 +61,7 @@ return {
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
				openai_high = function()
 | 
									openai_high = function()
 | 
				
			||||||
					return require("codecompanion.adapters").extend("openai", {
 | 
										return create_adapter("openai", "openai_high", {
 | 
				
			||||||
						name = "openai_high",
 | 
					 | 
				
			||||||
						schema = {
 | 
											schema = {
 | 
				
			||||||
							model = { default = "o4-mini-2025-04-16" },
 | 
												model = { default = "o4-mini-2025-04-16" },
 | 
				
			||||||
							reasoning_effort = { default = "high" },
 | 
												reasoning_effort = { default = "high" },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue