Skip to content
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

Populate vscode specific configurations #43

Open
Tracked by #132
geiseri opened this issue Jul 26, 2023 · 3 comments
Open
Tracked by #132

Populate vscode specific configurations #43

geiseri opened this issue Jul 26, 2023 · 3 comments

Comments

@geiseri
Copy link

geiseri commented Jul 26, 2023

The devcontainer spec has a section that covers the support of VS Code specific properties. I am not sure how reasonable the customizations.vscode.settings are for the remote since those are stored in a local user session. (In the case of coder could be in a different volume). This might actually be a better issue for them to solve on that side then. If that is your opinion please feel free to close this issue and I will move it to the coder project.

@kylecarbs
Copy link
Member

@geiseri if you have the VS Code Dev Containers extension do the customizations automatically install?

@aaronlehmann
Copy link
Collaborator

aaronlehmann commented Jul 26, 2023

I've been using this snippet of code in the devcontainer startup script to install VS Code extensions specified in devcontainer.json. It's a pretty gross hack and you may well be able to come up with something better, but it might be useful as an example:

  if ! which code-server > /dev/null; then
    curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
  fi
  CODE_CLI=code-server
  if code -v > /dev/null; then
    CODE_CLI=code
  fi
  mkdir -p ~/.vscode-server/extensions

  set +e
  extensions=( $(sed 's/\/\/.*$//g' */.devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
  if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
    for extension in "$${extensions[@]}"; do
      $CODE_CLI --extensions-dir ~/.vscode-server/extensions --install-extension "$extension"
    done
  fi

@michaelbrewer
Copy link
Contributor

Ended up doing something very similar, would be nice to have this built in

    curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.22.0

    CODE_CLI=/tmp/code-server/bin/code-server
    DEVCONTAINER_JSON=".devcontainer/devcontainer.json"
    if [[ -f "$DEVCONTAINER_JSON" ]]; then
        EXTENSIONS=$(sed '/^ *\/\//d' "$DEVCONTAINER_JSON" | jq -r '.customizations.vscode.extensions[]?')
        if [[ -n "$EXTENSIONS" ]]; then
            # Loop over each extension and install it
            for EXTENSION in $EXTENSIONS; do
                $CODE_CLI --install-extension $EXTENSION
            done
        fi
    fi

    $CODE_CLI --auth none --port 13337 >/tmp/code-server.log 2>&1 &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants