setup.cmdline: support using a table (#1193)

This commit is contained in:
Amar Al-Zubaidi
2022-09-25 22:51:01 -04:00
committed by GitHub
parent 4dd7ab6c26
commit 83c097699d
2 changed files with 12 additions and 12 deletions

View File

@@ -103,14 +103,12 @@ lua <<EOF
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
for _,v in pairs({ '/', '?' }) do
cmp.setup.cmdline(v, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
end
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {

View File

@@ -57,10 +57,12 @@ end
---Set configuration for cmdline
---@param c cmp.ConfigSchema
---@param cmdtype string
config.set_cmdline = function(c, cmdtype)
local revision = (config.cmdline[cmdtype] or {}).revision or 1
config.cmdline[cmdtype] = c or {}
config.cmdline[cmdtype].revision = revision + 1
config.set_cmdline = function(c, cmdtypes)
for _, cmdtype in ipairs(type(cmdtypes) == 'table' and cmdtypes or { cmdtypes }) do
local revision = (config.cmdline[cmdtype] or {}).revision or 1
config.cmdline[cmdtype] = c or {}
config.cmdline[cmdtype].revision = revision + 1
end
end
---Set configuration as oneshot completion.