luozhiya / fittencode.nvim

Fitten Code AI Programming Assistant for Neovim
49 stars 8 forks source link

Fix not having range when calling command by using lua api #57

Closed hoofcushion closed 1 month ago

hoofcushion commented 1 month ago

I also formatted this file, if you don't like, you can roll back.

hoofcushion commented 1 month ago
vim.keymap.set({"n","x"},"<leader>ae",require("fittencode.api").api.explain_code,{})

Problem: 如此设置一个映射,在 visual mode 下触发,无法获取 range 参数,必须使用 ":Fitten explain_code<cr>" 才能获取 Solution: 在 action 检测到目前处于 visual mode,先回到 normal mode,然后 nvim_buf_get_mark 获取 range ( '<, '> 要在退出 visual mode 后才会更新), 否则直接从 '<, '> 获取 range.

luozhiya commented 1 month ago

Hi @hoofcushion

Please rebase the code and keep only the main parts that have been changed

hoofcushion commented 1 month ago

@luozhiya Done. But doc/tags This file is changed, and I have no idea how to recovery it. Would you help to see it? I enabled Allow edits and access to secrets by maintainers

luozhiya commented 1 month ago
vim.keymap.set({"n","x"},"<leader>ae",require("fittencode.api").api.explain_code,{})

Problem: 如此设置一个映射,在 visual mode 下触发,无法获取 range 参数,必须使用 ":Fitten explain_code<cr>" 才能获取 Solution: 在 action 检测到目前处于 visual mode,先回到 normal mode,然后 nvim_buf_get_mark 获取 range ( '<, '> 要在退出 visual mode 后才会更新), 否则直接从 '<, '> 获取 range.

@hoofcushion

API 调用可以简化一下,可以直接在 fittencode 这个模块下访问

require("fittencode").explain_code
luozhiya commented 1 month ago

@luozhiya Done. But doc/tags This file is changed, and I have no idea how to recovery it. Would you help to see it? I enabled Allow edits and access to secrets by maintainers

GitHub 上操作好像不太方便,麻烦本地使用一下如下 git 语句

git rm --cache doc/tags
git commit --amend --no-edit
git push --force
hoofcushion commented 1 month ago

好了

luozhiya commented 1 month ago

@hoofcushion 谢谢