Use avante instead of copilot chat
This commit is contained in:
		
							parent
							
								
									fcbf7c2873
								
							
						
					
					
						commit
						4a6324122a
					
				| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
return {
 | 
			
		||||
  'yetone/avante.nvim',
 | 
			
		||||
  event = 'VeryLazy',
 | 
			
		||||
  version = '*',
 | 
			
		||||
  opts = {
 | 
			
		||||
    provider = 'copilot',
 | 
			
		||||
    copilot = {
 | 
			
		||||
      endpoint = 'https://api.githubcopilot.com',
 | 
			
		||||
      model = 'gpt-4o-2024-08-06',
 | 
			
		||||
      proxy = nil,
 | 
			
		||||
      allow_insecure = false,
 | 
			
		||||
      timeout = 30000,
 | 
			
		||||
      temperature = 0,
 | 
			
		||||
      max_tokens = 4096,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  build = 'make',
 | 
			
		||||
  dependencies = {
 | 
			
		||||
    'nvim-treesitter/nvim-treesitter',
 | 
			
		||||
    'stevearc/dressing.nvim',
 | 
			
		||||
    'nvim-lua/plenary.nvim',
 | 
			
		||||
    'MunifTanjim/nui.nvim',
 | 
			
		||||
    {
 | 
			
		||||
      'HakonHarnes/img-clip.nvim',
 | 
			
		||||
      event = 'VeryLazy',
 | 
			
		||||
      opts = {
 | 
			
		||||
        default = {
 | 
			
		||||
          embed_image_as_base64 = false,
 | 
			
		||||
          prompt_for_file_name = false,
 | 
			
		||||
          drag_and_drop = {
 | 
			
		||||
            insert_mode = true,
 | 
			
		||||
          },
 | 
			
		||||
          use_absolute_path = true,
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      'MeanderingProgrammer/render-markdown.nvim',
 | 
			
		||||
      opts = {
 | 
			
		||||
        file_types = { 'markdown', 'Avante' },
 | 
			
		||||
      },
 | 
			
		||||
      ft = { 'markdown', 'Avante' },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,72 +1,10 @@
 | 
			
		|||
local on_attach = function(on_attach, name)
 | 
			
		||||
  return vim.api.nvim_create_autocmd('LspAttach', {
 | 
			
		||||
    callback = function(args)
 | 
			
		||||
      local buffer = args.buf ---@type number
 | 
			
		||||
      local client = vim.lsp.get_client_by_id(args.data.client_id)
 | 
			
		||||
      if client and (not name or client.name == name) then
 | 
			
		||||
        return on_attach(client, buffer)
 | 
			
		||||
      end
 | 
			
		||||
    end,
 | 
			
		||||
  })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  {
 | 
			
		||||
    'CopilotC-Nvim/CopilotChat.nvim',
 | 
			
		||||
    dependencies = {
 | 
			
		||||
      { 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim
 | 
			
		||||
      { 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper
 | 
			
		||||
    },
 | 
			
		||||
    build = 'make tiktoken', -- Only on MacOS or Linux
 | 
			
		||||
    opts = {
 | 
			
		||||
      debug = true, -- Enable debugging
 | 
			
		||||
      context = 'buffer',
 | 
			
		||||
    },
 | 
			
		||||
    keys = {
 | 
			
		||||
      {
 | 
			
		||||
        '<leader>aa',
 | 
			
		||||
        function()
 | 
			
		||||
          local chat = require 'CopilotChat'
 | 
			
		||||
          chat.toggle()
 | 
			
		||||
        end,
 | 
			
		||||
        desc = 'Copilot toggle chat',
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        '<leader>aq',
 | 
			
		||||
        function()
 | 
			
		||||
          local input = vim.fn.input 'Quick Chat: '
 | 
			
		||||
          if input ~= '' then
 | 
			
		||||
            require('CopilotChat').ask(input, { selection = require('CopilotChat.select').buffer })
 | 
			
		||||
          end
 | 
			
		||||
        end,
 | 
			
		||||
        desc = 'Copilot quick chat',
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        '<leader>ax',
 | 
			
		||||
        function()
 | 
			
		||||
          local chat = require 'CopilotChat'
 | 
			
		||||
          chat.reset()
 | 
			
		||||
        end,
 | 
			
		||||
        desc = 'Copilot chat reset',
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        '<leader>ap',
 | 
			
		||||
        function()
 | 
			
		||||
          local actions = require 'CopilotChat.actions'
 | 
			
		||||
          require('CopilotChat.integrations.telescope').pick(actions.prompt_actions())
 | 
			
		||||
        end,
 | 
			
		||||
        desc = 'Copilot chat prompt actions',
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    'zbirenbaum/copilot.lua',
 | 
			
		||||
    cmd = 'Copilot',
 | 
			
		||||
    event = 'InsertEnter',
 | 
			
		||||
    build = ':Copilot auth',
 | 
			
		||||
    opts = {
 | 
			
		||||
      -- suggestion = { enabled = false },
 | 
			
		||||
      -- panel = { enabled = false },
 | 
			
		||||
      filetypes = {
 | 
			
		||||
        markdown = true,
 | 
			
		||||
        help = true,
 | 
			
		||||
| 
						 | 
				
			
			@ -80,9 +18,14 @@ return {
 | 
			
		|||
    config = function(_, opts)
 | 
			
		||||
      local copilot_cmp = require 'copilot_cmp'
 | 
			
		||||
      copilot_cmp.setup(opts)
 | 
			
		||||
      on_attach(function(client)
 | 
			
		||||
        copilot_cmp._on_insert_enter {}
 | 
			
		||||
      end, 'copilot')
 | 
			
		||||
      vim.api.nvim_create_autocmd('LspAttach', {
 | 
			
		||||
        callback = function(args)
 | 
			
		||||
          local client = vim.lsp.get_client_by_id(args.data.client_id)
 | 
			
		||||
          if client and client.name == 'copilot' then
 | 
			
		||||
            copilot_cmp._on_insert_enter {}
 | 
			
		||||
          end
 | 
			
		||||
        end,
 | 
			
		||||
      })
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue