nvim-dap-ui icon indicating copy to clipboard operation
nvim-dap-ui copied to clipboard

[Feature] Custom window layout properties

Open asmodeus812 opened this issue 2 years ago • 6 comments

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

asmodeus812 avatar Mar 12 '23 17:03 asmodeus812

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,
})

rcarriga avatar Mar 13 '23 09:03 rcarriga

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.

asmodeus812 avatar Mar 13 '23 11:03 asmodeus812

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

rcarriga avatar Mar 13 '23 19:03 rcarriga

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

emxxjnm avatar Jun 28 '23 03:06 emxxjnm

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

serranomorante avatar Dec 14 '23 15:12 serranomorante