Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Custom window layout properties #248

Open
asmodeus812 opened this issue Mar 12, 2023 · 5 comments
Open

[Feature] Custom window layout properties #248

asmodeus812 opened this issue Mar 12, 2023 · 5 comments

Comments

@asmodeus812
Copy link

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
@rcarriga
Copy link
Owner

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

@asmodeus812
Copy link
Author

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.

@rcarriga
Copy link
Owner

The buffer names are considered public API, so they'd be as stable as any configuration options offered 😄 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

@emxxjnm
Copy link

emxxjnm commented Jun 28, 2023

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

@serranomorante
Copy link
Contributor

serranomorante commented Dec 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants