-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.lua
More file actions
90 lines (85 loc) · 2.13 KB
/
Copy pathconfig.lua
File metadata and controls
90 lines (85 loc) · 2.13 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
88
89
90
local M = {
jdtls_name = "jdtls",
options = {
show_guides = true,
auto_close = false,
width = "30%",
show_numbers = false,
show_relative_numbers = false,
preview_bg_highlight = "Pmenu",
winblend = 0,
fold_markers = { "", "" },
position = "right",
wrap = false,
hierarchical_view = true,
keymaps = {
close = "q",
toggle_fold = "o",
},
symbols = {
icons = {
NodeKind = {},
TypeKind = {},
EntryKind = {},
},
highlights = {
default_icon = "Type",
NodeKind = {},
TypeKind = {},
EntryKind = {},
},
},
highlights = {
LineGuide = { link = "Comment" },
},
},
}
M.setup = function(config)
if config then
local normalized = vim.deepcopy(config)
local option_keys = vim.tbl_keys(M.options)
for _, key in ipairs(option_keys) do
if normalized[key] ~= nil then
normalized.options = normalized.options or {}
if type(normalized[key]) == "table" then
normalized.options[key] = vim.tbl_deep_extend("force", normalized.options[key] or {}, normalized[key])
else
normalized.options[key] = normalized[key]
end
normalized[key] = nil
end
end
local new_config = vim.tbl_deep_extend("force", M, normalized)
for key, value in pairs(new_config) do
M[key] = value
end
end
end
function M.has_numbers()
return M.options.show_numbers or M.options.show_relative_numbers
end
function M.show_help()
print("Current keymaps:")
print(vim.inspect(M.options.keymaps))
end
function M.get_split_command()
if M.options.position == "left" then
return "topleft vs"
else
return "botright vs"
end
end
function M.get_window_width()
local width = M.options.width
if type(width) == "string" then
local percent = tonumber(width:match("^%s*(%d+)%%%s*$"))
if percent ~= nil then
return math.max(1, math.floor(vim.o.columns * percent / 100))
end
end
if type(width) == "number" then
return math.max(1, math.floor(width))
end
return math.max(1, math.floor(vim.o.columns * 0.3))
end
return M