Add cmp.mapping.abort
This commit is contained in:
@@ -48,6 +48,18 @@ cmp.close = function()
|
||||
end
|
||||
end
|
||||
|
||||
---Abort current completion
|
||||
cmp.abort = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
keymap.feedkeys(keymap.t('<C-e>'), 'n', function()
|
||||
core.reset()
|
||||
end)
|
||||
return true;
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
---Select next item if possible
|
||||
cmp.select_next_item = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
|
||||
@@ -28,6 +28,15 @@ mapping.close = function()
|
||||
end
|
||||
end
|
||||
|
||||
---Abort current completion menu if it displayed.
|
||||
mapping.abort = function()
|
||||
return function(fallback)
|
||||
if not require('cmp').abort() then
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Scroll documentation window.
|
||||
mapping.scroll_docs = function(delta)
|
||||
return function(fallback)
|
||||
|
||||
Reference in New Issue
Block a user