Add intellisense for docker compose files
bwateratmsft opened this issue ยท 15 comments
Creating this umbrella issue since there are a bunch of different things that basically boil down to creating a language server + intellisense + etc. for compose files.
- Linting support (Compose schema validation) (microsoft/compose-language-service#84)
- Volume pathing intellisense (microsoft/compose-language-service#85)
- Snippets for some well-known services (postgres, redis, etc.), including common ports (microsoft/compose-language-service#86)
- Image autocomplete suggestions (microsoft/compose-language-service#87)
- Port snippets (#2535)
- Autocompletions for subsequent parts--e.g., when typing 're', complete to 'restart:', then suggest 'always' and other valid suggestions (#2713)
- Linting support (YAML validation) (#37)
- Volume snippets (#2536)
- URL click behavior for base images (#2200)
- Auto format indentation on save/while typing (#2714)
- Updated icon theme: update https://github.com/microsoft/vscode/blob/main/extensions/theme-seti/icons/vs-seti-icon-theme.json (so all compose files can get pink whale that currently only appears for
docker-compose.yml
anddocker-compose.override.yml
) (microsoft/vscode@5541826) (should be available in VSCode 1.61.0) - Syntax highlighting
- Language ID for
file.associations
(#206) (microsoft/vscode#118042) - Defining a language with more specific file names would help with spurious activations.
onLanguage:yaml
accounts for about 60% of all our activations; I'm sure many (or most) of those are not actually docker-compose files
Maybe/currently not possible:
Semantic highlighting(I can't think of a use case)Change the file picking logic to be better and language-based(I don't think currently possible)Port-in-use intellisense(Gross, port scanning)
Other:
docker-stack.yml (#520)
Update: as of 2 Aug 21, about 33% of activations are due to Dockerfiles being opened, now about 25% are due to Docker Compose files being opened, with most of the balance being task runs and the Docker Explorer. This is down from 60% YAML, 30% Dockerfile, 10% others. This is a big improvement; by narrowing to activating for Compose documents only, the activations for Compose/YAML are way lower--this means far less spurious activation.
Other Notes & Ideas:
Adding a "well known" service to a compose file through a snippet. (Redis, postgres)
Warnings for incorrect indentation levels of a service or attributes (e.g "attribute dockerfile does not exist at this hierarchy)
Warnings for incorrect file paths or files that don't exist in the context of the project - mainly applies to context attribute and volume attribute
Warnings for misspelled sections (if you misspell volumes, ports, environment etc, there are no warnings)
Feb 11th Edit (per our meeting discussions):
We have at least a few sections we want to tackle early on for creating tab completions. A few of them are listed below:
- env
- env_file
- build
- depends_on
- labels
@bwateratmsft should the docker-stack.yml
be scrapped?
According to https://github.com/compose-spec/compose-spec/blob/master/spec.md#compose-file and https://docs.docker.com/compose/compose-file/ - the latest specs says a file should be named compose.yaml
it says:
The default path for a Compose file is
compose.yaml
(preferred) orcompose.yml
in working directory. Compose implementations SHOULD also supportdocker-compose.yaml
anddocker-compose.yml
for backward compatibility.
I also noticed now that when I renamed my file to compose.yaml
it does not get the "red Moby Dick icon" but rather a normal .yaml
icon.
@bwateratmsft should the
docker-stack.yml
be scrapped?
Yeah, probably.
According to https://github.com/compose-spec/compose-spec/blob/master/spec.md#compose-file and https://docs.docker.com/compose/compose-file/ - the latest specs says a file should be named
compose.yaml
it says:The default path for a Compose file is
compose.yaml
(preferred) orcompose.yml
in working directory. Compose implementations SHOULD also supportdocker-compose.yaml
anddocker-compose.yml
for backward compatibility.I also noticed now that when I renamed my file to
compose.yaml
it does not get the "red Moby Dick icon" but rather a normal.yaml
icon.
I had not noticed this change, thank you for bringing it to our attention! I'm going to make a separate work item (#2618) to cover that for the time being. It is more urgent that we get that fix in place than that we create a compose language server.
We will be able to do this incrementally which is good. The minimum viable product would include a language ID being defined, and syntax highlighting to support it. This would have the side benefit of reducing spurious activations for non-compose YAML files.
@bwateratmsft Is the plan to implement this with VS Code APIs or as a language server?
Most likely a language server since I assume a lot of these features would require that. We also want to take the same language server and run it in VS--not just VSCode--which is a thing now, or so I'm told. ๐
Might get a language ID from VSCode itself: microsoft/vscode#118042
The VSCode team has merged that change, so now there is a compose language ID of dockercompose
. It matches the following patterns:
"filenamePatterns": [
"compose.yml",
"compose.yaml",
"compose.*.yml",
"compose.*.yaml",
"*docker*compose*.yml",
"*docker*compose*.yaml"
],
I'll start making some changes in the Docker extension to best support this. Thanks @alexr00! This is a big win for us!
Moved to 1.17 per discussion in team meeting, and we'll make this high pri for 1.17.
Icon theme gets defined here: https://github.com/jesseweed/seti-ui/blob/24bb6afe6f9c136fb660d39ed8d46956cb94eb13/styles/components/icons/mapping.less#L542-L551 (disregard the // BOWER
label, looks like a copypaste typo)
We can update the mapping here.
The pink whale icon has been extended to all dockercompose
documents via microsoft/vscode@5541826. This should be available in VSCode 1.60 or maybe 1.61.
Moving milestone to 1.19.0 as we have completed what we wanted to in 1.18.0.
Rather than continually moving this a milestone at a time, I'm going to make sure issues exist for each of the remaining tasks in https://github.com/microsoft/compose-language-service, and close this one.
@bwateratmsft the original post in this thread already contains existing issues. Just open them up again?
Yeah, that's a better idea. I'll do that and transfer them to the other repo.