Skip to content

feat: dynamic main with - #4

Merged
sand4rt merged 2 commits into
mainfrom
dynamic-width
Apr 12, 2026
Merged

sand4rt merged 2 commits into
mainfrom
dynamic-width

Conversation

@sand4rt

@sand4rt sand4rt commented Apr 12, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 12, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for configuring the “main” window width dynamically (via a function) and updates the side-window sizing logic to use the resolved width.

Changes:

  • Extend Config/ConfigOptions typing to allow main.width to be number or fun(): number.
  • Introduce get_main_width() helper and route width calculations/comparisons through it.
  • Update side-window resizing logic to use the resolved main width consistently.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/zen/init.lua
Comment thread lua/zen/init.lua Outdated
Copilot AI review requested due to automatic review settings April 12, 2026 16:48
@sand4rt
sand4rt merged commit e472619 into main Apr 12, 2026
1 check passed
@sand4rt
sand4rt deleted the dynamic-width branch April 12, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/zen/init.lua
Comment on lines +52 to 55
vim.api.nvim_win_set_width(win_id, math.floor((vim.o.columns - get_main_width()) / 2))
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local", win = win_id })
vim.api.nvim_set_option_value("winfixbuf", true, { scope = "local", win = win_id })
vim.api.nvim_set_option_value("cursorline", false, { scope = "local", win = win_id })

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

Because opts.main.width can now be a function, evaluating get_main_width() multiple times across a single operation can yield inconsistent results (e.g., the caller checks vim.o.columns <= get_main_width() and then create_window() recomputes a different width). That can produce negative/invalid side widths in nvim_win_set_width. Consider computing local main_width = get_main_width() once in the autocmd callback and passing it into create_window() (or into the width calculation) so the check and the arithmetic use the same value.

Copilot uses AI. Check for mistakes.
Comment thread lua/zen/init.lua
Comment on lines 226 to 228
local left = vim.api.nvim_win_is_valid(get_side_buffer("left"))
if left then
vim.api.nvim_win_set_width(get_side_buffer("left"), new_width)

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

resize_side_buffers() recomputes get_main_width() internally. With a functional main.width, callers may already have checked vim.o.columns <= get_main_width() using a different value, leading to negative/invalid new_width. To keep behavior consistent, consider passing the resolved main_width into resize_side_buffers(main_width) (and using that value throughout the calling callback) rather than calling get_main_width() again here.

Copilot uses AI. Check for mistakes.
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.

3 participants