Commit graph

8 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
774bf9d8c8
fix(util): only use mini.icons if it has been setup. Closes #2199 2025-10-20 17:53:11 +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
Alexander Siryk
32e5bf1730
fix(util): fix invalid window error (#1996)
## Description

Add check if win id is valid to prevent errors when opening buffers
using Harpoon, or Diffview.

## Related Issue(s)

- Fixes #1968

## Screenshots

<img width="1391" alt="image"
src="https://github.com/user-attachments/assets/daa8cbd1-7104-4c5d-8cae-d50a900b6c76"
/>

<img width="1690" alt="image"
src="https://github.com/user-attachments/assets/6dd9cae6-fc3f-4a5e-b5ae-6fc1e4afeeca"
/>
2025-09-17 08:23:19 +02:00
Folke Lemaitre
9f0aa20489
feat(util): small ts parse wrapper that parses async when available 2025-03-01 07:53:55 +01:00
Folke Lemaitre
e2cb9df7d0
feat(util): util method to check if ts lang is available on any Neovim version. See #1422 2025-02-25 15:25:48 +01:00
Folke Lemaitre
b65178b470
feat(image): show progress indicator when converting image files 2025-02-17 23:56:55 +01:00
Folke Lemaitre
a76fe13148
feat(util): util.spawn 2025-02-17 23:12:54 +01:00
Renamed from lua/snacks/util.lua (Browse further)