-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
JSON files without .json extension show as "Binary cannot be previewed" #2221
Labels
bug
Something isn't working
Comments
kamalmarhubi
changed the title
JSON files without .json extension are not previewed with default configuration
JSON files without .json extension show as "Binary cannot be previewed"
Nov 5, 2022
5 tasks
Conni2461
pushed a commit
that referenced
this issue
May 14, 2023
Conni2461
pushed a commit
that referenced
this issue
May 14, 2023
abelmul
pushed a commit
to abelmul/telescope.nvim
that referenced
this issue
Jun 6, 2023
Hi, this issue is valid for more file types in general, not only
and maybe more. Maybe it would be best to consider, some type of user option where we can map the specific file types so they can at least render somehow/anyhow in the preview pane, instead of just showing Cheers! |
should be closed by #2567 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The default configuration will incorrectly show the
Binary cannot be previewed
message for a JSON file whose extension is notjson
.The mime-type check results in JSON being treated as non-text as its type is
application/json
, whose pre-slash element is nottext
. This happens here:telescope.nvim/lua/telescope/previewers/buffer_previewer.lua
Lines 194 to 196 in 4bd4205
Since the default has no
mime_hook
, theBinary cannot be previewed
message shows instead of the file contents.I came across this because I was opening a JSON
.lock
file, and was surprised not to see the preview. There are a few ecosystems that have.lock
files that are JSON. Some examples: NPM'spackage-lock.json
, Nix'sflake.lock
, pipenv'sPipfile.lock
among others.Not sure if the solution should be a hard-coded list of known-to-be-text mime types, a configuration option, or a combination. Requiring users to add a
mime_hook
just for this is pretty annoying, but I suppose that's also a solution!Neovim version
Operating system and version
macOS 12.4
Telescope version / branch / rev
master (4bd4205)
checkhealth telescope
Steps to reproduce
echo '{"testJson":"content"}' > example.notjson
:Telescope find_files
example.notjson
Expected behavior
Content of file is shown in preview.
Actual behavior
No preview, instead the
Binary cannot be previewed
message.Minimal config
The text was updated successfully, but these errors were encountered: