Commit graph

79 commits

Author SHA1 Message Date
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
cc69a9304b
fix(dashboard): restore showtabline/laststatus when entering another non-float window. Closes #1774 2025-10-21 16:16:33 +02:00
Folke Lemaitre
19ff343a16
style: format 2025-10-20 15:29:47 +02:00
Folke Lemaitre
fe88a07d53
feat(dashboard): optional filter for projects. Closes #798 2025-10-20 14:48:06 +02:00
Franck Delage
e9228d6b2f
fix(dashboard): replace deprecated AutoSession command (#2288)
## Description

The command `SessionRestore` from the auto-session plugin is deprecated.
Replaced it with `AutoSession restore`.
2025-10-20 13:24:04 +02:00
Folke Lemaitre
fcd309f9ea
fix(dashboard): oldfiles filter should return a boolean instead of the result of find. Fixes #2283 2025-10-19 23:01:57 +02:00
Copilot
1ed737e465
fix(dashboard): recent_files section not displaying files without cwd parameter (#2284)
## Problem

The `recent_files` section in the dashboard was not displaying any files
when called without a `cwd` parameter, which is the default usage in
most dashboard examples and documentation.

```lua
-- This would show an empty section after the bug was introduced
{ section = "recent_files", limit = 8 }
```

## Root Cause

When `opts.cwd` was not provided, the code set `root = ""` (empty
string) and passed it to the oldfiles filter:

```lua
local root = opts.cwd and svim.fs.normalize(...) or ""
for file in M.oldfiles({ filter = { [root] = true } }) do
```

The filter logic in `M.oldfiles` checks if a file path starts with the
filter path **AND** if the character immediately after that prefix is a
directory separator (`/` or `\`). With an empty string as the filter
path:

1. `file:sub(1, 0) == ""` is always `true`
2. But `file:sub(1, 1):find("[/\\]")` is `false` for most files (unless
they start with `/` or `\`)
3. This results in `matches = false`, causing all files to be filtered
out

## Solution

Changed the logic to use `nil` instead of an empty string when no `cwd`
is specified:

```lua
local root = opts.cwd and svim.fs.normalize(opts.cwd == true and vim.fn.getcwd() or opts.cwd) or nil
-- Only filter by directory when root is specified. If nil, M.oldfiles will use default filters only (excludes stdpath data/cache/state).
local oldfiles_opts = root and { filter = { [root] = true } } or nil
local ret = {} ---@type snacks.dashboard.Section
for file in M.oldfiles(oldfiles_opts) do
```

When no filter is passed, `M.oldfiles()` uses only its default filters
(excluding stdpath data/cache/state directories), which is the intended
behavior for showing all recent files.

## Testing

All usage scenarios now work correctly:

| Scenario | Code | Behavior |
|----------|------|----------|
| No cwd | `{ section = "recent_files" }` |  Shows all recent files
(except stdpath) |
| Current dir | `{ section = "recent_files", cwd = true }` |  Shows
files in cwd |
| Specific dir | `{ section = "recent_files", cwd = "/path" }` |  Shows
files in specified path |

## Impact

This is a minimal, surgical fix (4 lines changed) that restores the
expected behavior documented in all dashboard examples without affecting
any other functionality.

Fixes the issue where users reported empty recent_files sections after
updating to the latest version.

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>bug: dashboard does not display "recent_files"
section</issue_title>
> <issue_description>### Did you check docs and existing issues?
> 
> - [x] I have read all the snacks.nvim docs
> - [x] I have updated the plugin to the latest version before
submitting this issue
> - [x] I have searched the existing issues of snacks.nvim
> - [x] I have searched the existing issues of plugins related to this
issue
> 
> ### Neovim version (nvim -v)
> 
> 0.11 
> 
> ### Operating system/version
> 
> arch linux
> 
> ### Describe the bug
> 
> after updating, snacks.dashboard stopped displaying the "recent_files"
section.
> Looking through the commit history, I found that commit `5c4365e` is
relevant to that section. Upon rolling the plugin back to one commit
prior to it (commit `a4de830`), the section displayed as normal.
> 
> ### Steps To Reproduce
> 
> update to latest commit
> 
> ### Expected Behavior
> 
> section "recent files" displayed as per the documentations
> 
> ### Repro
> 
> ```lua
> vim.env.LAZY_STDPATH = ".repro"
> load(vim.fn.system("curl -s
https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
> 
> require("lazy.minit").repro({
>   spec = {
>     { "folke/snacks.nvim", opts = {} },
>     -- add any other plugins here
>   },
> })
> ```</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>

Fixes folke/snacks.nvim#2283

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: folke <292349+folke@users.noreply.github.com>
2025-10-19 22:17:03 +02:00
Folke Lemaitre
5c4365e993
fix(dashboard): recent cwd filter matching 2025-10-19 11:27:52 +02:00
Masayuki Izumi
057d4ab80e
fix(dashboard): fix path filtering for recent_files with cwd option (#2201)
## Description

Fix incorrect path filtering when using `recent_files` section with
`cwd`
option in dashboard.

Previously, when setting cwd to `/foo/bar/baz`, files from directories
with
the same prefix like `/foo/bar/bazbaz` were incorrectly included in the
recent
files list. This was due to simple string prefix matching without
considering
 directory boundaries.

The fix ensures proper directory boundary checking by verifying that the
path
either exactly matches the filter path or is followed by a "/"
character.

## Screenshots

```lua
return {
  "snacks.nvim",
  ---@type snacks.Config
  opts = {
    dashboard = {
      enabled = true,
      sections = {
        {
          title = "Recent Files " .. vim.uv.cwd(),
          section = "recent_files",
          cwd = true,
        },
      },
    },
  },
}
```

### before
<img width="659" height="149" alt="CleanShot 2025-09-24 at 00 00 13"
src="https://github.com/user-attachments/assets/943ad53f-11c5-49d2-b680-f032ad5fee94"
/>

### after
<img width="639" height="111" alt="CleanShot 2025-09-24 at 00 01 01"
src="https://github.com/user-attachments/assets/0dbde991-5164-4afa-9981-ae6707a8fcc0"
/>
2025-10-19 11:11:38 +02:00
Folke Lemaitre
24e92e0c94
fix(dashboard): use fqn for icon. Closes #1496 2025-10-19 11:07:53 +02:00
Folke Lemaitre
29682a0a72
fix(dashboard): update cursor on loading the dashboard. Closes #2004 2025-10-19 10:31:46 +02:00
Dmitriy Kovalenko
fc06234ce1
feat(picker): Support rmagatti/autosession session manager (#1825)
## Description

Supports this plugin for session restorations
https://github.com/rmagatti/auto-session

## 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-10-19 10:19:33 +02:00
François-Pierre Bouchard
83f364f833
fix(dashboard): set border = "none" on terminal sections (#1643)
## Description

Since 0.11, a new `vim.o.winborder` global option sets the borders for
all floating windows. Override this for terminal sections.
2025-10-19 10:16:50 +02:00
Folke Lemaitre
dc65ffd4f5
fix(dashboard): pcall chansend for dashoard terminal widgets 2025-09-27 09:39:06 +02:00
Folke Lemaitre
fb016d20c2
perf(dashboard): add basic OSC11 and CSI6n support to terminal sections (gh 10 seconds faster) 2025-09-17 20:39:44 +02:00
Folke Lemaitre
8b0e79ab4c
fix(dashboard): escape filenames for edit. Closes #1453 2025-02-27 08:36:29 +01:00
Folke Lemaitre
bc902f7032
feat(compat): added svim, a compatibility layer for Neovim. Closes #1321 2025-02-20 06:59:44 +01:00
Joshua Li
b91f417670
perf(dashboard): speed up filtering for recent_files (#1250)
## Description

I have 5000 oldfiles, every time i go to a new directory and open nvim,
the dashboard recent_files (with `cwd=true`) computation takes 4-5
seconds to go through all oldfiles before deciding nothing should show
up

```lua
sections = {
  { icon = " ", title = "Recent files (current directory)", section = "recent_files", cwd = true },
}
```

It appears to be the `vim.v.oldfiles[i]` indexing. I didn't look much
into it but it opens much faster looping with ipairs.

Repro:
1. add the above section config in dashboard
2. increase oldfiles limit and populate up to the limit
3. `mkdir brand-new-directory; cd brand-new-directory; nvim`
4. the section is empty as expected, but it takes a few seconds before
dashboard shows up

## 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-02-18 23:05:55 +01:00
Folke Lemaitre
c2f06daeca
fix(dashboard): use Snacks.util.icon for icons. Closes #1192 2025-02-15 12:27:37 +01:00
Folke Lemaitre
f36c70a912
fix(dashboard): dashboard can be a main editor window 2025-02-14 12:39:19 +01:00
Folke Lemaitre
e3ead3c648
fix(dashboard): allow dashboard to be the main editor window 2025-02-14 07:04:56 +01:00
Folke Lemaitre
5420a64b66
feat(dashboard): play nice with file explorer netrw replacement 2025-01-31 07:44:44 +01:00
Folke Lemaitre
558b0ee04d
fix(dashboard): update on VimResized and WinResized 2025-01-31 07:44:12 +01:00
Folke Lemaitre
2f396b341d
fix(dashboard): prevent starting picker twice when no session manager. Fixes #783
Some checks failed
CI / ci (push) Failing after 0s
2025-01-29 13:09:02 +01:00
soulsoiledit
5ff2ad320b
fix(dashboard): don't override user configuration (#774)
## Description

When `picker` is enabled, the original line removes it from the table
and reinserts it as the first element, preventing the user configuration
in `preset.picker` from being used as the picker. This change inserts it
as the second element instead.
2025-01-29 06:55:44 +01:00
Folke Lemaitre
6cb7fdfb03
fix(dashboard): better handling of closed dashboard win 2025-01-28 12:19:33 +01:00
Folke Lemaitre
d44b978d7d
fix(dashboard): fix dasdhboard when opening in a new win. Closes #767 2025-01-28 08:50:55 +01:00
Folke Lemaitre
32cd34383c
fix(dashboard): added optional filter for recent files 2025-01-20 12:14:54 +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
Jay Madden
d312053f78
fix(dashboard): hash dashboard terminal section caching key to support long commands (#381)
## Description

This change hashes the caching key for snacks dashboards terminal
sections instead of building the key from the command itself. This
allows for arbitrary length scripts to be given as a terminal section
command instead of relying on existing commands in PATH.

## Related Issue(s)

#379 

## Screenshots

<img width="1176" alt="image"
src="https://github.com/user-attachments/assets/77a376c1-75b6-4023-8984-efd590f66a68"
/>
2024-12-31 06:24:21 +01:00
Folke Lemaitre
dcc5338e6f
fix(dashboard): telescope can't be run from a vim.schedule for some reason 2024-12-15 07:54:47 +01:00
Folke Lemaitre
7c7b18fdee
fix(dashboard): set cursor to non-hidden actionable items. Fixes #273 2024-12-13 09:45:28 +01:00
SueXY
63506d5168
feat(dashboard): add dashboard startuptime icon option (#214)
## Description

Adds an `icon` option to the dashboard `startup` section. So people
(like me, who thinks an emoji in a bunch of nerdfonts is awkward) can
change it easily.

## Screenshots

<details>
<summary>Screenshots</summary>

Screenshot with a minimal config

![Snipaste_2024-12-07_22-08-42](https://github.com/user-attachments/assets/bf8c4754-3902-412d-83dc-f7efec77ee7f)

</details>

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2024-12-12 06:50:04 +01:00
pynappo
9c68a54af6
fix(dashboard): add filetype to terminal sections (#215)
The intention is to make it easier to exclude the dashboard terminal
from some plugins. For example, heirline.nvim sets winbar per-window to
allow for winbar to be optionally disabled in non-floating windows, so
this PR lets me disable heirline for snacks' dashboard terminals over
other floating terminals.
2024-12-11 22:35:56 +01:00
Folke Lemaitre
140204fde5 build: added metadata to plugins 2024-12-10 13:55:51 +01:00
Folke Lemaitre
47ad2a7bfa fix(dashboard): override foldmethod 2024-12-10 13:55:51 +01:00
Folke Lemaitre
0194f18cfa refactor: auto-gen plugin types 2024-12-10 13:55:51 +01:00
Iordanis Petkakis
6b78172864
fix(dashboard): don't open with startup option args (#222)
## Description
Don't open dashboard when Neovim opens with only startup option args.
Took a look at how `dashboard.nvim` did it.
They also have an autocmd for `StdInReadPre`, but I tested with piping
`echo "hello" | nvim` and it works as expected.

Not sure if it's the best solution, so feel free to make any additional
changes or completely disregard for something more robust.
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)
Closes #221.
<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->
2024-12-09 14:28:26 +01:00
Folke Lemaitre
736ce447e8
fix(dashboard): take hidden items into account when calculating padding. Fixes #194 2024-12-03 09:57:36 +01:00
Marcin
42d62775d8
feat(dashboard): make buffer not listed (#191)
## Description

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

Set the dashboard buffer to not listed for consistency with other
dashboard plugins

## 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. -->
2024-12-02 17:35:17 +01:00
Folke Lemaitre
cda695e53f
fix(dashboard): take indent into account when calculating terminal width 2024-12-02 16:59:27 +01:00
Folke Lemaitre
045a17da06
feat(dashboard): when a section has a title, use that for action and key. If not put it in the section. Fixes #189 2024-12-02 16:33:55 +01:00
Folke Lemaitre
6e3b9546de
fix(dashboard): calculate proper offset when item has no text 2024-12-02 16:27:36 +01:00
Folke Lemaitre
78f44f720b
feat(dashboard): allow terminal sections to have actions. Closes #189 2024-12-02 12:15:22 +01:00
Folke Lemaitre
d370be6d69
feat(dashboard): hide title if section has no items. Fixes #184 2024-12-01 21:52:01 +01:00
Folke Lemaitre
4bdf7daece
fix(dashboard): truncate file names when too long. Fixes #183 2024-12-01 19:56:44 +01:00
Folke Lemaitre
b99bc64ef9
feat(dashbard): explude files from stdpath data/cache/state in recent files and projects 2024-12-01 19:49:26 +01:00
Folke Lemaitre
93b254d658
fix(dashboard): prevent possible duplicate recent files. Fixes #171 2024-12-01 18:16:43 +01:00
Folke Lemaitre
7a47eb76df
feat(dashboard): allow items to be hidden, but still create the keymaps etc 2024-12-01 17:41:10 +01:00
Folke Lemaitre
8e6d977ec9
perf(dashboard): properly cleanup autocmds 2024-11-30 21:45:41 +01:00