forked from vimichael/floatingtodo.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.lua
More file actions
57 lines (45 loc) · 1.18 KB
/
Copy pathwindow.lua
File metadata and controls
57 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local M = {}
function M.Calculate_position(position)
local posx, posy = 0.5, 0.5
-- Custom position
if type(position) == "table" then
posx, posy = position[1], position[2]
end
-- Keyword position
if position == "center" then
posx, posy = 0.5, 0.5
elseif position == "top-left" then
posx, posy = 0, 0
elseif position == "top-center" then
posx, posy = 0.5, 0
elseif position == "top-right" then
posx, posy = 1, 0
elseif position == "center-left" then
posx, posy = 0, 0.5
elseif position == "center-right" then
posx, posy = 1, 0.5
elseif position == "bottom-left" then
posx, posy = 0, 1
elseif position == "bottom-center" then
posx, posy = 0.5, 1
elseif position == "bottom-right" then
posx, posy = 1, 1
end
return posx, posy
end
function M.Win_config(w, h, pos, border)
local width = math.min(math.floor(vim.o.columns * w), 64)
local height = math.floor(vim.o.lines * h)
local posx, posy = M.Calculate_position(pos)
local col = math.floor((vim.o.columns - width) * posx)
local row = math.floor((vim.o.lines - height) * posy)
return {
relative = "editor",
width = width,
height = height,
col = col,
row = row,
border = border,
}
end
return M