Refactor a bit
This commit is contained in:
@@ -5,7 +5,8 @@ local WIDE_HEIGHT = 40
|
|||||||
|
|
||||||
---@return cmp.ConfigSchema
|
---@return cmp.ConfigSchema
|
||||||
return function()
|
return function()
|
||||||
return {
|
---@type cmp.ConfigSchema
|
||||||
|
local config = {
|
||||||
enabled = function()
|
enabled = function()
|
||||||
local disabled = false
|
local disabled = false
|
||||||
disabled = disabled or (vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt')
|
disabled = disabled or (vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt')
|
||||||
@@ -17,7 +18,7 @@ return function()
|
|||||||
performance = {
|
performance = {
|
||||||
debounce = 60,
|
debounce = 60,
|
||||||
throttle = 30,
|
throttle = 30,
|
||||||
fetching_timeout = 200,
|
fetching_timeout = 500,
|
||||||
},
|
},
|
||||||
|
|
||||||
preselect = types.cmp.PreselectMode.Item,
|
preselect = types.cmp.PreselectMode.Item,
|
||||||
@@ -25,7 +26,7 @@ return function()
|
|||||||
mapping = {},
|
mapping = {},
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function()
|
expand = function(_)
|
||||||
error('snippet engine is not configured.')
|
error('snippet engine is not configured.')
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -105,4 +106,5 @@ return function()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
return config
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ core.confirm = function(self, e, option, callback)
|
|||||||
feedkeys.call(table.concat(keys, ''), 'in')
|
feedkeys.call(table.concat(keys, ''), 'in')
|
||||||
end)
|
end)
|
||||||
feedkeys.call('', 'n', function()
|
feedkeys.call('', 'n', function()
|
||||||
|
-- Restore the line at the time of request.
|
||||||
local ctx = context.new()
|
local ctx = context.new()
|
||||||
if api.is_cmdline_mode() then
|
if api.is_cmdline_mode() then
|
||||||
local keys = {}
|
local keys = {}
|
||||||
@@ -377,13 +378,12 @@ core.confirm = function(self, e, option, callback)
|
|||||||
feedkeys.call(table.concat(keys, ''), 'in')
|
feedkeys.call(table.concat(keys, ''), 'in')
|
||||||
else
|
else
|
||||||
vim.cmd([[silent! undojoin]])
|
vim.cmd([[silent! undojoin]])
|
||||||
vim.api.nvim_buf_set_text(0, ctx.cursor.row - 1, e:get_offset() - 1, ctx.cursor.row - 1, ctx.cursor.col - 1, {
|
vim.api.nvim_set_current_line(e.context.cursor_line)
|
||||||
string.sub(e.context.cursor_before_line, e:get_offset()),
|
|
||||||
})
|
|
||||||
vim.api.nvim_win_set_cursor(0, { e.context.cursor.row, e.context.cursor.col - 1 })
|
vim.api.nvim_win_set_cursor(0, { e.context.cursor.row, e.context.cursor.col - 1 })
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
feedkeys.call('', 'n', function()
|
feedkeys.call('', 'n', function()
|
||||||
|
-- Apply additionalTextEdits.
|
||||||
local ctx = context.new()
|
local ctx = context.new()
|
||||||
if #(misc.safe(e:get_completion_item().additionalTextEdits) or {}) == 0 then
|
if #(misc.safe(e:get_completion_item().additionalTextEdits) or {}) == 0 then
|
||||||
e:resolve(function()
|
e:resolve(function()
|
||||||
|
|||||||
Reference in New Issue
Block a user