Generic Lexer Missing for rc/conf/config Files

All questions regarding lexer highlighting schemes are discussed here...
Random Void User
Posts: 104
Joined: 13.07.2024 21:19

Re: Generic Lexer Missing for rc/conf/config Files

Post by Random Void User »

Free Pascal has "fppkg.cfg" so an update:

Code: Select all

"files": "*rc;conf;*.conf;config;*.config;cfg;*.cfg"
main Alexey
Posts: 2931
Joined: 25.08.2021 18:15

Re: Generic Lexer Missing for rc/conf/config Files

Post by main Alexey »

- '*rc' works? i am not sure. ie I call the LCL for this mathching and I don't know how it works. maybe it will.
- '*rc' is not ok because 'rc' may be the tail of file extension
- for the case of fppkg.cfg - better to add this case to "detect" option (described in the wiki).
Random Void User
Posts: 104
Joined: 13.07.2024 21:19

Re: Generic Lexer Missing for rc/conf/config Files

Post by Random Void User »

- '*rc' works?
Yes, try shellcheckrc for example.
- '*rc' is not ok because 'rc' may be...
Comprehensive file extension lists I found online show no problems. Also, Cud still lexes "~/.bashrc" and "~/.zshrc" correctly as shell script. So those present no conflict. Bash and zsh have just a few confs anyway, so a "detect" stanza could handle them.

Maybe transpose dot and asterisk to compromise? A new pattern

Code: Select all

.*rc
would catch .netrc or .wgetrc while missing shellcheckrc and most.rc. Yet it's vastly more common than dot-suffix

Code: Select all

*.rc
on *nix and macOS. On Windows, the .rc suffix means resource definition script which has its own Cud lexer.

So avoiding that dot-suffix pattern may be more correct. The compromise pattern

Code: Select all

.*rc
covers most cases on *nix and macOS. A "hidden file" ending in "rc" is always a configuration file.
- for the case of fppkg.cfg - better to add this case to "detect" option (described in the wiki).
No, because this pattern is not specific to Free Pascal. Windows uses *.cfg a lot. Linux programs use it too, if not commonly. Java apps may have a "jvm.cfg" file. The suffix can only mean "configuration" anyway, no matter the platform.

So my new recommendation is

Code: Select all

"files": ".*rc;conf;*.conf;config;*.config;cfg;*.cfg"
Leaving "shellcheckrc" and "most.rc" TBD. I just tested "detect" lines for them without success. So, outliers need more thought, but that makes sense, since their names are non-standard for their category.

Why does the lexer show as "Config-rc ^" (with caret) in dialogs, not just "Config-rc"? I tried all lexer name variations to "detect" shellcheckrc but nothing worked. And the name should be "Config-RC" as RC was technically an acronym (Run Control, I think).

Thanks!
main Alexey
Posts: 2931
Joined: 25.08.2021 18:15

Re: Generic Lexer Missing for rc/conf/config Files

Post by main Alexey »

applied the suggested filemask.
renamed the lexer to Config-RC.

why lexer shows ' ^' in its name? read the wiki topic 'Lite lexers' please.
Random Void User
Posts: 104
Joined: 13.07.2024 21:19

Re: Generic Lexer Missing for rc/conf/config Files

Post by Random Void User »

Read, thanks.
Lite_lexers

I did a home-made .zip install of Config-RC. I will continue testing. Mainly I want to deal with outliers, most.rc, wego.rc, and shellcheckrc, probably with some variation of "detect" if it can work.

I can report on the Config-RC lexer with .wgetrc file. The line

Code: Select all

limit-rate = 7M
applies two colors to the right-hand value, one for numeral 7, another for unit M. Readability needs a common color for both.

Thanks!
main Alexey
Posts: 2931
Joined: 25.08.2021 18:15

Re: Generic Lexer Missing for rc/conf/config Files

Post by main Alexey »

7M hilite is easy to change. add the \\b (word boundary) regex specifier to the end of rule.
changed.
sync with my file:
https://github.com/Alexey-T/CudaText/bl ... -litelexer
Random Void User
Posts: 104
Joined: 13.07.2024 21:19

Re: Generic Lexer Missing for rc/conf/config Files

Post by Random Void User »

Hmm well I'd still like it colored as a number, including the M which is just a unit. The whole field is basically a number.

Anyway tweaking can go on, but maybe you could link our discussion here at an open issue in micro on this topic.

Thanks very much for the latest Cud release and frequent releases in general!
main Alexey
Posts: 2931
Joined: 25.08.2021 18:15

Re: Generic Lexer Missing for rc/conf/config Files

Post by main Alexey »

'M' and 'K' suffix, added it to the rule in lexer:
https://github.com/Alexey-T/CudaText/co ... 550db6c0c5
Post Reply