Add preselect configuration option

This commit is contained in:
hrsh7th
2021-08-25 21:23:54 +09:00
parent 5df8233081
commit 6bc0ddb58b
6 changed files with 22 additions and 7 deletions

View File

@@ -21,6 +21,8 @@ return function()
end,
},
preselect = types.cmp.PreselectMode.Item,
documentation = {
border = { '', '', '', ' ', '', '', '', ' ' },
winhighlight = 'NormalFloat:CmpDocumentation,FloatBorder:CmpDocumentationBorder',

View File

@@ -54,7 +54,7 @@ cmp.abort = function()
keymap.feedkeys(keymap.t('<C-e>'), 'n', function()
core.reset()
end)
return true;
return true
else
return false
end

View File

@@ -1,4 +1,5 @@
local debug = require('cmp.utils.debug')
local types = require('cmp.types')
local async = require('cmp.utils.async')
local float = require('cmp.float')
local config = require('cmp.config')
@@ -116,7 +117,7 @@ menu.update = check.wrap(function(self, ctx, sources)
local abbrs = {}
local preselect = 0
for i, e in ipairs(entries) do
if preselect == 0 and e.completion_item.preselect then
if preselect == 0 and e.completion_item.preselect and config.get().preselect ~= types.cmp.PreselectMode.None then
preselect = i
end

View File

@@ -17,10 +17,10 @@ cmp.TriggerEvent = {}
cmp.TriggerEvent.InsertEnter = 'InsertEnter'
cmp.TriggerEvent.TextChanged = 'TextChanged'
---@alias cmp.ScrollDirection "'up'" | "'down'"
cmp.ScrollDirection = {}
cmp.ScrollDirection.Up = 'up'
cmp.ScrollDirection.Down = 'down'
---@alias cmp.PreselectMode "'item'" | "'None'"
cmp.PreselectMode = {}
cmp.PreselectMode.Item = 'item'
cmp.PreselectMode.None = 'none'
---@class cmp.ContextOption
---@field public reason cmp.ContextReason|nil
@@ -47,6 +47,7 @@ cmp.ScrollDirection.Down = 'down'
---@class cmp.ConfigSchema
---@field private revision number
---@field public preselect cmp.PreselectMode
---@field public completion cmp.CompletionConfig
---@field public documentation cmp.DocumentationConfig
---@field public confirmation cmp.ConfirmationConfig