Commit graph

1447 commits

Author SHA1 Message Date
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
Jakub F. Bortlík
57fbda70d6
feat(picker): allow configuring pathspec for git grep (#2311)
## Description

This is in place of the rejected PR #2178. Please consider the following
reasons for merging.

This PR adds the possibility to specify pathspec patterns to the `git
grep .... -- <patchspec>` command. This is necessary for ignoring large
git-tracked files (that cannot be added to `.gitignore`) from the git
grep search. git-grepping in some large files with very long lines can
freeze Neovim and make `Snacks.picker.git_grep` completely unusable.

Without this change the picker cannot be configured to use some
pathspecs by default. They can be added dynamically in live mode but
re-typing the same pathspecs every time one needs to use
`Snacks.picker.git_grep` would be silly.

In reply to the [question if cmd_args can be used for
this](https://github.com/folke/snacks.nvim/pull/2178#discussion_r2448762906):
No. The "pathspecs" need to be specified *last* (optionally after `--`).
When configuring Snacks.picker like this:
```lua
  sources = {
    git_grep = {
      cmd_args = { ':!*.min.js', ':!*.min.css', ':!uv.lock'  },
    },
  }
```
then the `cmd_args` are inserted in front of the search pattern and `git
grep` doesn't find anything. The following config can't be used either
because that will cause the [search
pattern](c9fa6f7b07/lua/snacks/picker/source/git.lua (L76))
to be treated as one of the pathspecs.
```lua
    git_grep = {
      cmd_args = { '--', ':!*.min.js', ':!*.min.css', ':!uv.lock'  },
    },
```
2025-10-22 06:33:33 +02:00
Folke Lemaitre
d293b21fe1
fix(scroll): don't animate 1 line scrolls (jk). Closes #1620
Some checks are pending
CI / ci (push) Waiting to run
2025-10-21 23:57:09 +02:00
Folke Lemaitre
92a08cece7
fix(image): work-around for sha256 not allowed to be a Blob 2025-10-21 23:39:36 +02:00
Folke Lemaitre
080320bb82
fix(picker.preview): don't record previeww searches in history and prevent scrolling from the top. Closes #2305 2025-10-21 23:29:58 +02:00
Folke Lemaitre
2c56e10b1d
feat(image): added support for base64 encoded images in url. Closes #2304 2025-10-21 22:59:36 +02:00
Folke Lemaitre
8116e0b380
feat(indent): pass win to filter func. Closes #2307 2025-10-21 22:39:49 +02:00
Folke Lemaitre
1417701af6
perf(grep): move match parsing to resolve and fix an issue with .* results. Closes #2308 2025-10-21 22:32:44 +02:00
Folke Lemaitre
c9fa6f7b07
feat(picker): added live support to git_log, which uses -S (pickaxe) to search. Closes #1544 2025-10-21 17:49:13 +02:00
Folke Lemaitre
924a9304e9
fix(picker): show_delay is in ms. Also increase it to allow auto_confirm to work properly 2025-10-21 17:48:10 +02:00
Folke Lemaitre
5782b5cda0
feat(git): allow configuring extra git args and git cmd args for all git sources. See #2178 2025-10-21 17:17:14 +02:00
Pedro Pombeiro
f324f96bea
feat(picker.git): use default previewer args in git_show (#1736)
## Description

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

Currently, I'm able to perform a search on a YADM repo by passing the
args `{ "--git-dir", "/Users/pedro/.local/share/yadm/repo.git",
"--work-tree", "/Users/pedro" }` to `picker.previewers.git.args`.
Unfortunately, the `git_show` previewer is currently not using this
configuration, so constantly fails to show the preview with an error
message. This MR fixes the problem by leveraging the existing `git`
local function.

## 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. -->

<img width="1582" alt="image"
src="https://github.com/user-attachments/assets/6f7c3960-cfc0-4c0c-a264-105a721cd9a8"
/>

Previewer working inside a YADM repo.
2025-10-21 16:43:37 +02:00
Anthony Qiu
2cf864aaa1
feat(picker): add author field to git log (#2295)
## Description

Currently in the picker you cant filter git log pickers by author, the
only option to do that right now is to pass it into the opts when you
call it like lua Snacks.picker.git_log({ author="test" }) but most of
the time I would like to filter interactively and also use the field
filtering offered by snacks like file:lua$ and with this new change,
author:test.

## Related Issue(s)

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

## Screenshots
<img width="760" height="842" alt="Screenshot 2025-10-13 at 11 03 28 PM"
src="https://github.com/user-attachments/assets/e57278aa-0fcd-4513-981d-fe8cfe078c64"
/>
<!-- Add screenshots of the changes if applicable. -->

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-21 16:38:24 +02:00
Folke Lemaitre
a5d45d543e
fix(explorer): reset main when entering another window. Closes #1587 2025-10-21 16:30:33 +02:00
Folke Lemaitre
cc69a9304b
fix(dashboard): restore showtabline/laststatus when entering another non-float window. Closes #1774 2025-10-21 16:16:33 +02:00
Folke Lemaitre
0bf8fe4ece
fix(picker.format): apply hidden file hl group last. Fixes #2127 2025-10-21 16:07:59 +02:00
Folke Lemaitre
8c501965be
fix(terminal): stack only terminal splits by default. Closes #2137 2025-10-21 16:04:38 +02:00
Folke Lemaitre
e46a09427c
feat(win): make split window "stacking" configurable 2025-10-21 16:04:38 +02:00
Folke Lemaitre
c757d4dc28
fix(layout): allow width/height to be a function. Closes #2184 2025-10-21 15:47:08 +02:00
Folke Lemaitre
67bb3a7ba0
fix(picker): show_delay config value 2025-10-21 15:38:12 +02:00
Folke Lemaitre
64583a0386
fix(picker): added show_delay to config max ms to wait to show if no results found yet. Closes #2206 2025-10-21 15:37:51 +02:00
phanium
5173e96f33
fix(image): ENOENT on preview (#2301)
After cb6bf052, occationally I get this error when attach snacks.image
in fzf-lua previewer

vim.schedule callback: runtime/lua/vim/fs.lua:737:
ENOENT: no such file or directory:
/home/phan/.cache/nvim/snacks/image/56bd7d4f-img.shields.io-badge-Made-with-Lua-blueviolet.svg.data
stack traceback:
    [C]: in function 'error'
    runtime/lua/vim/fs.lua:737: in function 'rm'
    snacks.nvim/lua/snacks/image/convert.lua:66: in function 'on_error'
    snacks.nvim/lua/snacks/image/convert.lua:340: in function 'on_step'
snacks.nvim/lua/snacks/image/convert.lua:434: in function
<snacks.nvim/lua/snacks/image/convert.lua:433>
2025-10-21 14:46:27 +02:00
Folke Lemaitre
d491236941
fix(input): zindex. Closes #2302 2025-10-21 14:45:04 +02:00
Folke Lemaitre
df018edfdb
fix(picker.list): resize when needed. Closes #2290 2025-10-21 14:44:03 +02:00
Folke Lemaitre
ad6cbc8d5d
fix(input): schedule stopinsert. Fixes #1841 2025-10-21 13:38:37 +02:00
Folke Lemaitre
67d690d362
fix(input): zindex 2025-10-21 13:32:59 +02:00
Folke Lemaitre
756a791131
fix(picker): prevent WinEnter handling during startup
When opening Neovim with a directory argument (e.g., `nvim .`), the
explorer's preview window was not being shown automatically. This was
because the WinEnter autocmd in the picker was triggering during the
startup sequence before VimEnter, interfering with the initialization.

The fix adds a check for `vim.v.vim_did_enter == 0` to skip the window
management logic during startup, allowing the explorer to properly
initialize with its preview window enabled.

Fixes #2257 (second issue)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 13:16:14 +02:00
Folke Lemaitre
e796aef0fa
fix(picker): correct z-index for preview="main" layout
When using `preview="main"`, the preview window floats over the main
editor window. Set its z-index to 40 (lower than the default 50) to
ensure input and help windows remain on top and visible.

Fixes #2257 (first issue)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 12:49:56 +02:00
Folke Lemaitre
2b22fe7861
feat(picker): add git_restore action for git_status picker
Adds a git_restore action that discards changes to files in the
git_status picker. Includes confirmation prompt before discarding
changes to prevent accidental data loss.

Usage:
- `<C-r>` in git_status picker to restore selected file(s)
- Works with multi-select (select multiple files and restore all)
- Shows different confirmation messages for single vs multiple files

Implementation:
- Added git_restore() action in actions.lua
- Bound to <C-r> in git_status picker
- Supports both single and multi-select
- Uses Snacks.picker.select for confirmation
- Refreshes picker and returns to insert mode after restore

Closes #2298

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 12:43:00 +02:00