Search code examples
syntax-highlightingnano

Nano on server ignores certain syntax coloring


I'm using nano on a server via ssh; on that system, nano doesn't have syntax color enabled by default. So I copied these nanosyntax files (for alternative, see also @CraigBarnes' answer) on the server, and had set up ~/.nanorc as:

include "~/nanosyntax/syntax-nanorc/php.nanorc"
include "~/nanosyntax/syntax-nanorc/php2.nanorc"
include "~/nanosyntax/syntax-nanorc/sh.nanorc"
include "~/nanosyntax/syntax-nanorc/python.nanorc"
include "~/nanosyntax/syntax-nanorc/html.nanorc"
include "~/nanosyntax/syntax-nanorc/perl.nanorc"
include "~/nanosyntax/syntax-nanorc/ruby.nanorc"
include "~/nanosyntax/syntax-nanorc/js.nanorc"

Now, this is the thing; if I just call:

nano somefile.php

... no php syntax coloring is done. If I try to force:

nano --syntax=php somefile.php

... still no syntax coloring (shown as plain text). However, if I do:

nano ~/.nanorc

... then I do get syntax coloring (that corresponds to .nanorc type file) ?!

So obviously, syntax coloring as such works (i.e. shell and nano are capable of it) - except, it seems to be ignored for some languages, like in this case php ?!

So, does anyone know what is going on - and how could I get syntax coloring also for php files?

Thanks,
Cheers!


Solution

  • I just ran into the same problem, and I fiddled around a bit with the includes to find the error. Surprisingly, turns out that changing the inclusion order fixed the issue:

    This works:

    include "~/.nano/nanorc.nanorc"
    include "~/.nano/sh.nanorc"
    # more includes...
    

    This fails to highlight sh files:

    include "~/.nano/sh.nanorc"
    include "~/.nano/nanorc.nanorc"
    # more includes...
    

    So I guess it's probably a bug (in nano 2.2.2; worked fine in nano 2.1.7)