Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions lua/popup/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,38 @@ function popup.create(what, vim_options)
}

local win_opts = {}
win_opts.relative = "editor"

local cursor_relative_pos = function(pos_str, dim)
assert(string.find(pos_str,'^cursor'), "Invalid value for " .. dim)
win_opts.relative = 'cursor'
local line = 0
if (pos_str):match "cursor%+(%d+)" then
line = line + tonumber((pos_str):match "cursor%+(%d+)")
elseif (pos_str):match "cursor%-(%d+)" then
line = line - tonumber((pos_str):match "cursor%-(%d+)")
end
return line
end

if vim_options.line then
-- TODO: Need to handle "cursor", "cursor+1", ...
win_opts.row = vim_options.line
if type(vim_options.line) == 'string' then
win_opts.row = cursor_relative_pos(vim_options.line, "row")
else
win_opts.row = vim_options.line
end
else
-- TODO: It says it needs to be "vertically cenetered"?...
-- wut is that.
win_opts.row = 0
end

if vim_options.col then
-- TODO: Need to handle "cursor", "cursor+1", ...
win_opts.col = vim_options.col
if type(vim_options.col) == 'string' then
win_opts.col = cursor_relative_pos(vim_options.col, "col")
else
win_opts.col = vim_options.col
end
else
-- TODO: It says it needs to be "horizontally cenetered"?...
win_opts.col = 0
Expand Down Expand Up @@ -157,8 +176,6 @@ function popup.create(what, vim_options)
-- textpropwin
-- textpropid

win_opts.relative = "editor"

local win_id
if vim_options.hidden then
assert(false, "I have not implemented this yet and don't know how")
Expand Down