Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update languages.yml #6968

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update languages.yml #6968

wants to merge 1 commit into from

Conversation

JW0914
Copy link

@JW0914 JW0914 commented Jul 25, 2024

Added INI syntax highlighting for config file extensions *.conf and *.ovpn:

  • Some programs (like OpenVPN) use .conf instead of .cnf for config files
  • OpenVPN client .ovpn files are INI config files

Description

Checklist:

  • I am adding a new extension to a language.
    • The new extension is used in hundreds of repositories on GitHub.com
    • I have included a real-world usage sample for all extensions added in this PR:
    • I have included a change to the heuristics to distinguish my language from others using the same extension.

Added INI syntax highlighting for config file extensions *.conf and *.ovpn:
  - Some programs (like OpenVPN) use .conf instead of .cnf for config files
  - OpenVPN client .ovpn files are INI config files
@JW0914 JW0914 requested a review from a team as a code owner July 25, 2024 03:01
@DecimalTurn
Copy link
Contributor

DecimalTurn commented Jul 25, 2024

It seems like the syntax of a lot of OpenVPN's files in the search queries (and the samples) you provided aren't compatible with the current syntax highlighting for INI files.

The current syntax expects an equal sign (=) between the key and the value, but most of the OpenVPN's .conf files seem to use a space instead, hence the syntax highlighting doesn't really work:

server {{OVPN_NETWORK}} {{OVPN_SUBNET}}
verb 3

pkcs12 {{OVPN_CERTS}}
dh {{OVPN_DH}}

key-direction 0
keepalive 10 60
persist-key
persist-tun

proto {{OVPN_PROTO}}
port 1194
dev tun0
status /tmp/openvpn-status.log

user nobody
group nogroup

{{MORE_OPTS}}

push "route {{OVPN_K8S_SERVICE_NETWORK}} {{OVPN_K8S_SERVICE_SUBNET}}"
{{POD_CONF}}
push "dhcp-option DOMAIN {{OVPN_K8S_DOMAIN}}"
push "dhcp-option DNS {{OVPN_K8S_DNS}}"

(sample source)

However a lot of .conf file seem to be using the INI format that linguist uses, so maybe I'd suggest to add a heuristic taking into account that the file needs to have at least one well specified key followed by an equal sign to be considered an INI file (some thing like ^[\w_]*\s?=).

This still gives 5K files, but if we drop the "OPENVPN" search term we even get 631K files.

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is not complete. Please follow the CONTRIBUTING.md file for adding extensions and update the title of the PR.

You're going to need to add .conf as a generic extension (also add to generic.yml) with a very precise heuristic (there is no scope for error) as it is such a generic and common extension used by many languages which don't use the INI format. Some use their own language, some use JSON, some use XML etc. This is a potential minefield 😁

@JW0914
Copy link
Author

JW0914 commented Jul 28, 2024

@DecimalTurn and @lildude will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants