Skip to content

fix(picker): support relative and opt-out picker_width values#400

Merged
sudo-tee merged 2 commits into
sudo-tee:mainfrom
hermandavid:fix/picker-relative-width
Jun 5, 2026
Merged

fix(picker): support relative and opt-out picker_width values#400
sudo-tee merged 2 commits into
sudo-tee:mainfrom
hermandavid:fix/picker-relative-width

Conversation

@hermandavid
Copy link
Copy Markdown
Contributor

Issue

picker_width only accepts absolute column counts. Users who want the picker to scale with their terminal size have no way to specify a relative width. Users who want to delegate sizing entirely to their picker backend (fzf-lua, telescope, snacks) cannot opt out of the hardcoded default since vim.tbl_deep_extend drops nil values during config merge.

Additionally, all four pickers hardcode an or 100 fallback, preventing any opt-out value from propagating.

Solution

Extend picker_width to support three modes:

  • Absolute (>1): fixed column count, same as before (e.g. picker_width = 120)
  • Relative (0<w<=1): fraction of screen width (e.g. picker_width = 0.8 for 80%)
  • false: delegate all sizing to the picker backend. Uses false instead of nil because vim.tbl_deep_extend cannot merge nil over a default value.

Non-breaking: the default picker_width remains 100 in @config.lua.

Changes

  • Relative width resolution (@base_picker.lua) — Resolve values in (0, 1] to absolute columns via math.floor(vim.o.columns * w) at the start of M.pick(), before format functions or backends consume the value.

  • false opt-out (base_picker.lua) — Convert false to nil at the start of M.pick(). When nil, no @winopts.width override is passed to fzf-lua and format functions fall back to vim.api.nvim_win_get_width(0).

  • Remove hardcoded fallbacks (session, timeline, reference, history pickers) — Replace config.ui.picker_width or 100 with config.ui.picker_width so false propagates cleanly through M.pick().

  • Type annotation (@types.lua) — Update picker_width field to document number|false|nil and the three modes.

picker_width now supports three modes:

- Absolute (>1): fixed column count, e.g. picker_width = 120
- Relative (0<w<=1): fraction of screen, e.g. picker_width = 0.8
- false: delegate all sizing to the picker backend (fzf-lua, telescope,
  snacks, mini.pick). Use false instead of nil because vim.tbl_deep_extend
  drops nil values during config merge, so nil cannot override the default.

Relative values are resolved to absolute columns in M.pick() so that
format functions receive a consistent value. Remove the hardcoded
'or 100' fallbacks from individual pickers so false propagates cleanly.

Non-breaking: default picker_width remains 100 in config.lua.
…h for opt-out mode

The model picker was the only picker not passing width to base_picker.pick(),
causing format_fn to fall back to the full neovim window width when
picker_width was nil or false. This produced lines wider than the fzf-lua
content area, clipping provider names on the right.

Pass picker_width consistently and, when it resolves to nil (opt-out),
derive format_width from fzf-lua's effective winopts.width so padded
columns align to the actual content area.
@sudo-tee sudo-tee merged commit e9aae35 into sudo-tee:main Jun 5, 2026
5 checks passed
@hermandavid hermandavid deleted the fix/picker-relative-width branch June 5, 2026 11:34
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.

2 participants