-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
local require = require("noice.util.lazy") | ||
|
||
local Util = require("noice.util") | ||
local Config = require("noice.config") | ||
|
||
---@class NoicePreset: NoiceConfig | ||
---@field enabled? boolean | ||
|
||
local M = {} | ||
|
||
function M.setup() | ||
for name, preset in pairs(Config.options.presets) do | ||
if preset ~= false then | ||
M.load(name, preset) | ||
end | ||
end | ||
end | ||
|
||
---@param name string | ||
---@param preset NoiceConfig|boolean | ||
function M.load(name, preset) | ||
if preset == true and not M.presets[name] then | ||
return Util.panic("Unknown preset " .. name) | ||
end | ||
|
||
preset = vim.tbl_deep_extend("force", {}, M.presets[name], type(preset) == "table" and preset or {}) | ||
---@cast preset NoicePreset | ||
|
||
if preset.enabled == false then | ||
return | ||
end | ||
|
||
local routes = preset.routes | ||
preset.routes = nil | ||
Config.options = vim.tbl_deep_extend("force", Config.options, preset) | ||
if routes then | ||
vim.list_extend(Config.options.routes, routes) | ||
end | ||
end | ||
|
||
---@class NoicePresets: table<string, NoicePreset|boolean> | ||
M.presets = { | ||
bottom_search = { | ||
cmdline = { | ||
format = { | ||
search_down = { | ||
view = "cmdline", | ||
}, | ||
search_up = { | ||
view = "cmdline", | ||
}, | ||
}, | ||
}, | ||
}, | ||
command_palette = { | ||
views = { | ||
cmdline_popup = { | ||
position = { | ||
row = 3, | ||
col = "50%", | ||
}, | ||
size = { | ||
min_width = 60, | ||
width = "auto", | ||
height = "auto", | ||
}, | ||
}, | ||
popupmenu = { | ||
relative = "editor", | ||
position = { | ||
row = 6, | ||
col = "50%", | ||
}, | ||
size = { | ||
width = 60, | ||
height = "auto", | ||
max_height = 15, | ||
}, | ||
border = { | ||
style = "rounded", | ||
padding = { 0, 1 }, | ||
}, | ||
win_options = { | ||
winhighlight = { Normal = "Normal", FloatBorder = "NoiceCmdlinePopupBorder" }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
long_message_to_split = { | ||
routes = { | ||
{ | ||
filter = { event = "msg_show", min_height = 20 }, | ||
view = "split", | ||
opts = { enter = true }, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return M |