mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
## Description This PR builds on top of #743 to add flexible filename formatting in the picker. ### Changes: - **Flexible path truncation**: Added support for different truncation strategies (`left`, `center`, `right`) instead of just a fixed number - `left`: truncates the beginning of the path (e.g., `…/path/to/file.lua`) - `center`: truncates the middle of the path (default behavior, e.g., `~/pro…/file.lua`) - `right`: truncates the end of the path (e.g., `~/projects/long…`) - **Dynamic width calculation**: The filename formatter now adapts to available window width using a resolve function - **Enhanced truncate utility**: Updated `M.truncate()` to support left-side truncation ### Implementation: The filename formatter now uses a `resolve` function that receives context including the picker, item, current offset, and maximum available width. This allows the formatter to make intelligent decisions about how to display the path based on actual available space. ## Related Issue(s) - Based on #743 - Addresses dynamic path formatting needs ## Technical Details The implementation introduces: 1. `snacks.picker.format.ctx` - context passed to resolve functions 2. `snacks.picker.format.resolve` - callback type for dynamic formatting 3. `Snacks.picker.highlight.resolve()` - resolves flex text elements in highlight arrays --------- Co-authored-by: qw457812 <37494864+qw457812@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| snacks | ||
| trouble/sources | ||