This commit is contained in:
hrsh7th
2021-10-16 22:09:01 +09:00
parent ebe040b1a9
commit f0a6cca5b9
4 changed files with 14 additions and 9 deletions

View File

@@ -87,8 +87,11 @@ custom_entries_view.ready = function()
return vim.fn.pumvisible() == 0
end
custom_entries_view.redraw = function()
-- noop
custom_entries_view.on_change = function(self)
if self:visible() and self:get_active_entry() then
self.entries_win:option('cursorline', false)
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 })
end
end
custom_entries_view.open = function(self, offset, entries)
@@ -143,7 +146,6 @@ custom_entries_view.open = function(self, offset, entries)
end
local delta = cursor[2] + 1 - self.offset
self.entries_win:option('cursorline', false)
self.entries_win:open({
relative = 'editor',
style = 'minimal',
@@ -153,6 +155,7 @@ custom_entries_view.open = function(self, offset, entries)
height = height,
zindex = 1001,
})
self.entries_win:option('cursorline', false)
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 })
if preselect > 0 and config.get().preselect == types.cmp.PreselectMode.Item then

View File

@@ -33,7 +33,7 @@ native_entries_view.ready = function(_)
return vim.fn.complete_info({ 'mode' }).mode == 'eval'
end
native_entries_view.redraw = function(self)
native_entries_view.on_change = function(self)
if #self.entries > 0 and self.offset <= vim.api.nvim_win_get_cursor(0)[2] + 1 then
local completeopt = vim.o.completeopt
vim.o.completeopt = self.preselect_index == 1 and 'menu,menuone,noinsert' or config.get().completion.completeopt