Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否存在能够取消补全的lua接口,或者类似的方式能够取消补全 #89

Closed
Kaiser-Yang opened this issue Jun 25, 2024 · 9 comments

Comments

@Kaiser-Yang
Copy link
Contributor

由于个人习惯原因,我使用回车键作为补全的接受按键,因此当我需要输入回车而当前存在补全的时候,我输入回车会接受所有的补全,而我想知道能否有取消本次补全的接口(例如copilot中的copilot#Dismiss()),这样我可以绑定<C-C>来取消本次补全进而可以通过<CR>来换行。

@luozhiya
Copy link
Owner

@Kaiser-Yang

目前没有直接的API,绕一点的话可以通过 require('fittencode.engines.inline').reset() 实现类似的功能

@Kaiser-Yang
Copy link
Contributor Author

OK,谢谢回复,我试试

@Kaiser-Yang
Copy link
Contributor Author

但是这个有问题,reset之后他会马上加载出来。

@Kaiser-Yang
Copy link
Contributor Author

@luozhiya
我看主页写了可以集成到coc里面, 如果能够集成到coc里面的话,就可以通过coc的接口来取消:
image

但是source mode部分只给了cmp的配置,请问我使用coc的话应该如何配置?
image

@luozhiya
Copy link
Owner

@Kaiser-Yang

coc 处于 WIP 状态,目前还没有提供,您可以看下 #55 有列出计划事项

@Kaiser-Yang
Copy link
Contributor Author

好的。

@Kaiser-Yang
Copy link
Contributor Author

我找一个巧妙的方法可以实现我的需求,当存在fitencode补全的时候,通过<C-c>清楚当前补全并关闭所有补全,而在需要的时候通过<C-Space>即可再次触发补全:

vim.cmd[[
inoremap <silent><expr> <C-c>
      \ coc#pum#visible() ? coc#pum#cancel() :
      \ luaeval('require("fittencode").has_suggestions()') ? '<cmd>lua require("fittencode.engines.inline").reset()<cr><cmd>Fitten disable_completions<cr>' : "\<C-c>"
inoremap <silent><expr> <c-space> luaeval('require("fittencode").has_suggestions()') ? "\<c-space>" : '<cmd>Fitten enable_completions<cr>'
]]

@luozhiya
Copy link
Owner

@Kaiser-Yang

#94 新加了API dismiss_suggestions

@Kaiser-Yang
Copy link
Contributor Author

感谢,辛苦了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants