linguist icon indicating copy to clipboard operation
linguist copied to clipboard

Add BIRD2 language

Open Alice39s opened this issue 4 months ago • 9 comments

Summary

This PR introduces syntax highlighting support for the BIRD2 configuration language via .conf files used by the BIRD Internet Routing Daemon.

Unlike simpler configuration models (e.g., INI or Nginx), BIRD employs a uniquely intricate paradigm with distinct implementation challenges. We address this by adding a textmate grammar with precise scoping for:

  • Protocol definitions
  • Filter functions
  • Route maps
  • Other core BIRD2 constructs

Motivation

BIRD2 powers critical Internet infrastructure at scale, including:

  • AMS-IX – 870+ ASNs, 14Tb/s traffic (ref)
  • LINX – 1,000+ BGP sessions on v2.13 (ref)
  • Cloudflare – Anycast routing across all edge PoPs (ref)

Despite its critical role in major Internet infrastructure, editors like VSCode and Shiki lack native grammar support for BIRD2 configurations. This PR aims to fill that gap.

References

License

Checklist:

  • [x] I am adding a new language.
    • [x] The extension of the new language is used in hundreds of repositories on GitHub.com.

      • Search results for each extension:
        • Public code rearch results -- 27k+ BIRD2 configuration snippets found in public repositories
        • Public repo rearch results -- 883+ active repositories using BIRD configurations
        • bird.conf: 1.3k+ https://github.com/search?q=path%3Abird.conf&type=code
        • bird6.conf: 275+ https://github.com/search?q=path%3Abird6.conf&type=code
        • bird2.conf: 149+ https://github.com/search?q=path%3Abird2.conf&type=code
    • [x] I have included a real-world usage sample for all extensions added in this PR:

      • Sample source:
        • https://github.com/bird-chinese-community/BIRD-tm-language-grammar/blob/main/sample/
      • Sample license: MIT License
    • [x] I have included a syntax highlighting grammar: https://github.com/bird-chinese-community/BIRD-tm-language-grammar/blob/main/Syntaxes/bird2.tmLanguage.json

    • [x] I have added a color

    • [x] I have updated the heuristics to distinguish my language from others using the same extension.

Alice39s avatar Aug 02 '25 20:08 Alice39s

You're right — thanks for pointing that out.

I ran script/add-grammar and didn’t realize it would remove those entries automatically. That wasn’t my intention, and I’d be happy to fix it — though I’m not entirely sure what the best way is to restore them manually.

If you could point me in the right direction, I’d really appreciate it 🙏!

Apologies again for the unintended change.

Alice39s avatar Aug 04 '25 06:08 Alice39s

The easiest would be to revert your previous commit and then re-apply just your changes.

lildude avatar Aug 04 '25 08:08 lildude

Hi @lildude 👋

Gentle ping on this — updates done per your feedback (extensions & licenses) - Could you take a look when you have a moment?

Thanks for your time!

Alice39s avatar Aug 06 '25 22:08 Alice39s

Samples can not be in subdirectories. Please move them to a level.

Please also update the PR template to provide individual links to the search results for each of the filenames you're adding and fix the information about the samples' sources and licences.

@lildude Thanks for the feedback and detailed explanation!

I've made the following changes based on your suggestions:

  1. I've moved all the sample configuration files from subdirectories to the top level. They are now all located in the samples/BIRD2 directory.
  2. I've updated the PR template to provide individual search result links for each new filename.
  3. I've corrected the information regarding the samples' sources and licenses.

Please take another look, and let me know if there are any further changes required.

Alice39s avatar Aug 15 '25 16:08 Alice39s

Hi @lildude, could you take a look at this when you have a chance? 🙂

Updates are in place, and I really appreciate your help!

Alice39s avatar Aug 21 '25 17:08 Alice39s

Hi @lildude 👋

Hope you’re doing well! Just wanted to gently follow up on this PR when you have a moment. I believe all the requested changes have been addressed, and it’s currently awaiting your review.

Please let me know if there’s anything else you’d like me to adjust. Really appreciate your time and guidance on this!

Thanks in advance 🙏

Alice39s avatar Sep 03 '25 20:09 Alice39s

The test failure is because samples/BIRD2/bird.conf is in the wrong place. It needs to be at samples/BIRD2/filenames/bird.conf

Thanks for catching that! 🙏 I've moved the sample config to samples/BIRD2/filenames/bird.conf as suggested.

Please let me know if there’s anything else you'd like me to adjust.

Alice39s avatar Sep 09 '25 17:09 Alice39s

a bunch of the regexes have extra erroneous backslashes https://github.com/bird-chinese-community/BIRD-tm-language-grammar/blob/c39653d00f6337f9fe4ba9c75f403c29dbec3907/grammars/bird2.tmLanguage.json#L558

image

RedCMD avatar Sep 23 '25 04:09 RedCMD

a bunch of the regexes have extra erroneous backslashes

https://github.com/bird-chinese-community/BIRD-tm-language-grammar/blob/c39653d00f6337f9fe4ba9c75f403c29dbec3907/grammars/bird2.tmLanguage.json#L558

image

Hi, I I’ve just fixed the issue in the repo.

pppwaw avatar Sep 25 '25 16:09 pppwaw