Commit graph

1475 commits

Author SHA1 Message Date
Folke Lemaitre
7a63ba5d37
feat(util): add LSP utility module with dynamic capability handlers
Add `Snacks.util.lsp.on()` to register handlers that fire when LSP clients
attach with specific capabilities. Supports filtering by:
- LSP method/capability
- Client name
- Buffer ID
- Any vim.lsp.get_clients() filter

Features:
- Handles both LspAttach and client/registerCapability events
- Ensures handlers only fire once per buffer
- Lazy-loaded via Snacks.util metatable

This provides a foundation for LSP-aware features like conditional keymaps.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 16:31:13 +02:00
Folke Lemaitre
f75eaf1e18
fix(dashboard): don't write to closed terminal buffer 2025-10-25 13:35:33 +02:00
Folke Lemaitre
d569072b2e
fix(explorer): macos has trash pre-installed, so no need to try osascript and move to first. Closes #2349
Some checks are pending
CI / ci (push) Waiting to run
2025-10-25 11:16:29 +02:00
Whitney Beck
602393aed2
fix(layout): provide parent win width/height when relative to win (#2346)
## Description

When a win is relative = "win" it should size itself relative to that
win's size. Currently this only happens correctly when the picker layout
is created. All subsequent updates, such as a toggle_preview action, can
potentially trigger calls to a function width/height opt with a
max_width and max_height smaller than was previously calculated. This
feeds into a recursive series of updates triggered by the WinResized
event triggering and updating with a yet smaller max_width or
max_height.

Additionally, because win.o.cols and win.o.lines is used,
relative/decimal dimensions would not calculate correctly in splits.
Screenshots are from a picker configured as
```
{
    col = 1,
    height = 0.9,
    width = 0.9,
    position = 'float',
    relative = 'win',
}
```
**before** 
<img width="1348" height="1358" alt="image"
src="https://github.com/user-attachments/assets/847b0565-afd0-4ca1-b44c-eb63e335afca"
/>

**after**
<img width="1354" height="1354" alt="image"
src="https://github.com/user-attachments/assets/064f25ae-ed17-42c8-8b34-f32652fab02d"
/>
2025-10-25 08:22:28 +02:00
Folke Lemaitre
ed08ef1a63
feat(explorer): add cross-platform trash support
- Add `trash` config option to use system trash when deleting files
- Implement trash support for Linux (gio, trash-cli, kioclient)
- Implement trash support for macOS (osascript/Finder)
- Implement trash support for Windows (PowerShell/RecycleBin)
- Add health check to verify trash command availability
- Gracefully fallback to permanent delete when trash unavailable
- Improve error messages with command details

Closes #982

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 07:45:02 +02:00
Folke Lemaitre
4122143240
fix(image): increase timeout for querying the terminal. Closes #2344 2025-10-25 06:52:56 +02:00
Folke Lemaitre
7bf4175588
fix(image): detach image when reloading image file. Closes #2343 2025-10-25 06:43:26 +02:00
Folke Lemaitre
c9528341a6
fix(dahboard): do full terminal reset when receiving first output and displayed cached contents
Some checks are pending
CI / ci (push) Waiting to run
2025-10-24 23:49:19 +02:00
Folke Lemaitre
6f72643323
fix(image): only attach to a buffer once. Closes #2343 2025-10-24 23:30:38 +02:00
Folke Lemaitre
4d776bdd1d
fix(dashboard): work-around for jobstart+pty issue where not all output is processed before exit. Closes #1706 2025-10-24 23:25:28 +02:00
flashios09
869709dd65
feat(win): add SnacksWinSeparator to default win.wo.winhighlight (#2340)
See #2336
2025-10-24 17:01:24 +02:00
Folke Lemaitre
efa304a078
perf(picker): re-use existing string parsers per language to prevent needing to create new parsers 2025-10-24 17:00:36 +02:00
flashios09
381265b543
feat(win): add default *Snacks* prefixed WinSeparator (#2338)
See #2336
2025-10-24 16:41:43 +02:00
Folke Lemaitre
ad6c0a5e54
perf(picker): don't use treesitter string parser, since a change in nightly creates thousands of unlisted buffers in that case 2025-10-24 16:39:28 +02:00
Folke Lemaitre
69417ac681
fix(picker): set min file width to 40 2025-10-24 16:26:52 +02:00
Folke Lemaitre
bbd6d42a97
fix(win): use sbuffer instead of split for split windows 2025-10-24 10:55:41 +02:00
Folke Lemaitre
56bdc78505
refactor(scroll): convert to object-oriented state management
Converted scroll state management from procedural to OO approach:

- State is now a proper class with methods (get, stop, wo, valid, update, reset)
- Window options now managed per-state (_wo field) instead of global wo_backup table
- Centralized cleanup in State:stop() method
- Consolidated validation in State:valid() method
- Added is_enabled() helper for enable checks
- Simplified code throughout by using state methods

Benefits:
- Clearer state lifecycle management
- Better encapsulation and ownership
- Less code duplication
- More maintainable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 09:43:19 +02:00
Folke Lemaitre
9b22e97647
refactor(picker.preview): centralize builtin/pager git options 2025-10-24 08:30:22 +02:00
Folke Lemaitre
b029511abb
fix(image): let healthcheck wait till terminal detection is done 2025-10-24 07:38:39 +02:00
Folke Lemaitre
c9ccbe5617
fix(picker): fix race condition causing "Finder yielded after done" error. Closes #2327
The old code had a race condition where:
1. R:request() scheduled LSP request setup but immediately suspended
2. R:wait() checked #self.requests (still 0) and returned immediately
3. Finder completed and set running = false
4. Then scheduled function ran and LSP responses came back
5. Callbacks tried to yield items but finder was already done → error

The fix uses a pending counter to track when the scheduled setup function
is running, ensuring we wait for both the setup to complete AND all LSP
responses before the finder completes.

Also improved error handling by checking the err parameter in callbacks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 07:25:22 +02:00
Folke Lemaitre
e93dcfdf39
fix(image): work around tmux extended-keys breaking TermResponse. Closes #2332
When tmux has extended-keys enabled, Neovim's TermResponse autocmd doesn't fire,
causing terminal response sequences to leak as literal text into buffers.

Workaround: Detect this configuration and query tmux directly for the terminal
name using `tmux display-message -p "#{client_termname}"` instead of sending
escape sequences.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 06:59:17 +02:00
github-actions[bot]
d1eaa30b1b
chore(main): release 2.25.0 (#2329)
🤖 I have created a release *beep* *boop*
---


##
[2.25.0](https://github.com/folke/snacks.nvim/compare/v2.24.0...v2.25.0)
(2025-10-23)


### Features

* **notifier:** added `gap` option. Closes
[#2331](https://github.com/folke/snacks.nvim/issues/2331)
([b1acbb0](b1acbb0fcc))
* **select:** allow configuring options for specific vim.ui.select kinds
([bca5b05](bca5b05838))
* **snacks:** added `Snacks.version`. auto updated by the release
workflow
([a283beb](a283beb6dc))


### Bug Fixes

* **dashboard:** fix issue with opening file at location due to
splitkeep and restoring laststatus/showtabline
([1a2b34d](1a2b34dffd))
* **scroll:** stop animations when buf/changedtick changes
([a42b376](a42b3761f7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-23 21:30:03 +02:00
Folke Lemaitre
a42b3761f7
fix(scroll): stop animations when buf/changedtick changes 2025-10-23 21:24:33 +02:00
Folke Lemaitre
b1acbb0fcc
feat(notifier): added gap option. Closes #2331 2025-10-23 20:30:49 +02:00
Folke Lemaitre
1a2b34dffd
fix(dashboard): fix issue with opening file at location due to splitkeep and restoring laststatus/showtabline 2025-10-23 20:13:20 +02:00
Folke Lemaitre
bca5b05838
feat(select): allow configuring options for specific vim.ui.select kinds 2025-10-23 18:53:23 +02:00
folke
8625e4bd72 chore(build): auto-generate markdown docs
Some checks are pending
CI / ci (push) Waiting to run
2025-10-23 13:43:55 +00:00
Folke Lemaitre
a283beb6dc
feat(snacks): added Snacks.version. auto updated by the release workflow 2025-10-23 15:35:33 +02:00
Daniel Wennberg
90227af497
fix(image): skip \usepackage in comments and body (#2325)
## Description

Here are some small and hopefully uncontroversial tweaks to package
extraction from LaTeX preambles:

* Don't consider anything in comments
* Make sure that the extracted names are actually the arguments of
`\usepackage` and not some other macro on the same line
* Stop looking for packages at `\begin{document}`, where the preamble
ends and the body of the document begins (you can't load packages after
this, so any `\usepackage` beyond this point is content, not code. Also
saves a huge amount of work in large documents.)

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-23 11:14:32 +02:00
maskudo
ca0f8b2c09
feat(picker.scratch): add scratch picker with grep, new and delete keybinds (#1019)
## Description


The scratch module uses `vim.ui.select` which misses the nice things
about the picker.
This implementation adds scratch picker with ability to create, grep and
delete scratch buffers.

Couldn't figure out how to prettify the scratch buffer's name so any
help would be appreciated.
## 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. -->

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-23 10:53:02 +02:00
Folke Lemaitre
4e1070867a
fix(picker.lsp): don't process lsp request results when aborted. Closes #2327
Some checks are pending
CI / ci (push) Waiting to run
2025-10-23 09:45:28 +02:00
Folke Lemaitre
7964f040bf
feat(picker.git_diff): add base option to show diff against a merge base. Useful to see changes on a branch/PR 2025-10-23 09:25:56 +02:00
David
b30121bfce
fix(picker.actions): ensure the current window is updated after tabdrop (#2326)
## Description

Update the winid (in the `win` variable) after `tab drop`.

## Related Issue(s)

Without this patch, when the user set `confirm` to `{ action =
"confirm", cmd = "tabdrop" }` and jump to a location in a different tab,
since the `win` is still pointing to the original window (tab), there'd
be a `Cursor position outside buffer` error.
2025-10-23 09:09:24 +02:00
Folke Lemaitre
6c7ddae887
fix(image.terminal): do only terminal detection for now. Closes #2323 2025-10-23 07:02:17 +02:00
Folke Lemaitre
c1737d866e
feat(win): all existing snacks windows for all plugins now honor vim.o.winborder. Defaults to rounded if not set. 2025-10-22 23:06:35 +02:00
Folke Lemaitre
b30523c89f
feat(win): added support for vim.o.winborder. Set win.border = true to use it 2025-10-22 23:06:35 +02:00
Valentin Degenne
b8d17192b6
feat(win): generalize footer options for keys (#363)
#fixes https://github.com/folke/snacks.nvim/issues/361

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-22 22:36:09 +02:00
Folke Lemaitre
766f7b87aa
fix(scroll): stop anim and reset state when win has new buf, or buf was changed. Closes #1820. Closes #2221 2025-10-22 22:10:38 +02:00
Folke Lemaitre
79f3a8d8b3
fix(picker.lsp): move get_clients inside vim.schedule to prevent issues on Neovim 0.11. Closes #2320 2025-10-22 21:54:05 +02:00
Folke Lemaitre
43261baf87
fix(image): detect kitty image protocol through terminal capability request. Closes #1695 2025-10-22 16:56:26 +02:00
Folke Lemaitre
42902871f5
feat(picker): added Snacks.picker.tags() a picker for ctags. Closes #1728 2025-10-22 14:44:02 +02:00
Folke Lemaitre
de1b7a8729
refactor(picker.help): simplified help picker 2025-10-22 14:33:16 +02:00
Folke Lemaitre
db3c13c28e
feat(picker): when resuming a source that has nothing to resume, start a picker with the source instead 2025-10-22 13:31:47 +02:00
Folke Lemaitre
bc6c446c11
feat(picker): enhanced resume with multi-state support and flexible API
Refactored picker resume functionality to support multiple picker states instead of just the last one. Each picker source now maintains its own resume state, allowing users to resume any previously opened picker.

Key improvements:
- Multi-state storage: Each picker source tracks its own state independently
- Flexible API: `Snacks.picker.resume({ source = "files" })` or with include/exclude options
- LSP caching: Cache LSP results for instant resume of LSP pickers
- Better UX: Can resume specific pickers by source name

Moved resume logic to dedicated `picker/resume.lua` module for better separation of concerns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 13:24:18 +02:00
Folke Lemaitre
2b9d52258d
feat(picker.lsp): added option keep_parents to lsp_symbols (default false). See #2083. closes #2266 2025-10-22 11:24:08 +02:00
SheffeyG
471eb036c4
fix(win): check parent win is valid before getting size (#2315)
## Related Issue(s)

  - Fixes #1926
2025-10-22 10:21:24 +02:00
Folke Lemaitre
6f1158fe9b
fix(picker.lsp): trigger docs workflow
Some checks are pending
CI / ci (push) Waiting to run
2025-10-22 10:10:30 +02:00
Folke Lemaitre
55d6670a7e
feat(picker.lsp): added lsp_incoming_calls and lsp_outgoing_calls. Closes #1843 2025-10-22 09:56:36 +02:00
Folke Lemaitre
a45503b957
feat(picker.finder): added assertions that finder is still running when receiving results 2025-10-22 08:52:07 +02:00
Folke Lemaitre
04990d042c
perf(picker): set limit_live=10000 by default. Makes no sense to load millions of matches when doing live searches. 2025-10-22 06:55:32 +02:00