yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
6.97k stars 253 forks source link

question: Cannot map edit functionality to enter directly in insert mode #573

Open oxysoft opened 2 months ago

oxysoft commented 2 months ago

Describe the bug

Edit mode exits automatically after a few seconds and it appears that the request goes through even though I didn't press c-s. Seems to have nothing to do with the startinsert command, simply AvanteEdit will do it, but this is my use case.

To reproduce

vim.keymap.set("v", "C", function()
  vim.cmd('AvanteEdit')
  vim.cmd('startinsert')
end, { noremap = true })

Expected behavior

No response

Environment

nvim -v
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1720049189
Run "nvim -V1 -v" for more info

Repro

No response

aarnphm commented 1 month ago

This is more of an usage, not a bug.

Try this

vim.keymap.set("v", "C", function()
  require("avante.api").edit()
  vim.cmd('startinsert')
end, { noremap = true })