This commit is contained in:
hrsh7th
2021-10-28 16:48:02 +09:00
parent 1c498a5497
commit c01de2bd19

View File

@@ -101,29 +101,33 @@ return function()
}), }),
['<Tab>'] = mapping({ ['<Tab>'] = mapping({
c = function(fallback) c = function(fallback)
local c = require('cmp.config')
local cmp = require('cmp') local cmp = require('cmp')
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif not c.get().experimental.native_menu then else
local sources = cmp.core:get_sources()
if #sources > 0 and not require('cmp.config').get().experimental.native_menu then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end end
end
}), }),
['<S-Tab>'] = mapping({ ['<S-Tab>'] = mapping({
c = function(fallback) c = function(fallback)
local c = require('cmp.config')
local cmp = require('cmp') local cmp = require('cmp')
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif not c.get().experimental.native_menu then else
local sources = cmp.core:get_sources()
if #sources > 0 and not require('cmp.config').get().experimental.native_menu then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end end
end
}), }),
['<C-n>'] = mapping(mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Insert }), { 'i', 'c' }), ['<C-n>'] = mapping(mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Insert }), { 'i', 'c' }),
['<C-p>'] = mapping(mapping.select_prev_item({ behavior = types.cmp.SelectBehavior.Insert }), { 'i', 'c' }), ['<C-p>'] = mapping(mapping.select_prev_item({ behavior = types.cmp.SelectBehavior.Insert }), { 'i', 'c' }),