RFC: cmdline completion (#362)
* manual support dot-repeat * cmdwin and terminal * cmdline only * Fix * fix * Improve * Fix test * Support macro * disable cmdline for now * Simplify * fmt * consume once * Ignore = type * cmdline * fmt * Improve * update * fmt * Support incsearch * fix * Add api * Avoid cmdline completion if the native_menu enabled * fix for macro * Improve * fmt * Insert-mode only by default * Update * avoid conflict * Improve default mapping * Fix * fix * similar to native * Update * Fix README.md * Improve * Use <afile>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
local api = require('cmp.utils.api')
|
||||
|
||||
local mapping
|
||||
mapping = setmetatable({}, {
|
||||
__call = function(_, invoke, modes)
|
||||
@@ -7,9 +9,25 @@ mapping = setmetatable({}, {
|
||||
invoke(...)
|
||||
end,
|
||||
modes = modes or { 'i' },
|
||||
__type = 'mapping',
|
||||
}
|
||||
elseif type(invoke) == 'table' then
|
||||
if invoke.__type == 'mapping' then
|
||||
return invoke
|
||||
else
|
||||
return mapping(function(fallback)
|
||||
if api.is_insert_mode() and invoke.i then
|
||||
return invoke.i(fallback)
|
||||
elseif api.is_cmdline_mode() and invoke.c then
|
||||
return invoke.c(fallback)
|
||||
elseif api.is_select_mode() and invoke.s then
|
||||
return invoke.s(fallback)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, vim.tbl_keys(invoke))
|
||||
end
|
||||
end
|
||||
return invoke
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -53,7 +71,9 @@ end
|
||||
mapping.select_next_item = function(option)
|
||||
return function(fallback)
|
||||
if not require('cmp').select_next_item(option) then
|
||||
local release = require('cmp').core:suspend()
|
||||
fallback()
|
||||
vim.schedule(release)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -62,7 +82,9 @@ end
|
||||
mapping.select_prev_item = function(option)
|
||||
return function(fallback)
|
||||
if not require('cmp').select_prev_item(option) then
|
||||
local release = require('cmp').core:suspend()
|
||||
fallback()
|
||||
vim.schedule(release)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user