Add cmp.config.disable for opt-out default setting
This commit is contained in:
@@ -84,6 +84,7 @@ lua <<EOF
|
|||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.close(),
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<C-y>'] = cmp.config.disable, -- If you want to remove the default `<C-y>` mapping, You can specify `cmp.config.disable` value.
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local source = require('cmp.source')
|
|||||||
local config = require('cmp.config')
|
local config = require('cmp.config')
|
||||||
local autocmd = require('cmp.utils.autocmd')
|
local autocmd = require('cmp.utils.autocmd')
|
||||||
local keymap = require('cmp.utils.keymap')
|
local keymap = require('cmp.utils.keymap')
|
||||||
|
local misc = require('cmp.utils.misc')
|
||||||
|
|
||||||
local cmp = {}
|
local cmp = {}
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ cmp.vim = require('cmp.types.vim')
|
|||||||
|
|
||||||
---Export default config presets.
|
---Export default config presets.
|
||||||
cmp.config = {}
|
cmp.config = {}
|
||||||
|
cmp.config.disable = misc.none
|
||||||
cmp.config.compare = require('cmp.config.compare')
|
cmp.config.compare = require('cmp.config.compare')
|
||||||
cmp.config.sources = require('cmp.config.sources')
|
cmp.config.sources = require('cmp.config.sources')
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ misc.concat = function(list1, list2)
|
|||||||
return new_list
|
return new_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---The symbol to remove key in misc.merge.
|
||||||
|
misc.none = vim.NIL
|
||||||
|
|
||||||
---Merge two tables recursively
|
---Merge two tables recursively
|
||||||
---@generic T
|
---@generic T
|
||||||
---@param v1 T
|
---@param v1 T
|
||||||
@@ -49,6 +52,9 @@ misc.merge = function(v1, v2)
|
|||||||
end
|
end
|
||||||
return new_tbl
|
return new_tbl
|
||||||
end
|
end
|
||||||
|
if v1 == misc.none then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
if v1 == nil then
|
if v1 == nil then
|
||||||
return v2
|
return v2
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ describe('misc', function()
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.are.equal(merged.a.b, 1)
|
assert.are.equal(merged.a.b, 1)
|
||||||
|
|
||||||
merged = misc.merge({
|
merged = misc.merge({
|
||||||
a = false,
|
a = false,
|
||||||
}, {
|
}, {
|
||||||
@@ -23,5 +24,14 @@ describe('misc', function()
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.are.equal(merged.a, false)
|
assert.are.equal(merged.a, false)
|
||||||
|
|
||||||
|
merged = misc.merge({
|
||||||
|
a = misc.none,
|
||||||
|
}, {
|
||||||
|
a = {
|
||||||
|
b = 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
assert.are.equal(merged.a, nil)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user