Skip to content

feat: add dynamic_win_width option for tags window - #199

Open
awerebea wants to merge 4 commits into
cbochs:mainfrom
awerebea:feat/dynamic-win-width
Open

feat: add dynamic_win_width option for tags window#199
awerebea wants to merge 4 commits into
cbochs:mainfrom
awerebea:feat/dynamic-win-width

Conversation

@awerebea

Copy link
Copy Markdown

Summary

Add a dynamic_win_width setting that automatically sizes the tags window to fit the longest tag
path rather than using a fixed width.

How it works:

  • Accepts a number between 0 and 1 (exclusive) representing the maximum width as a fraction of
    the editor width, or false (default) to keep the existing static-width behavior.
  • win_opts.width is repurposed as the minimum floor: the computed width is clamped between
    win_opts.width and vim.o.columns * dynamic_win_width.
  • Width calculation accounts for: display style (relative strips the scope path prefix,
    basename uses only the filename), optional tag names rendered as EOL virtual text, icon
    padding, and the index/separator overhead (/001 + icon = ~10 cols with icons, ~7 without).
  • open_window(content, win_opts?) gains an optional second parameter so computed opts are passed
    per-call without mutating global settings.

No breaking changes. Default is false; existing configs behave identically.

-- Example
require("grapple").setup({
    dynamic_win_width = 0.8,  -- max 80% of editor width
    win_opts = {
        width = 40,           -- minimum width (floor)
    },
})

awerebea added 4 commits July 9, 2026 20:34
Add `dynamic_win_width` setting that accepts a fraction (0–1) to
calculate the tags window width based on the longest tag path.

- Add `dynamic_win_width` setting to DEFAULT_SETTINGS (false by
  default)
- Compute display length per tag respecting relative/basename styles
- Cap computed width at `dynamic_win_width * vim.o.columns`
- Use `win_opts.width` as minimum width
- Pass computed win_opts to `open_window` via new optional parameter
When calculating max display length for tag alignment, include
the tag's name length and padding offset (+2) so that virt_text
does not overflow when name_pos is "start".
- Add dynamic_win_width option to default settings in docs
- Add table of contents entry for dynamic window width
- Document width calculation algorithm and overhead values
- Add configuration example with annotated win_opts
- Add worked numeric example showing clamp behaviour
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.

1 participant