-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use scratch buffer for file previews (#467)
* Initial implementation of scratch based preview * Fix call to buf is valid in loop * Fixing call to be made only from the main event loop * Improve handling of large files from @pkazmier * Better error handling and simplifying the code * Default to old behavior * Add documentation * Fix readfile * Fix the configuration * refactor: single config enum and load real buffer on BufEnter * doc: regenerate documentation --------- Co-authored-by: Steven Arcangeli <[email protected]>
- Loading branch information
1 parent
8ea40b5
commit 21705a1
Showing
5 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21705a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems after this commit,the preview of image that use image.nvim does not work anymore
21705a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps try changing the value of
preview_method
in your config toload
orscratch
? The default offast_scratch
does not load the whole file for efficiency purposes.21705a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right,changing the
preview_method
toload
fix the problem.21705a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the image.nvim preview issue when
preview_method="scratch"
, but this now means that a large image can freeze the UI again even whenpreview_method="scratch"
. To combat this, I've added another config option that will allow you to define a function to determine if previews should be enabled for a specific file. If you find that images are lagging, you can disable previews on them or you can check their size and disable previews for large images.21705a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works well.