nnn doesn't obey NNN_USE_EDITOR
Hi everyone, I'm sort of new to contributing to projects like these so sorry if I missed something, but, I'm having some problems with getting my files to open in the correct editor.
My problem is that even when NNN_USE_EDITOR is set to 1 (I tried set -Ux NNN_USE_EDITOR 1 in fish and export NNN_USE_EDITOR=1 in bash) some files still use open. Specifically .cpp, .md and other files have no problem opening in $EDITOR (vim) but when trying to open a .js file it opens in Sublime Text (My default GUI editor).
I tried using the file command to investigate but both .md and .js files return the same thing. (index.js: text/plain; charset=us-ascii).
Any help with this would be appreciated.
OS: macOS 10.14
Shell: fish
nnn version: 2.0 installed from homebrew
What is the output of file -bi filename.js?
I have added js to the mix.
Looking at commit 0a8970a, it seems that you just added it so a list of file types. Maybe a more future proof option could be allowing the user to define what extensions should count as text.
I left a question before the commit. What do you see?
The logic is here: https://github.com/jarun/nnn/blob/v2.1/src/nnn.c#L2607-L2626
We don't want to add a config file for what's detected properly in most cases. What would you do differently?
You redacted this:
I'm not sure if this is still useful but the output is regular file.
That's why it's not detected correctly. What is the output of file -bi for md and cpp?
Sorry, I redacted it because I didn't think that it would be very useful. The output for both .cpp and .md files is still regular file.
Re: config file, I'm not sure, I guess you're right as it would be duplicating functionality already in file.
Can you check if omitting -b helps?
I am trying to figure out how you got:
I tried using the file command to investigate but both .md and .js files return the same thing. (index.js: text/plain; charset=us-ascii).
Did you try just file index.js?
I used file -I to get the MIME type.
Great! Does file -bI filename show the mime as text/.... Please tech with different file types to confirm this.
If it does, I will pass different args for Linux and OS X and it would be the correct fix.
I have made the change to pass -I at 8aa72a40a3021508888441b60dd6f324eefe76ee. Thanks for providing all the info.
Please test it out!
Removed JS from mime list at d8df13f665b035cad0cceee48f388f4a9b03b9f2.
I just built and tested it and it works great! Thanks for taking the time to fix this.
No problem! Have fun!
BTW, I don't own a Mac and occasionally I need someone to help me out with insights for any issue reported on Mac.
Would you be interested in joining the project as a collaborator?
Hello! I believe I'm having the same issue in linux with application/json; charset=us-ascii type files, with or without the .json extension.
I'm using nnn-git from the arch user repository.
What is the output of file json_file?
package.json: JSON data
Sorry, if on Mac, try: file -bI json_file, else file -bi json_file.
If it still shows the same, the program is behaving correctly. We look for the pattern text/. E.g.:
text/x-c; charset=utf-8
Thanks, I'm actually on linux. Here's the output of those commands.
file -bI package.json
file: invalid option -- 'I'
Usage: file [-bcCdEhikLlNnprsvzZ0] [--apple] [--extension] [--mime-encoding]
[--mime-type] [-e <testname>] [-F <separator>] [-f <namefile>]
[-m <magicfiles>] [-P <parameter=value>] <file> ...
file -C [-m <magicfiles>]
file [--help]
file -bi package.json
application/json; charset=us-ascii
file -v
file-5.35
magic file from /usr/share/file/misc/magic