Installing a local unpackaged VSCode extension - visual-studio-code

I'm trying to install a custom version of a VSCode extension without packaging it into a .vsix file. I've copied an existing extension in ~/.vscode-server/extensions/original-extension to ~/.vscode-server/extensions/my-custom-extension with my modifications, but VSCode doesn't seem to detect that it's there: it's not in the Extensions sidebar after reloading the window, etc.
I've also tried and failed to install the custom extension locally in case it was something specific to the remote setup (copying into ~/.vscode/extensions and running VSCode locally), so that doesn't seem to be the issue.
From these (possibly outdated) docs, it seems like side-loading by just copying into the extensions folder should work: https://vscode-docs.readthedocs.io/en/stable/extensions/install-extension/#sharing-privately-with-others-side-loading . Is there a way to get VSCode to detect my extensions folder? What am I missing?

Related

Why cannot I use the Vim VSCode extension over ssh or wsl?

I cannot install the Vim VSCode extension on my headless machine through VSCode remote development nor in WSL. I think I used to be able to but I uninstalled it once and since then I haven't been able to install it again. I can only install and uninstall on my Windows computer but not remotely: when I click the button to install Windows extensions to server, the Vim VSCode extension is not part of the batch:
Edit: actually the extension stopped working in Windows as well without obvious reason.
Here is a list of my extensions: maybe I introduced incompatibilities I am not aware of:
I wonder how to get a JSON list of the extensions by the way :(
I might be wrong but I don't believe the normal VSCodeVim extension requires Vim itself to be installed as it just emulates it, so it shouldn't need installed in the remote environment as long as it is installed/enabled which it looks to be. Is it not working?
There was a bug in the settings JSON file. There was some syntax error, possibly caused by the installation of some other extension.

How to create settings.json and extensions.json outside of image and named config level for an ATTACHED VSCode Container

I'm using WSL 2 for Windows, and I'm currently working on a ddev repo where I am creating a development environment using ddev and VSCode. On initiation of the ddev environment, I am starting up all my containers. With my custom "ddev code" command, I am attaching VSCode to the web container via the hex representation of the web container using
'code --folder-uri="vscode-remote://attached-container+646465762d646465762d7673636f64652d646576636f6e7461696e65722d64727570616c392d74656d706c6174652d776562%/var/www/html"'
Now, I would like to automatically enable a bunch of extensions and settings. Currently, I am using workspace settings in my projects folder structure in the form of .vscode/settings.json and extension settings in the form of .vscode/extensions.json. But this is just a workaround, since VSCode will use these settings as "workspace settings" and not "devcontainer settings". I would like to define the settings and install the extensions directly on my attached VSCode container rather than in my workspace settings, since I can only use "recommendations" in the extensions.json, because it is seen as a workspace.
I know I can set the settings and extensions under "AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-containers\imageConfigs" or "nameConfigs" but I would like to have them in Ubuntu or rather in my project's folder directory. I also know that there is the devcontainer.json for standalone VSCode Containers where you can set the Docker files and settings/extensions, but how can I use such a file for my attached container?
Another way would be to install the extensions via command after attaching VSCode using
code --install-extension <extension-id>
But this will only install them locally. And executing this command in the web Container via ssh will throw an error.
Maybe someone knows a solution? If further information is needed I can of course provide it :)
Here is the repository I am working on:
https://github.com/webksde/ddev-vscode-devcontainer-drupal9-template
EDIT: Maybe this issue from our repo can also give more insight:
https://github.com/webksde/ddev-vscode-devcontainer-drupal9-template/issues/28

Multiple configurations for VSCode

At the moment I'm working on a few projects at the same time using VSCode, one in react, another in angular and some good old javascript.
The problem is that I have a few extensions installed that conflict, for example, some code snippets that are the same for React and Angular.
Is it possible to have 3 visual studio code installed on a Mac with different extensions installed?
There are two options for such setup:
Portable installation - unzip VSCode in a folder and create a subfolder there called data. This will trigger the portable mode and all settings will be stored in that data folder. The downside is that you'll have to manually update every portable folder whenever new version comes out. More info here.
Custom config paths - create a shortcut for your VSCode installation, and add those parameters:
--user-data-dir <some-path> --extensions-dir <some-path>
You can put them wherever and have as much shortcuts as you want, they even run in parallel. Best part is once you update the installation, all the configs are upgraded too. More info here.
Both modes are incompatible, so you have to choose one.

Download Visual Studio Code extensions behind proxy

Despite setting the http.proxy setting, I am unable to download extensions (or browse extensions).
I found that if I start the program with --proxy-server=http://myproxy.example.com:3128 then it works.
The code-server used for remote development doesn't support the --proxy-server flag.
The workaround I have found is to manually download the .vsix extension archive for the extension I want to install. e.g. from here: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools there's a "Download Extension" drop down on the right under "Resources" where I can download the extension for the server's platform.
Then, move this archive to the target server. Since I'm using an ssh remote, I just scp it over.
Then, install the extension from the archive:
~/.vscode-server/bin/<id>/bin/code-server --install-extension /path/to/archive.vsix
And this should install the extension. I had to restart the editor a few times before the extension showed as installed in the editor as well.

How to install VS code extension manually?

I am not able to download any extension via VS Code on my office system due to the proxy. Is there a way that I can do it manually by downloading and placing the downloaded files at the right place?
Download the extension from VSCode marketplace, it'll be a .vsix file, then do like the image below.
You can also use the command-line to install extensions from VSIX files using the --install-extension parameter.
code --install-extension /path/to/vsix
eg: code --install-extension vscodevim.vim
Just in case u have a same UI as mine. Happy coding!
You can also just drop the extension files into the correct folder. On mac, for example, this is ~/.vscode/extensions/. I'm unsure whether it works for all extensions, but it works just fine for a simple language specification.
Two notes when downloading an extension from VScode marketplace:
Version compatibility
Extensions are updated repeatedly on the marketplace. If you download and transfer it to the target computer, it may not work. One can try to look into version history of the extension and download the older version. But it is not easy to correlate the extension version with VSCode version. You can check the version of the extension on the online computer and try to find a match in the marketplace. But sometimes the older versions are not listed there.
Dependencies
An extension may have dependencies. When installing from within VSCode, VScode installs the dependencies for you. Good example is the Python extension that requires few other extension like Jupyter and pylance.
To handle these two cases easier:
1- Install the same VSCode version on the online (access to internet) computer as the offline (no access to internet) target computer.
2- From within the VSCode, install the desired extension. It will install the right version and all the dependencies.
3- Find the folder where extensions are installed. On windows, it is in: C:\Users\USER_NAME\.vscode\extensions. On Linux, it is ib ~/.vscode/extensions.
4- Copy and transfer the extensions to the target offline computer, in the extensions folder.
5- Restart the VSCode to see the extensions.
The below screenshot shows all the extensions that I transferred to have the python extension available on the target computer: