Commit graph

38 commits

Author SHA1 Message Date
Folke Lemaitre
d7caea32ab
style(picker): better debug/errors when running commands 2025-10-26 20:37:31 +01:00
Folke Lemaitre
244f5b1a97
refactor(picker): move explorer.confirm to picker.util 2025-10-26 20:37:02 +01:00
Folke Lemaitre
b7f811613a
fix(picker.format): added min_width for truncated paths 2025-10-21 08:14:34 +02:00
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
nickx00
7a5eb1036a
fix(explorer): mounted directories being detected as non-directories in Tree:expand (#2053)
## Description

In certain filesystems — such as bind mounts, NFS, FUSE, or other
mounted paths — uv.fs_scandir_next() may return a nil type for valid
directories. This causes the snacks.nvim explorer to treat mounted
folders as files, making them unexpandable in the UI.

This patch adds a fallback to resolve the correct type when
fs_scandir_next() returns nil. It uses uv.fs_stat() first, and falls
back to vim.fn.isdirectory() if needed.

This ensures that mounted directories are properly marked as navigable.

Code change summary:

- Inside Tree:expand, we now check t == nil
- If so, we call uv.fs_stat() to get the true type
- If fs_stat fails, we fallback to vim.fn.isdirectory
- Final dir = true logic remains intact

Impact:
- Fixes a long-standing bug in mounted directories under /mnt, FUSE,
etc.
- Only runs extra checks when needed (no performance hit for regular
files)
- No changes elsewhere — clean, isolated patch

## Related Issue(s)
  - Fixes #2036

## Screenshots

before:
<img width="1907" height="946" alt="image"
src="https://github.com/user-attachments/assets/15e1b8a5-c999-49e8-8ab5-1d23c60e4969"
/>

after:
<img width="343" height="902" alt="Screenshot_20250715_222920"
src="https://github.com/user-attachments/assets/c7ca2fa0-e0cc-4e3d-a4bb-5345538408f7"
/>

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-09-25 12:45:01 +02:00
Folke Lemaitre
e039139291
feat(image): configurable templates for math expressions. Closes #1338 2025-02-20 17:11:12 +01:00
Folke Lemaitre
bc902f7032
feat(compat): added svim, a compatibility layer for Neovim. Closes #1321 2025-02-20 06:59:44 +01:00
Folke Lemaitre
97dcd9c168
feat(picker.util): lua globber 2025-02-11 22:22:04 +01:00
Folke Lemaitre
5d42c7e5e4
feat(picker.util): utility function to get all bins on the PATH 2025-02-11 13:41:32 +01:00
Folke Lemaitre
8272c1c66f
fix(all): better support for opening windows / pickers / ... on multiple tab pages. Closes #1043 2025-02-10 11:24:13 +01:00
Folke Lemaitre
5af04ab667
feat(picker): get filetype from modeline when needed. Closes #987 2025-02-07 11:35:16 +01:00
Folke Lemaitre
2528fcb02c
feat(explorer): recursive copy and copying of selected items with c 2025-02-02 20:32:51 +01:00
Folke Lemaitre
5c5b40b5d0
feat(picker.pickwin): optional win/buf filter. Closes #877 2025-02-02 19:35:33 +01:00
Folke Lemaitre
6f8f0d3c72
feat(picker.projects): projects now automatically processes dev folders and added a bunch of actions/keymaps. Closes #871 2025-02-02 16:09:00 +01:00
Folke Lemaitre
6dbc26757c
fix(picker): make pick_win work with split layouts. Closes #834 2025-01-31 19:14:16 +01:00
Folke Lemaitre
5cae48d93c
feat(explorer): added git status. Closes #817 2025-01-31 19:08:32 +01:00
Folke Lemaitre
dad3e00e83
fix(picker.format): extra slash in path 2025-01-31 17:09:08 +01:00
Folke Lemaitre
4e7356c9ad
refactor(picker.actions): move pick_win to util so it can be used outside the picker. Closes #623 2025-01-30 21:04:05 +01:00
Folke Lemaitre
4e30ff0f1e
fix(picker.multi): apply source filter settings for multi source pickers. See #761 2025-01-28 14:19:25 +01:00
Folke Lemaitre
1069d78334
fix(picker.util): proper cwd check for paths. Fixes #754. See #757 2025-01-28 13:21:00 +01:00
Folke Lemaitre
14f16ceb5d
fix(picker.util): prevent empty shortened paths if it's the cwd. Fixes #721 2025-01-23 19:06:55 +01:00
Folke Lemaitre
9d5d3bdb17
feat(picker): added opts.rtp (bool) to find/grep over files in the rtp. See #680 2025-01-23 13:03:27 +01:00
Folke Lemaitre
ee6f21bbd6
fix(picker.util): for -- args require a space before 2025-01-23 12:43:52 +01:00
Folke Lemaitre
bab8243395
feat(picker.util): smart path truncate. Defaults to 40. Closes #708 2025-01-23 12:00:08 +01:00
Folke Lemaitre
97898e910d
feat(picker): added new icons picker for nerd fonts and emoji. Closes #703 2025-01-23 10:51:17 +01:00
Folke Lemaitre
964beb1148
fix(picker.util): more relaxed resolve_loc 2025-01-21 09:23:37 +01:00
Folke Lemaitre
cd5eddb1de
fix(picker): better handling of buffers with custom URIs. Fixes #677 2025-01-21 09:18:33 +01:00
Folke Lemaitre
5e00b0ab27
feat(picker.matcher): new opts.matcher.file_pos which defaults to true to support patterns like file:line:col or file:line. Closes #517. Closes #496. Closes #651 2025-01-20 11:40:06 +01:00
Folke Lemaitre
6b7705c7ed
fix(picker.util): relax pattern for args 2025-01-20 10:37:00 +01:00
Folke Lemaitre
3df2408713
fix(picker.lsp): backward compat with Neovim 0.95 2025-01-20 10:14:28 +01:00
Folke Lemaitre
d0a0046e37
fix(picker.lsp): lazy resolve item lsp locations. Fixes #650 2025-01-20 09:56:12 +01:00
Folke Lemaitre
2ff21b4394
fix(picker.util): item.resolve for nil item 2025-01-20 00:11:36 +01:00
Folke Lemaitre
b0d3266985
feat(picker): added support for item.resolve that gets called if needed during list rendering / preview 2025-01-19 21:53:18 +01:00
Folke Lemaitre
50f3c3e5b1
feat(picker): added support for live args for grep and files. Closes #601 2025-01-19 17:54:25 +01:00
Folke Lemaitre
2e70b7f423
feat(picker): added {preview} and {flags} title placeholders. Closes #557, Closes #540 2025-01-18 09:35:22 +01:00
Folke Lemaitre
7117356b49
perf(picker.util): cache path calculation 2025-01-16 12:57:38 +01:00
Folke Lemaitre
0892db4f42
feat(picker.git): stage/unstage files in git status with <tab> key 2025-01-15 22:12:19 +01:00
Folke Lemaitre
559d6c6bf2
feat(snacks): added snacks.picker (#445)
## Description

More info coming tomorrow.

In short:
- very fast. pretty much realtime filtering/sorting in huge repos (like
1.7 million files)
- extensible
- easy to customize the layout (and lots of presets) with
`snacks.layout`
- simple to create custom pickers
- `vim.ui.select`
- lots of builtin pickers
- uses treesitter highlighting wherever it makes sense
- fast lua fuzzy matcher which supports the [fzf
syntax](https://junegunn.github.io/fzf/search-syntax/) and additionally
supports field filters, like `file:lua$ 'function`

There's no snacks picker command, just use lua.

```lua
-- all pickers
Snacks.picker()

-- run files picker
Snacks.picker.files(opts)
Snacks.picker.pick("files", opts)
Snacks.picker.pick({source = "files", ...})
```

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Todo
- [x] issue with preview loc not always correct when scrolling fast in
list (probably due to `snacks.scroll`)
- [x] `grep` (`live_grep`) is sometimes too fast in large repos and can
impact ui rendering. Not very noticeable, but something I want to look
at.
- [x] docs
- [x] treesitter highlights are broken. Messed something up somewhere

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->
2025-01-14 22:53:59 +01:00