scopatz / nanorc

Improved Nano Syntax Highlighting Files
Other
3.05k stars 556 forks source link

[yaml] Syntax highlighting hardly works #168

Closed yochem closed 6 years ago

yochem commented 6 years ago

First of all, thanks for all the work you put in these rc files!

OS: Mac Nano: 2.9.5 (brew) Terminal: Hyper

When i tried using the yaml.nanorc file, it worked only partly (only the whitespaces aka the last 2) Here is a screenshot of a yaml file with the current rc file:

Current file

I created my own yaml rc file. The colors are inspired on the Atom One Dark theme.

Own file

Let me know what you think!

yochem commented 6 years ago

yaml.nanorc:

syntax yaml "\.ya?ml"
comment "#"
header "^---" "%YAML"

# Values
color green "(:|^|\s)+\S+"

# Keys
color red "(^|\s+).*+\s*:(\s|$)"

# Special values
color yellow "[:-]\s+(true|false|null)\s*$"
color yellow "[:-]\s+[0-9]+\.?[0-9]*(\s*($|#))"
color yellow  "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "

# Separator
color brightwhite "^\s+-"
color brightwhite ":(\s|\t|$)"

# Comments
color white "(^|[[:space:]])#.*$"
scopatz commented 6 years ago

Thanks! I think that looks a lot better. Please feel free to put in a PR with that change. Let me know if you need help

yochem commented 6 years ago

Sure! Is there any style format to which I must comply?

scopatz commented 6 years ago

Thanks a ton!

jc-iacono commented 6 years ago

Hi there, there may be a typo in the first 2 lines !

Line1 -syntax yaml ".ya?ml" +syntax "yaml" ".ya?ml"

Line 2 might be to be removed -comment "#"

(Or maybe I misunderstood, tell me if it's the case)

Thank you ! :)

scopatz commented 6 years ago

A PR with a fix would be great!

yochem commented 6 years ago

Line1 -syntax yaml ".ya?ml" +syntax "yaml" ".ya?ml"

It's working fine on my computer, but it's indeed better to wrap yaml with quotes.

Line 2 might be to be removed -comment "#"

The comment line enables the option to type M-3 for commenting a line out. From the man-page: """

comment "string"

Use the given string for commenting and uncommenting lines. If the string contains a vertical bar or pipe character (|), this designates bracket-style comments; for example, "/|/" for CSS files. The characters before the pipe are prepended to the line and the characters after the pipe are appended at the end of the line. If no pipe character is present, the full string is prepended; for example, "#" for Python files. If empty double quotes are specified, the comment/uncomment function is disabled; for example, "" for JSON. The default value is "#". """" It's a future I use a lot, so that's why I added it to the nanorc file.

yochem commented 6 years ago

@jc-iacono I fixed the syntax yaml part in PR #170

DDifDEVzero commented 6 years ago

hello scopatz

from a fresh install debian here is the output when start nano (in german):

Fehler in yaml.nanorc in Zeile 2: Befehl „comment“ nicht verstanden

Fehler in yaml.nanorc in Zeile 17: Farbe „normal“ nicht verstanden. Gültige Farben sind „green“ (grün), „red“ (rot), „blue“ (blau), „white“ (weiß), „yellow“ (gelb), „cyan“ (zyanblau), „magenta“ (magentarot) und „black“ (schwarz), mit dem optionalen Präfix „bright“ (hell) für Vordergrundfarben.

Fehler in yaml.nanorc in Zeile 18: Farbe „normal“ nicht verstanden. Gültige Farben sind „green“ (grün), „red“ (rot), „blue“ (blau), „white“ (weiß), „yellow“ (gelb), „cyan“ (zyanblau), „magenta“ (magentarot) und „black“ (schwarz), mit dem optionalen Präfix „bright“ (hell) für Vordergrundfarben.

Drücken Sie die Eingabetaste, um mit dem Starten von nano fortzufahren.

the original code look this:

syntax "yaml" "\.ya?ml"
comment "#"
header "^---" "%YAML"

# Values
color green "(:|^|\s)+\S+"

# Keys
color red "(^|\s+).*+\s*:(\s|$)"

# Special values
color yellow "[:-]\s+(true|false|null)\s*$"
color yellow "[:-]\s+[0-9]+\.?[0-9]*(\s*($|#))"
color yellow  "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "

# Separator
color normal "^\s+-"
color normal ":(\s|\t|$)"

# Comments
color white "(^|[[:space:]])#.*$"

edit yaml.nanorc worked now:

syntax "yaml" "\.ya?ml$"
header "^---" "%YAML"

# Values
color green "(:|^|\s)+\S+"

# Keys
color red "(^|\s+).*+\s*:(\s|$)"

# Special values
color yellow "[:-]\s+(true|false|null)\s*$"
color yellow "[:-]\s+[0-9]+\.?[0-9]*(\s*($|#))"
color yellow "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "

# Separator
color brightwhite "^\s+-"
color brightwhite ":(\s|\t|$)"

# Comments
color white "(^|[[:space:]])#.*$"

i delete the line commnet "#" and change normal to brightwhite in the # Seperator area

please fix it

thank you very much !!

yochem commented 6 years ago

hhm, what version are you using?

DDifDEVzero commented 6 years ago

hello,

I used debian 9.4

Yochem van Rosmalen notifications@github.com schrieb am Sa., 5. Mai 2018, 21:37:

hhm, what version are you using?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scopatz/nanorc/issues/168#issuecomment-386829686, or mute the thread https://github.com/notifications/unsubscribe-auth/AlM-0EeAbYjEdBeqr5ITD5GgDjcYpqh-ks5tvf93gaJpZM4Tueo8 .

DDifDEVzero commented 6 years ago

The Error say he is not recognized the color by name 'normal' only 'brightwhite'

Markus Krawanja krawanja.markus@gmail.com schrieb am Sa., 5. Mai 2018, 21:44:

hello,

I used debian 9.4

Yochem van Rosmalen notifications@github.com schrieb am Sa., 5. Mai 2018, 21:37:

hhm, what version are you using?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scopatz/nanorc/issues/168#issuecomment-386829686, or mute the thread https://github.com/notifications/unsubscribe-auth/AlM-0EeAbYjEdBeqr5ITD5GgDjcYpqh-ks5tvf93gaJpZM4Tueo8 .

scopatz commented 6 years ago

Please feel free to put in a PR that fixes this issue!

yochem commented 6 years ago

Fixed in PR #171