This commit is contained in:
hrsh7th
2021-10-18 11:47:17 +09:00
parent 4ecf2a2426
commit 1e913aefd9
2 changed files with 11 additions and 6 deletions

View File

@@ -120,7 +120,7 @@ window.update = function(self)
else else
style1.noautocmd = true style1.noautocmd = true
self.swin1 = vim.api.nvim_open_win(buffer.ensure(self.name .. 'sbuf1'), false, style1) self.swin1 = vim.api.nvim_open_win(buffer.ensure(self.name .. 'sbuf1'), false, style1)
vim.api.nvim_win_set_option(self.swin1, 'winhighlight', 'Normal:PmenuSbar,NormalNC:PmenuSbar,NormalFloat:PmenuSbar') vim.api.nvim_win_set_option(self.swin1, 'winhighlight', 'EndOfBuffer:PmenuSbar,Normal:PmenuSbar,NormalNC:PmenuSbar,NormalFloat:PmenuSbar')
end end
local style2 = {} local style2 = {}
style2.relative = 'editor' style2.relative = 'editor'
@@ -135,7 +135,7 @@ window.update = function(self)
else else
style2.noautocmd = true style2.noautocmd = true
self.swin2 = vim.api.nvim_open_win(buffer.ensure(self.name .. 'sbuf2'), false, style2) self.swin2 = vim.api.nvim_open_win(buffer.ensure(self.name .. 'sbuf2'), false, style2)
vim.api.nvim_win_set_option(self.swin2, 'winhighlight', 'Normal:PmenuThumb,NormalNC:PmenuThumb,NormalFloat:PmenuThumb') vim.api.nvim_win_set_option(self.swin2, 'winhighlight', 'EndOfBuffer:PmenuThumb,Normal:PmenuThumb,NormalNC:PmenuThumb,NormalFloat:PmenuThumb')
end end
else else
if self.swin1 and vim.api.nvim_win_is_valid(self.swin1) then if self.swin1 and vim.api.nvim_win_is_valid(self.swin1) then

View File

@@ -129,7 +129,6 @@ custom_entries_view.open = function(self, offset, entries)
width = width + self.column_width.kind + (self.column_width.menu > 0 and 1 or 0) width = width + self.column_width.kind + (self.column_width.menu > 0 and 1 or 0)
width = width + self.column_width.menu + 1 width = width + self.column_width.menu + 1
local cursor = api.get_cursor()
local pos = api.get_screen_cursor() local pos = api.get_screen_cursor()
local height = vim.api.nvim_get_option('pumheight') local height = vim.api.nvim_get_option('pumheight')
height = height == 0 and #self.entries or height height = height == 0 and #self.entries or height
@@ -145,18 +144,24 @@ custom_entries_view.open = function(self, offset, entries)
return return
end end
local cursor = api.get_cursor()
local delta = cursor[2] + 1 - self.offset local delta = cursor[2] + 1 - self.offset
local row, col = pos[1], pos[2] - delta - 1
if row < 0 or vim.o.lines <= row or col < 0 or vim.o.columns <= col then
return
end
self.entries_win:open({ self.entries_win:open({
relative = 'editor', relative = 'editor',
style = 'minimal', style = 'minimal',
row = pos[1], row = row,
col = pos[2] - delta - 1, col = col,
width = width, width = width,
height = height, height = height,
zindex = 1001, zindex = 1001,
}) })
self.entries_win:option('cursorline', false)
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 }) vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 })
self.entries_win:option('cursorline', false)
if preselect > 0 and config.get().preselect == types.cmp.PreselectMode.Item then if preselect > 0 and config.get().preselect == types.cmp.PreselectMode.Item then
self:preselect(preselect) self:preselect(preselect)