ranger / ranger

A VIM-inspired filemanager for the console
https://ranger.fm
GNU General Public License v3.0
15.68k stars 890 forks source link

some source code files aren't being previewed #3007

Open 4rtemis-4rrow opened 2 months ago

4rtemis-4rrow commented 2 months ago

Runtime Environment

⮚ \ranger --version
ranger version: ranger-master
Python version: 3.12.5 (main, Aug  9 2024, 08:20:41) [GCC 14.2.1 20240805]
Locale: en_US.UTF-8

Current Behavior

when hovering over source code files, in some cases it displays the actual source code in the preview pane, in other cases, it displays "----- File Type Classification -----\nJavaScript source, Unicode text, UTF-8 text", even if both files are the same type, even if none are javascript

Steps to reproduce

no idea why it's happening to begin with, I'm using bat for the preview, and my dotfiles can be found it github.com/4rtemis-4rrow/dotfiles

4rtemis-4rrow commented 2 months ago

this is intresting

⮚ xdg-mime query filetype autopairs.lua
text/plain
⮚ xdg-mime query filetype dashboard.lua
application/javascript

seems like it isn't an issue with ranger, anyone knows what might have caused this?

vejkse commented 2 months ago

I don’t know why it happen, but a solution is to add | */javascript in your scope.sh, in the handle_mime function, in the first line of the ## Text section.

BeniaminK commented 1 month ago

The scope.sh uses the file to detect the mime-type of a file and it happens to me as well for lua files. When I changed to xdg-mime the problem has been resolved for all my lua files (xdg-mime version is xdg-mime 1.1.3).

909oce commented 1 month ago

my init.lua file for nvim is showing "Javascript source, ASCII text", however querying it with xdg-mime shows it as text/x-lua, so i dont think it has to do with xdg-mime