Skip to content

Comments

Add grammar for Gemfile.lock files#5266

Merged
lildude merged 7 commits intogithub-linguist:masterfrom
hmarr:gemfile-lock-grammar
Mar 15, 2021
Merged

Add grammar for Gemfile.lock files#5266
lildude merged 7 commits intogithub-linguist:masterfrom
hmarr:gemfile-lock-grammar

Conversation

@hmarr
Copy link

@hmarr hmarr commented Mar 9, 2021

Description

I noticed that Gemfile.lock files are currently treated as Ruby code (which they're not), which means the syntax highlighting isn't right. Here's an example.

Given the prevalence of Gemfile.lock files (GitHub search reports > 1M) I thought it'd be worth fixing. This PR adds a TextMate grammar for Gemfile.lock files so we can highlight them correctly.

I see this has been discussed previously, but that issue went stale and was closed. If you'd rather not include a grammar for a generated file format, no hard feelings! But in that case it'd be good to remove Gemfile.lock from the file types classed as Ruby, and fix the misclassification problem described in the issue I linked 😄

Right now this grammar is in its own repo as that was the path of least resistance. However I'd be more than happy to contribute it to atom/language-ruby if that'd be a better place for it.

Checklist:

hmarr added 2 commits March 9, 2021 15:43
Before this change they were treated as Ruby files, which means the
highlighting was incorrect as Gemfile.lock files have a custom format.
@hmarr hmarr requested a review from a team as a code owner March 9, 2021 21:31
@hmarr
Copy link
Author

hmarr commented Mar 9, 2021

I'm not sure what to do about this test failure:

Ruby Gemfile.lock has a sample with extension (.lock) that isn't explicitly defined in languages.yml

Adding .lock to extensions in the languages.yml file doesn't feel like the right solution – I assume that'd mean all .lock files get associated with this grammar?

@Nixinova
Copy link
Contributor

Nixinova commented Mar 10, 2021

I'm not sure what to do about this test failure:

The sample file must be placed in a "filenames" subfolder: samples/Ruby Gemfile.lock/filenames/Gemfile.lock

Ruby Gemfile.lock:
type: data
color: "#701516"
searchable: false
Copy link
Contributor

@Nixinova Nixinova Mar 10, 2021

Choose a reason for hiding this comment

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

@lildude: What does searchable do? It's false on e.g. JSON but https://github.com/search?q=language:JSON&type=code works.

Copy link
Member

Choose a reason for hiding this comment

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

Good question. I've taken a quick look into it and the answer is... wait for it... nothing 😆

It looks like that's a remnant from the old search backend that was used around about 2011-12.

I'll need to do a thorough investigation, but I think we can safely remove all the searchable stuff. I'll open an issue to remind me of this.

Copy link
Member

Choose a reason for hiding this comment

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

@hmarr
Copy link
Author

hmarr commented Mar 10, 2021

Thanks for the tip @Nixinova, that seems to have done the job. ✨

@lildude lildude merged commit a121eba into github-linguist:master Mar 15, 2021
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants