snacks.nvim/lua
Folke Lemaitre 9ad5d5374a
feat(picker): flexible filename format (#2294)
## 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>
2025-10-20 23:02:52 +02:00
..
snacks feat(picker): flexible filename format (#2294) 2025-10-20 23:02:52 +02:00
trouble/sources Revert "feat: test" 2025-02-14 22:13:38 +01:00