-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add Premake language definition #7686
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
base: main
Are you sure you want to change the base?
Conversation
|
In my projects, as in many others, GitHub's language statistics give the impression that a significant portion of the code is written in Lua, especially if the project has multiple premake-files, when in fact these are just premake files. This PR helps distinguish premakes from regular Lua. |
|
I'm don't think this should be pulled out into it's own entry as Premake appears to be a build system, like Bazel, that is written in Lua and not it's own language. We don't have a specific entry for Bazel as it's not a language. Instead it is included in Starlark which is the language Bazel uses. Build systems are essentially like a framework written in another language. We don't add support for frameworks as that's not the language, hence we don't have support for React or Rails or Phoenix or any other framework. |
|
Hey @lildude, thanks a lot for the quick review! I totally understand the reasoning about build systems vs languages — Bazel → buildSystem, CMake → buildSystem, C++ → Lang, etc. One important distinction: frameworks like React, Rails, or Phoenix are libraries used inside an existing language. Premake is not a library — it is a DSL-based build configuration system with a canonical filename, just like CMake, Meson, and Ninja. Premake is a bit of a special case, and that’s why I opened this PR: 1. Filename-based, not extension-basedPremake files are always named exactly premake5.lua or premake4.lua (never .premake, never arbitrary filenames). 2. CMake has been a separate language since 2012CMake is also “just a build system with its own DSL”, yet it has its own entry, color, 3. Massive distortion of statistics
This is exactly the same statistical problem that the CMake entry solved years ago. 4. Zero riskThe heuristic is extremely strict (matching top-level Premake-specific keywords like workspace, project, kind, cppdialect, include, etc.) and only applies to the two canonical filenames. 5. Avoiding misleading interpretationsLua appearing in statistics makes some users assume the project requires an embedded Lua runtime or that part of its logic is written in Lua, which is not the case. Additionally, one of Linguist’s core principles is to avoid skewed language statistics. This is literally the same precedent as CMake — just 13 years later. I’d be happy to adjust anything needed, but I believe this fits very cleanly into Linguist’s existing policy for configuration-oriented DSLs with canonical filenames. Thanks again for considering! |
lildude
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your detailed supporting explanation for this which makes sense to me.
Along with my inline comments, we need a real-world sample for every filename added. Please add a sample for each and update the PR template to state where they come from (not your fork of linguist 😉) and the licence of each sample.
lib/linguist/heuristics.yml
Outdated
| - language: OASv3-yaml | ||
| pattern: 'openapi:\s?''?"?3.[0-9.]+''?"?' | ||
| - language: YAML | ||
| - extensions: ['.lua'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not adding an extension as part of your new entry so this heuristic is not needed as it'll never be used. Please remove it.
lib/linguist/languages.yml
Outdated
| filenames: | ||
| - premake5.lua | ||
| - premake4.lua | ||
| interpreters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is for what is likely to occur in shebangs. Your search results indicate these files never have a shebang so we don't need this section.
|
Thank you @lildude! I've made all the necessary edits:
Ready for review! |
|
Hey @lildude, just wanted to check if there’s anything else needed from my side to get this PR merged? All requested edits have been applied and real-world samples added. Thanks! |
lildude
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have included a real-world usage sample for all extensions added in this PR:
You need to actually include the files in the PR, not the PR template, as they're used to train the classifier. We need at least one per filename being added with the template updated to link to each source (not your fork of linguist) with the license for each stated. The samples also need to be real-world examples so sourcing from the docs generally isn't a good indicator of real-world usage.
You'll also need to update the grammars README so that it reports the source of the grammar. The command to run is shown when you run the tests so I've approved CI to run on this PR.
|
Hey @lildude, I think I've made all the required changes. |
|
You've not resolved the ordering test failure. |
|
I hope I fixed it now? |
Nope. The entry needs to be in alphabetic order. |
|
It's in alphabetical order, isn't it? |
|
Look again, when you looked there, the commits were mixed up (and first five commits ended up at the top in reverse order and broke everything). It should be correct now. |
|
Ready for review! I've removed |
It's not. If you run the tests you'll see it'll still fail. The section needs to go after Praat. |
Add Premake as a separate language (premake5.lua)
Description
Premake is a quite popular Lua-based build configuration tool used extensively in the C++ community.
Currently premake5.lua files are classified as generic Lua, which significantly distorts language statistics for many repositories.
This PR adds Premake as a distinct language with its canonical filenames, official brand color, and a heuristic.
Example of a notable project using Premake:
Official links:
Repository: https://github.com/premake/premake-core
Website: https://premake.github.io/
Real World examples:
Source: https://github.com/TheCherno/glfw/blob/9bed794ab7c1b961aaca259403695bbd3870d3b3/premake5.lua
License: zlib/libpng (GLFW)
Checklist:
I am adding a new language.
The extension of the new language is used in hundreds of repositories on GitHub.com.
Search results for each extension:
I have included a real-world usage sample for all extensions added in this PR:
premake5.lua:
I have added a color
Hex value: #e67e22
Rationale: one of Premake's Official Brand Colors, used in the logo
I have updated the heuristics to distinguish my language from others using the same extension.