Update
This commit is contained in:
		
							parent
							
								
									1f78805dc5
								
							
						
					
					
						commit
						da73c6c333
					
				| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
return {
 | 
					return {
 | 
				
			||||||
  'yetone/avante.nvim',
 | 
					  'yetone/avante.nvim',
 | 
				
			||||||
  event = 'VeryLazy',
 | 
					  event = 'VeryLazy',
 | 
				
			||||||
  lazy = false,
 | 
					  lazy = true,
 | 
				
			||||||
  version = false, -- set this if you want to always pull the latest change
 | 
					  version = false, -- set this if you want to always pull the latest change
 | 
				
			||||||
  opts = {
 | 
					  opts = {
 | 
				
			||||||
    -- add any opts here
 | 
					    -- add any opts here
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,9 +3,13 @@ return {
 | 
				
			||||||
  dependencies = {
 | 
					  dependencies = {
 | 
				
			||||||
    'nvim-lua/plenary.nvim',
 | 
					    'nvim-lua/plenary.nvim',
 | 
				
			||||||
    'nvim-treesitter/nvim-treesitter',
 | 
					    'nvim-treesitter/nvim-treesitter',
 | 
				
			||||||
 | 
					    'j-hui/fidget.nvim',
 | 
				
			||||||
    -- The following are optional:
 | 
					    -- The following are optional:
 | 
				
			||||||
    { 'MeanderingProgrammer/render-markdown.nvim', ft = { 'markdown', 'codecompanion' } },
 | 
					    { 'MeanderingProgrammer/render-markdown.nvim', ft = { 'markdown', 'codecompanion' } },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  init = function()
 | 
				
			||||||
 | 
					    require('custom.plugins.codecompanion.fidget-spinner'):init()
 | 
				
			||||||
 | 
					  end,
 | 
				
			||||||
  config = function()
 | 
					  config = function()
 | 
				
			||||||
    require('codecompanion').setup {
 | 
					    require('codecompanion').setup {
 | 
				
			||||||
      adapters = {
 | 
					      adapters = {
 | 
				
			||||||
| 
						 | 
					@ -14,6 +18,11 @@ return {
 | 
				
			||||||
            api_key = 'CODECOMP_ANTHROPIC_API_KEY',
 | 
					            api_key = 'CODECOMP_ANTHROPIC_API_KEY',
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
        }),
 | 
					        }),
 | 
				
			||||||
 | 
					        deepseek = require('codecompanion.adapters').extend('deepseek', {
 | 
				
			||||||
 | 
					          env = {
 | 
				
			||||||
 | 
					            api_key = 'CODECOMP_DEEPSEEK_API_KEY',
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        }),
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      strategies = {
 | 
					      strategies = {
 | 
				
			||||||
        chat = {
 | 
					        chat = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,73 @@
 | 
				
			||||||
 | 
					-- lua/plugins/codecompanion/fidget-spinner.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local progress = require 'fidget.progress'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local M = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:init()
 | 
				
			||||||
 | 
					  local group = vim.api.nvim_create_augroup('CodeCompanionFidgetHooks', {})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  vim.api.nvim_create_autocmd({ 'User' }, {
 | 
				
			||||||
 | 
					    pattern = 'CodeCompanionRequestStarted',
 | 
				
			||||||
 | 
					    group = group,
 | 
				
			||||||
 | 
					    callback = function(request)
 | 
				
			||||||
 | 
					      local handle = M:create_progress_handle(request)
 | 
				
			||||||
 | 
					      M:store_progress_handle(request.data.id, handle)
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  vim.api.nvim_create_autocmd({ 'User' }, {
 | 
				
			||||||
 | 
					    pattern = 'CodeCompanionRequestFinished',
 | 
				
			||||||
 | 
					    group = group,
 | 
				
			||||||
 | 
					    callback = function(request)
 | 
				
			||||||
 | 
					      local handle = M:pop_progress_handle(request.data.id)
 | 
				
			||||||
 | 
					      if handle then
 | 
				
			||||||
 | 
					        M:report_exit_status(handle, request)
 | 
				
			||||||
 | 
					        handle:finish()
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					M.handles = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:store_progress_handle(id, handle)
 | 
				
			||||||
 | 
					  M.handles[id] = handle
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:pop_progress_handle(id)
 | 
				
			||||||
 | 
					  local handle = M.handles[id]
 | 
				
			||||||
 | 
					  M.handles[id] = nil
 | 
				
			||||||
 | 
					  return handle
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:create_progress_handle(request)
 | 
				
			||||||
 | 
					  return progress.handle.create {
 | 
				
			||||||
 | 
					    title = ' Requesting assistance (' .. request.data.strategy .. ')',
 | 
				
			||||||
 | 
					    message = 'In progress...',
 | 
				
			||||||
 | 
					    lsp_client = {
 | 
				
			||||||
 | 
					      name = M:llm_role_title(request.data.adapter),
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:llm_role_title(adapter)
 | 
				
			||||||
 | 
					  local parts = {}
 | 
				
			||||||
 | 
					  table.insert(parts, adapter.formatted_name)
 | 
				
			||||||
 | 
					  if adapter.model and adapter.model ~= '' then
 | 
				
			||||||
 | 
					    table.insert(parts, '(' .. adapter.model .. ')')
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					  return table.concat(parts, ' ')
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M:report_exit_status(handle, request)
 | 
				
			||||||
 | 
					  if request.data.status == 'success' then
 | 
				
			||||||
 | 
					    handle.message = 'Completed'
 | 
				
			||||||
 | 
					  elseif request.data.status == 'error' then
 | 
				
			||||||
 | 
					    handle.message = ' Error'
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    handle.message = ' Cancelled'
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return M
 | 
				
			||||||
		Loading…
	
		Reference in New Issue