Vscode-docker: Add intellisense for docker compose files

Created on 3 Dec 2020  路  9Comments  路  Source: microsoft/vscode-docker

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.

  • [x] Language ID for file.associations (#206)
  • [ ] Linting support (#37)
  • [x] Syntax highlighting
  • [ ] Semantic highlighting
  • [ ] Change the file picking logic to be better and language-based (I don't think currently possible)
  • [ ] URL click behavior for base images (#2200)
  • [ ] Volume snippets and pathing intellisense (#2536)
  • [ ] Port snippets and maybe some sort of in-use intellisense (#2535)
  • [ ] Snippets for some well-known services (postgres, redis, etc.)
  • [ ] Updated icon theme: https://github.com/jesseweed/seti-ui (so all compose files can get pink whale that currently only appears for docker-compose.yml and docker-compose.override.yml)
  • [x] 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
  • [ ] Replacing the whole image tag when auto-completing for images (#2710)
  • [ ] Suggest some popular ports for known services (#2715)
  • [ ] Auto format indentation on save/while typing (#2714)
  • [ ] Autocompletions for subsequent parts--e.g., when typing 're', complete to 'restart:', then suggest 'always' and other valid suggestions (#2713)

docker-stack.yml (#520)

P1 experimentation feature investigate language-server

Most helpful comment

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!

All 9 comments

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) or compose.yml in working directory. Compose implementations SHOULD also support docker-compose.yaml and docker-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. :smile:

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) or compose.yml in working directory. Compose implementations SHOULD also support docker-compose.yaml and docker-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. :smile:

Might get a language ID from VSCode itself: https://github.com/microsoft/vscode/pull/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.

Was this page helpful?
0 / 5 - 0 ratings