-
Notifications
You must be signed in to change notification settings - Fork 398
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
Feature Request: complete on close #2003
Comments
I've hacked some user-space proof of concept, but if you be so kind to add a proper solution to the plugin, it would be great (for some reason, that solution is horribly sloving down the editor. If less bindings are made, then perf is better. Maybe some O(n^2) algorithm going on?) local mappings = { ... };
local try_confirm_with_fallback = function(char)
return function(fallback)
if cmp.visible() and cmp.get_selected_entry() ~= nil then
cmp.confirm()
vim.defer_fn(function()
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
local line = vim.api.nvim_get_current_line()
local new_line = line:sub(1, col) .. char .. line:sub(col + 1)
vim.api.nvim_set_current_line(new_line)
vim.api.nvim_win_set_cursor(0, { row, col + 1 })
end, 0)
end
fallback()
end
end
-- All printable ascii chars
for i = 32, 126 do
mapping[string.char(i)] = try_confirm_with_fallback(string.char(i))
end
cmp.setup { ..., mappings = mappings, ... } |
My guess is that for key, mapping in pairs(config.get().mapping) do
if keymap.equals(key, keys) and mapping[mode] then
return mapping[mode](fallback)
end
end Or implement the feature as a whole inside the plugin, closing this issue directly |
You can try |
Hello, thank you for great plugin!
It would be great if you could've call
cmp.confirm()
when users just continues to type. In conjunction topreselect = types.cmp.PreselectMode.None
user would be able to configure workflow like this:n
times, to find a completion user wan'ts<CR>
that will do something like that:just continue typing, and equivalent to would occur (but writing itself would not be interrupted).
Right now, if you have
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
then that workflow would live you with text that was suggested and it is enough for most use cases, but it would do things like auto imports or other useful code actions. Hitting<CR>
is not a big price to pay, but maybe plugin can support that feature? Or maybe it already does?Thank you in advance.
The text was updated successfully, but these errors were encountered: