Files
nvim-cmp/lua/cmp/config/mapping.lua
Alex Tylor b546f50f09 Expose get_selected_entry() from view module to main cmp module fixes #385 (#386)
* Expose get_selected_entry() from view module to main cmp module fixes #385

* add get_active_entry() also

* fix linting

* remove unused vars

Co-authored-by: alex.tylor <atylor@gmail.com>
2021-10-22 17:47:55 +09:00

80 lines
1.5 KiB
Lua

local mapping
mapping = setmetatable({}, {
__call = function(_, invoke, modes)
if type(invoke) == 'function' then
return {
invoke = function(...)
invoke(...)
end,
modes = modes or { 'i' },
}
end
return invoke
end,
})
---Invoke completion
mapping.complete = function()
return function(fallback)
if not require('cmp').complete() then
fallback()
end
end
end
---Close current completion menu if it displayed.
mapping.close = function()
return function(fallback)
if not require('cmp').close() then
fallback()
end
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)
if not require('cmp').scroll_docs(delta) then
fallback()
end
end
end
---Select next completion item.
mapping.select_next_item = function(option)
return function(fallback)
if not require('cmp').select_next_item(option) then
fallback()
end
end
end
---Select prev completion item.
mapping.select_prev_item = function(option)
return function(fallback)
if not require('cmp').select_prev_item(option) then
fallback()
end
end
end
---Confirm selection
mapping.confirm = function(option)
return function(fallback)
if not require('cmp').confirm(option) then
fallback()
end
end
end
return mapping