forked from sourcegraph/sg.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.lua
More file actions
87 lines (70 loc) · 1.73 KB
/
Copy pathshared.lua
File metadata and controls
87 lines (70 loc) · 1.73 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
local shared = {}
shared.create = function(bufnr, win, popup_options)
if not vim.api.nvim_buf_is_valid(bufnr) then
bufnr = vim.api.nvim_create_buf(false, true)
end
if not vim.api.nvim_win_is_valid(win) then
win = vim.api.nvim_open_win(bufnr, false, popup_options)
end
vim.wo[win].wrap = true
vim.wo[win].winhighlight = "Normal:Normal,FloatBorder:Normal"
return bufnr, win
end
shared.buf_del = function(bufnr)
if vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_delete(bufnr, { force = true })
end
return -1
end
shared.win_del = function(win)
if vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_close(win, true)
end
return -1
end
shared.calculate_width = function(width)
if type(width) == "string" then
error "i'll do this later"
elseif width > 1 then
return width
else
return math.floor(width * vim.o.columns)
end
end
shared.calculate_height = function(height)
if type(height) == "string" then
error "i'll do this later"
elseif height > 1 then
return height
else
return math.floor(height * vim.o.lines)
end
end
shared.calculate_row = function(row)
return row
end
shared.calculate_col = function(col)
return col
end
shared.make_win_minimal = function(win)
local options = {
number = false,
relativenumber = false,
cursorline = false,
cursorcolumn = false,
list = false,
signcolumn = "auto",
wrap = true,
}
for key, value in pairs(options) do
vim.wo[win][key] = value
end
vim.wo[win].statuscolumn = nil
vim.opt_local.fillchars:append { eob = " " }
end
shared.make_buf_minimal = function(bufnr)
vim.bo[bufnr].buflisted = false
vim.bo[bufnr].modified = false
vim.bo[bufnr].buftype = "nofile"
end
return shared