fix(picker): support relative and opt-out picker_width values#400
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
picker_widthonly 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 sincevim.tbl_deep_extenddropsnilvalues during config merge.Additionally, all four pickers hardcode an
or 100fallback, preventing any opt-out value from propagating.Solution
Extend
picker_widthto support three modes:>1): fixed column count, same as before (e.g.picker_width = 120)0<w<=1): fraction of screen width (e.g.picker_width = 0.8for 80%)false: delegate all sizing to the picker backend. Usesfalseinstead ofnilbecausevim.tbl_deep_extendcannot mergenilover a default value.Non-breaking: the default
picker_widthremains100in @config.lua.Changes
Relative width resolution (@
base_picker.lua) — Resolve values in(0, 1]to absolute columns viamath.floor(vim.o.columns * w)at the start ofM.pick(), before format functions or backends consume the value.falseopt-out (base_picker.lua) — Convertfalsetonilat the start ofM.pick(). Whennil, no @winopts.widthoverride is passed to fzf-lua and format functions fall back tovim.api.nvim_win_get_width(0).Remove hardcoded fallbacks (session, timeline, reference, history pickers) — Replace
config.ui.picker_width or 100withconfig.ui.picker_widthsofalsepropagates cleanly throughM.pick().Type annotation (@
types.lua) — Updatepicker_widthfield to documentnumber|false|niland the three modes.