Skip to content

Conversation

hc-nolan
Copy link

@hc-nolan hc-nolan commented Apr 30, 2025

This PR adds a new config option wrap that lets the user choose to wrap the text within the UI windows. Defaults to false, the current default value.

Fixes #435

@nindaba
Copy link

nindaba commented May 14, 2025

Hi @chunned

Thanks for creating this PR,

I was testing this approach, and I found that some widgets such as Threads and Variables get messy, Is there a possiblity to configure the wrapping in the layout section on the element level, such that there is more control on which widget is wrapping

@hc-nolan
Copy link
Author

I don't believe that is possible, although I may be wrong. It looks like the layout settings are global.

Copy link

@nindaba nindaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested the folowing changes and they seem to work for me well, as I don't need other widgets to wrap. For example Threads and variables tend to get messy when they are wrapped

The solution would be to add wrap to the layout elements and make changes to the layout.lua line 7

 3 ---@class dapui.WinState
+7 ---@field wrap boolean

then apply the changes to the open function by adding the following changes

+33  for i, win_state in pairs(self.win_states) do
+41       if win_state.wrap then
+42          api.nvim_win_set_option(self.opened_wins[i], "wrap", true)
+43      end

at least the above changes are working for me very well, I am not an expert in lua perhaps you can figure out a way to integrate this changes nices and include docs, however default configs are not needed for other windows, may be the integrated terminal would be the best place for default wrap=true as console logs tend to not wrap

winfixwidth = true,
winfixheight = true,
wrap = false,
wrap = config.wrap,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

@hc-nolan
Copy link
Author

I like the suggestions, I'll have a go at implementing them some time this week. I have a few questions:

  • Does this approach work with AreaState as well as WinState? My thinking is that it would be ideal if the user could also choose to set wrapping for an area, e.g.:
{
      elements = {
        "repl",
        "console",
      },
      size = 10,
      position = "bottom", -- Can be "bottom" or "top"
      wrap = true
}
  • For your suggested reversion, does the wrap = config.wrap setting override the wrap setting for all elements with your new approach? If not, I think it would be ideal for there to still be a global toggle, but to also have the option of enabling it for specific windows in the layout configuration. However, if it does override the ability to set the wrap option for specific elements individually, then I think removing it is better.

  • One minor thing, mostly a reminder for myself when I have the time to work on this: nvim_win_set_option is deprecated; use nvim_set_option_value(opt, val, { win = ... })

@nindaba
Copy link

nindaba commented May 15, 2025

unfortunately doing the following would cost you more coding since it will require you to draw wrapping from gobal config, as each layout represents a window in vim and each window is configured differently from element = {}

{
      elements = {
          .......
      },
      .......
      .......
      wrap = true
}

Note: I am not saying that it is not possible, it is doable and its a nice challenge. just dig into the init.lua
perhaps you can also add those hardcoded configs into the config table

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

Successfully merging this pull request may close these issues.

issue: wrap not inherited, no configurable option

2 participants