Skip to content

Add new attachment handler for opening attachments and viewing them in neovim #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

simonhughxyz
Copy link

@simonhughxyz simonhughxyz commented Mar 25, 2025

This PR adds two new attachment handlers to improve how attachments are opened and viewed:

open_handler: replaces the old open_cmd config option and is a callback function to open attachments externally. By default, it calls xdg-open, just like the old setup.

view_handler: a new config option which is a callback function for viewing attachments directly inside Vim. By default it runs a view-handler shell command, which you can customize.

This change makes it easier to handle attachments in different ways depending on the context, either externally or within Vim.

By making them callback function it gives users the option to handle opening or viewing attachment entirely within their lua config.

I included a example shell script in the readme for view-handler. All it needs to do is to convert the file to text.

This PR is a breaking change as it removes the old open_cmd!

Previously, attachments could only be opened externally using `xdg-open`.
This update adds an option to view attachments directly in a Neovim buffer,
allowing users to preview text-based attachments without leaving Neovim.

Attachments like plain text, markdown, and PDFs (if converted) can now
be displayed in a buffer
BREAKING CHANGE: The `open_cmd` config option has been renamed to `open_handler`
to align with the `view_handler` config option. It is now a callback function.

Users will need to update their configuration to use `open_handler` instead of `open_cmd`.
The README configuration options now show that the handler config
options are callback functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant