[Feature] Custom window layout properties
Hi, i was wondering if we would be able to override the custom properties passed in in the window layout class, would be great i we could provide custom settings to override these - i am mainly interested in being able to customize things like relnumber and wrap for example. Thanks !
function WindowLayout:_init_win_settings(win)
local win_settings = {
list = false,
relativenumber = false,
number = false,
winfixwidth = true,
winfixheight = true,
wrap = false,
signcolumn = "auto",
}
for key, val in pairs(win_settings) do
api.nvim_win_set_option(win, key, val)
end
vim.fn.setwinvar(win, "&winhl", "Normal:DapUINormal,EndOfBuffer:DapUIEndOfBuffer")
end
You can use autocmds to do this:
vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = {"\\[dap-repl\\]", "DAP *"},
callback = function(args)
local win = vim.fn.bufwinid(args.buf)
...
end,
})
Indeed, but it seems like since the plugin itself does provide / create the ui it is more in line to allow for custom options to be passed in during configuration, also the auto cmd above relies on the string names of the buffers which might change, it does not seem like a too robust solution imo.
The buffer names are considered public API, so they'd be as stable as any configuration options offered :smile: I'd also like to limit the exposure of the window management API right now, I'm planning to change it quite a bit and don't want to add functionality that will likely change in future, especially any that can already be performed by neovim built-ins
You can use autocmds to do this:
vim.api.nvim_create_autocmd("BufWinEnter", { pattern = {"\\[dap-repl\\]", "DAP *"}, callback = function(args) local win = vim.fn.bufwinid(args.buf) ... end, })
this doesn't seem to work
This works for me to set line numbers on DAP windows
vim.api.nvim_create_autocmd("BufWinEnter", {
desc = "Set options on DAP windows",
group = vim.api.nvim_create_augroup("set_dap_win_options", { clear = true }),
pattern = { "\\[dap-repl\\]", "DAP *" },
callback = function(args)
local win = vim.fn.bufwinid(args.buf)
vim.schedule(function()
if not vim.api.nvim_win_is_valid(win) then return end
vim.api.nvim_set_option_value("number", true, { win = win })
end)
end,
})
edit: I'm on neovim nightly btw