-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Add a compose language #118042
Add a compose language #118042
Conversation
@chrmarti FYI |
I wanted to expand on this some; from telemetry it appears that around 60% of our (Docker extension) activations are due to opening a yaml document, and around 30% are from opening a Dockerfile. Certainly not all of those 60% are actually compose documents (not really sure just how many are), so those would be spurious activations. @alexr00 suggested we could also look at the
Users have a lot of variability in file naming for Docker-related stuff. Dockerfiles probably have this more, but compose documents are no exception. Allowing users to adjust This issue has a lot of our reasons for wanting this, and links several issues that we duped against it, in order to gather up everything related. Up until this morning when I spoke to Alex we were tentatively planning on duplicating the yaml grammar straight from VSCode and defining the language, but I was wondering if there was a better way than code duplication--so I asked, and @alexr00 recommended this! |
extensions/yaml/package.json
Outdated
"compose" | ||
], | ||
"filenamePatterns": [ | ||
"*compose*.yml", |
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.
Discussed in the chat, but is this case-sensitive?
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 don't have a linux VM to test this on at the moment, but looking at the code it seems that we toLower
the pattern so it should be case-insensitive.
vscode/src/vs/base/common/mime.ts
Lines 174 to 182 in e8760a5
// Longest pattern match | |
if (association.filepattern) { | |
if (!patternMatch || association.filepattern.length > patternMatch.filepattern!.length) { | |
const target = association.filepatternOnPath ? path : filename; // match on full path if pattern contains path separator | |
if (match(association.filepatternLowercase!, target)) { | |
patternMatch = association; | |
} | |
} | |
} |
extensions/yaml/package.json
Outdated
@@ -13,6 +13,18 @@ | |||
}, | |||
"contributes": { | |||
"languages": [ | |||
{ | |||
"id": "compose", |
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.
Would it make sense to disambiguate it as "docker-compose"
?
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.
Seems reasonable to me. I can change it.
Maybe call the language |
It needs to be more broad. Here's a sampling of a bunch of valid, (mostly) realistic compose file names:
The list goes on eternally...the only thing I think is reliable is that it's nearly always a yaml extension (yml or yaml), and "compose" appears in the filename nearly always. Sure, you could start to list them off more specifically, but it becomes a maintenance headache. Something a little less broad that I think would still cover most of our bases: "filenamePatterns": [
"compose.yml",
"compose.yaml",
"compose.*.yml",
"compose.*.yaml",
"*docker*compose*.yml",
"*docker*compose*.yaml"
] That would match everything in the list above, but not "composer.yaml" or something along those lines that would (probably) not be a compose document. |
Seems like there are no objections, so I'm going to merge this. |
I heard from @bwateratmsft that adding a compose language would be useful for the docker extension, and I think it might make sense. It's easy to try this, so I figured why not. Some of the reasons this could be useful:
compose
as the language for activationfiles.associations