This repository was archived by the owner on Feb 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathconfig.lua
206 lines (174 loc) · 5.11 KB
/
config.lua
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
local default_config = {
input = {
-- Set to false to disable the vim.ui.input implementation
enabled = true,
-- Default prompt string
default_prompt = "Input",
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Can be 'left', 'right', or 'center'
title_pos = "left",
-- The initial mode when the window opens (insert|normal|visual|select).
start_mode = "insert",
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "cursor",
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
prefer_width = 40,
width = nil,
-- min_width and max_width can be a list of mixed types.
-- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
max_width = { 140, 0.9 },
min_width = { 20, 0.2 },
buf_options = {},
win_options = {
-- Disable line wrapping
wrap = false,
-- Indicator for when text exceeds window
list = true,
listchars = "precedes:…,extends:…",
-- Increase this for more context when text scrolls off the window
sidescrolloff = 0,
},
-- Set to `false` to disable
mappings = {
n = {
["<Esc>"] = "Close",
["<CR>"] = "Confirm",
},
i = {
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
["<Up>"] = "HistoryPrev",
["<Down>"] = "HistoryNext",
},
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
-- see :help dressing_get_config
get_config = nil,
},
select = {
-- Set to false to disable the vim.ui.select implementation
enabled = true,
-- Priority list of preferred vim.select implementations
backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Options for telescope selector
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,
-- Options for fzf selector
fzf = {
window = {
width = 0.5,
height = 0.4,
},
},
-- Options for fzf-lua
fzf_lua = {
-- winopts = {
-- height = 0.5,
-- width = 0.5,
-- },
},
-- Options for nui Menu
nui = {
position = "50%",
size = nil,
relative = "editor",
border = {
style = "rounded",
},
buf_options = {
swapfile = false,
filetype = "DressingSelect",
},
win_options = {
winblend = 0,
},
max_width = 80,
max_height = 40,
min_width = 40,
min_height = 10,
},
-- Options for built-in selector
builtin = {
-- Display numbers for options and set up keymaps
show_numbers = true,
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "editor",
buf_options = {},
win_options = {
cursorline = true,
cursorlineopt = "both",
-- disable highlighting for the brackets around the numbers
winhighlight = "MatchParen:",
},
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- the min_ and max_ options can be a list of mixed types.
-- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total"
width = nil,
max_width = { 140, 0.8 },
min_width = { 40, 0.2 },
height = nil,
max_height = 0.9,
min_height = { 10, 0.2 },
-- Set to `false` to disable
mappings = {
["<Esc>"] = "Close",
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
},
-- Used to override format_item. See :help dressing-format
format_item_override = {},
-- see :help dressing_get_config
get_config = nil,
},
}
local M = vim.deepcopy(default_config)
-- Apply shims for backwards compatibility
---@param key string
---@param opts? table
---@return table?
M.apply_shim = function(key, opts)
-- Support start_in_insert for backwards compatibility.
if key == "input" and opts ~= nil and opts.start_in_insert ~= nil then
opts.start_mode = opts.start_in_insert and "insert" or "normal"
end
return opts
end
M.update = function(opts)
local newconf = vim.tbl_deep_extend("force", default_config, opts or {})
for k, v in pairs(newconf) do
M[k] = M.apply_shim(k, v)
end
end
-- Used to get the effective config value for a module.
-- Use like: config.get_mod_config('input')
M.get_mod_config = function(key, ...)
if not M[key].get_config then
return M[key]
end
local conf = M[key].get_config(...)
conf = M.apply_shim(key, conf)
if conf then
return vim.tbl_deep_extend("force", M[key], conf)
else
return M[key]
end
end
return M