Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 3.93 KB

MIGRATION.md

File metadata and controls

95 lines (70 loc) · 3.93 KB

Migration guide after Copilot Chat rewrite to Lua

Prerequisites

Ensure you have the following plugins installed:

You will also need curl. Neovim should ship with copy of curl by default so most likely you are fine.

After getting copilot.vim or copilot.lua make sure to run :Copilot setup or :Copilot auth to retrieve your token if its not cached already. Also make sure to run :UpdateRemotePlugins to cleanup the old python commands.

Configuration changes

Removed or changed params that you pass to setup:

  • disable_extra_info was removed. Now you can use keybinding to show current selection in chat on demand.
  • hide_system_prompt was removed. Now you can use keybinding to show current system prompt in chat on demand.
  • language was removed and is now part of selection as selection.filetype

Command changes

  • CopilotChatBuffer was removed (now exists as select.buffer selector for selection)
  • CopilotChatInPlace was removed (parts of it were merged to default chat interface, and floating window now exists as float config for window.layout)
  • CopilotChat now functions as CopilotChatVisual, the unnamed register selection now exists as select.unnamed selector
  • CopilotChatVsplitToggle was renamed to CopilotChatToggle

API changes

  • CopilotChat.code_actions.show_help_actions was reworked. Now you can use:
local actions = require("CopilotChat.actions")
require("CopilotChat.integrations.telescope").pick(actions.help_actions())
  • CopilotChat.code_actions.show_prompt_actions was reworked. Now you can use:
local actions = require("CopilotChat.actions")
local select = require("CopilotChat.select")
require("CopilotChat.integrations.telescope").pick(actions.prompt_actions({
    selection = select.visual,
}))

How to restore legacy behaviour

local chat = require('CopilotChat')
local select = require('CopilotChat.select')

chat.setup {
    -- Restore the behaviour for CopilotChat to use unnamed register by default
    selection = select.unnamed,
    -- Restore the format with ## headers as prefixes,
    question_header = '## User ',
    answer_header = '## Copilot ',
    error_header = '## Error ',
}

-- Restore CopilotChatVisual
vim.api.nvim_create_user_command('CopilotChatVisual', function(args)
    chat.ask(args.args, { selection = select.visual })
end, { nargs = '*', range = true })

-- Restore CopilotChatInPlace (sort of)
vim.api.nvim_create_user_command('CopilotChatInPlace', function(args)
    chat.ask(args.args, { selection = select.visual, window = { layout = 'float' } })
end, { nargs = '*', range = true })

-- Restore CopilotChatBuffer
vim.api.nvim_create_user_command('CopilotChatBuffer', function(args)
    chat.ask(args.args, { selection = select.buffer })
end, { nargs = '*', range = true })

-- Restore CopilotChatVsplitToggle
vim.api.nvim_create_user_command('CopilotChatVsplitToggle', chat.toggle, {})

For further reference, you can view @jellydn's configuration.

TODO

  • For proxy support, this is needed: nvim-lua/plenary.nvim#559
  • Delete rest of the python code? Or finish rewriting in place then delete - All InPlace features are done, per poll on discord delete the python code
  • Check for curl availability with health check
  • Add folds logic from python, maybe? Not sure if this is even needed
  • Finish rewriting the authentication request if needed or just keep relying on copilot.vim/lua - Relies on copilot.vim/lua
  • Properly get token file path, atm it only supports Linux (easy fix)
  • Update README and stuff
  • Add token count from tiktoken support to extra_info
  • Add test and fix failed test in CI