Skip to content

Instantly share code, notes, and snippets.

@soulmachine
Last active March 24, 2022 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulmachine/3523eb3e024fa0331be3b04b6230dc63 to your computer and use it in GitHub Desktop.
Save soulmachine/3523eb3e024fa0331be3b04b6230dc63 to your computer and use it in GitHub Desktop.
Visual Code Settings for Go, Rust, Solidity and Python. Install this extension https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync and fill in this gist ID, then you're all set

vscode settings for Go Rust, Solidity and Python

Each language should have the following 3 components:

  1. The language server.
  2. The formatter.
  3. The linter.

Each component has a binary and a vscode extension.

1. Go

First of all, install the go compiler by following the official doc https://go.dev/doc/install.

1.1 Language Server

Install the official go language server binanry gopls:

go install golang.org/x/tools/gopls@latest

Install the official vscode plugin vscode-go. This plugin can automatically install the gopls binary too.

1.2 Formatter

We are going to use gofumpt-style formatting instead of the default gofmt, first install it:

go install mvdan.cc/gofumpt@latest

Then add the following configuration to settings.json:

"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"go.formatTool": "gofumpt",
"gopls": {
    "formatting.gofumpt": true
}

1.3 Linter

Choose staticcheck as the Go linter. First install it:

go install honnef.co/go/tools/cmd/staticcheck@latest

Then add the following configuration to settings.go:

"go.lintTool": "staticcheck",
"go.lintOnSave": "file",

2. Rust

First of all, install the Rust compiler and cargo:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly

2.1 Language Server

Choose rust-analyzer because it is much better than the official language server rls.

First install its binary:

rustup component add rust-src rust-analyzer-preview

Then install its vscode extension matklad.rust-analyzer. This plugin can automatically install the rust-analyzer binary too.

2.2 Formatter

rust-analyzer is the formatter by default.

2.3 Linter

rust-analyzer is the linter by default.

3. Solidity

First of all, install the solc:

brew install solidity

3.1 Language Server

The solc has a --lsp parameter, which makes it a language server.

So we only need to install the vscode extension JuanBlanco.solidity.

3.2 Formatter

"[solidity]": {
    "editor.defaultFormatter": "JuanBlanco.solidity"
},

3.3 Linter

First, install the binary solhint,

brew install solhint

Then add the following configuration to settings.json:

"solidity.linter": "solhint",

4. Python

First of all, we need to install a Python interpreter, I prefer anaconda::

brew install --cask anaconda

4.1 Language Server

We choose the Microsoft pylance as the Python language server.

First, install the ms-python.python extension.

This extension can automatically install the Pylance binary, and it also install the Pylance and Jupyter extensions.

Then add the following configuration to settings.json:

"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "strict",

4.2 Formatter

Use black as the formatter, install it first:

conda install black -c conda-forge

Then add the following configuration to settings.json:

"python.formatting.provider": "black",

4.3 Linter

Use pylint as the linter, install it first:

conda install pylint -c conda-forge

Then add the following configuration to settings.json:

"python.linting.pylintEnabled": true,

References

  1. https://code.visualstudio.com/docs/languages/go
{"lastUpload":"2022-03-23T11:56:49.539Z","extensionVersion":"v3.4.3"}
[
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.4.3"
},
{
"metadata": {
"id": "23c4aeee-f844-43cd-b53e-1113e483f1a6",
"publisherId": "GitHub.copilot",
"publisherDisplayName": "GitHub"
},
"name": "copilot",
"publisher": "GitHub",
"version": "1.9.5350"
},
{
"metadata": {
"id": "25baab03-fe9a-40c7-b683-55c9a0a92480",
"publisherId": "JuanBlanco.solidity",
"publisherDisplayName": "JuanBlanco"
},
"name": "solidity",
"publisher": "JuanBlanco",
"version": "0.0.137"
},
{
"metadata": {
"id": "d6f6cfea-4b6f-41f4-b571-6ad2ab7918da",
"publisherId": "golang.go",
"publisherDisplayName": "golang"
},
"name": "go",
"publisher": "golang",
"version": "0.32.0"
},
{
"metadata": {
"id": "6c2f1801-1e7f-45b2-9b5c-7782f1e076e8",
"publisherId": "ms-toolsai.jupyter",
"publisherDisplayName": "ms-toolsai"
},
"name": "jupyter",
"publisher": "ms-toolsai",
"version": "2022.2.1030672458"
},
{
"metadata": {
"id": "9f6dc8db-620c-4844-b8c5-e74914f1be27",
"publisherId": "ms-toolsai.jupyter-keymap",
"publisherDisplayName": "ms-toolsai"
},
"name": "jupyter-keymap",
"publisher": "ms-toolsai",
"version": "1.0.0"
},
{
"metadata": {
"id": "b15c72f8-d5fe-421a-a4f7-27ed9f6addbf",
"publisherId": "ms-toolsai.jupyter-renderers",
"publisherDisplayName": "ms-toolsai"
},
"name": "jupyter-renderers",
"publisher": "ms-toolsai",
"version": "1.0.6"
},
{
"metadata": {
"id": "98790d67-10fa-497c-9113-f6c7489207b2",
"publisherId": "yzhang.markdown-all-in-one",
"publisherDisplayName": "yzhang"
},
"name": "markdown-all-in-one",
"publisher": "yzhang",
"version": "3.4.0"
},
{
"metadata": {
"id": "f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5",
"publisherId": "ms-python.python",
"publisherDisplayName": "ms-python"
},
"name": "python",
"publisher": "ms-python",
"version": "2022.3.10821003"
},
{
"metadata": {
"id": "93ce222b-5f6f-49b7-9ab1-a0463c6238df",
"publisherId": "ms-vscode-remote.remote-containers",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-containers",
"publisher": "ms-vscode-remote",
"version": "0.224.3"
},
{
"metadata": {
"id": "607fd052-be03-4363-b657-2bd62b83d28a",
"publisherId": "ms-vscode-remote.remote-ssh",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-ssh",
"publisher": "ms-vscode-remote",
"version": "0.76.1"
},
{
"metadata": {
"id": "bfeaf631-bcff-4908-93ed-fda4ef9a0c5c",
"publisherId": "ms-vscode-remote.remote-ssh-edit",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-ssh-edit",
"publisher": "ms-vscode-remote",
"version": "0.76.1"
},
{
"metadata": {
"id": "06574cb4-e5dc-4631-8174-a543a4533621",
"publisherId": "matklad.rust-analyzer",
"publisherDisplayName": "matklad"
},
"name": "rust-analyzer",
"publisher": "matklad",
"version": "0.3.987"
},
{
"metadata": {
"id": "2f0eaac2-070b-4dc7-9b23-8dd4c970c11c",
"publisherId": "redhat.vscode-commons",
"publisherDisplayName": "redhat"
},
"name": "vscode-commons",
"publisher": "redhat",
"version": "0.0.6"
},
{
"metadata": {
"id": "0479fc1c-3d67-49f9-b087-fb9069afe48f",
"publisherId": "ms-azuretools.vscode-docker",
"publisherDisplayName": "ms-azuretools"
},
"name": "vscode-docker",
"publisher": "ms-azuretools",
"version": "1.21.0"
},
{
"metadata": {
"id": "364d2426-116a-433a-a5d8-a5098dc3afbd",
"publisherId": "ms-python.vscode-pylance",
"publisherDisplayName": "ms-python"
},
"name": "vscode-pylance",
"publisher": "ms-python",
"version": "2022.3.2"
},
{
"metadata": {
"id": "2061917f-f76a-458a-8da9-f162de22b97e",
"publisherId": "redhat.vscode-yaml",
"publisherDisplayName": "redhat"
},
"name": "vscode-yaml",
"publisher": "redhat",
"version": "1.5.1"
}
]
{
"docker.explorerRefreshInterval": 3000,
"docker.languageserver.formatter.ignoreMultilineInstructions": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"editor.inlineSuggest.enabled": true,
"files.exclude": {
"node_modules/": true,
"target/": true
},
"files.trimFinalNewlines": true,
"git.autofetch": true,
"git.enableSmartCommit": true,
"python.formatting.provider": "black",
"python.linting.pylintEnabled": true,
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "strict",
"sync.autoDownload": true,
"sync.gist": "3523eb3e024fa0331be3b04b6230dc63",
"sync.removeExtensions": false,
"remote.containers.defaultExtensions": [
"GitHub.copilot",
"JuanBlanco.solidity",
"golang.go",
"ms-azuretools.vscode-docker",
"matklad.rust-analyzer",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"redhat.vscode-commons",
"redhat.vscode-yaml"
],
"remote.SSH.defaultExtensions": [
"GitHub.copilot",
"JuanBlanco.solidity",
"golang.go",
"ms-azuretools.vscode-docker",
"matklad.rust-analyzer",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"redhat.vscode-commons",
"redhat.vscode-yaml"
],
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"redhat.telemetry.enabled": true,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"security.workspace.trust.untrustedFiles": "open",
"github.copilot.enable": {
"*": true,
"yaml": false,
"plaintext": true,
"markdown": false
},
"go.formatTool": "gofumpt",
"gopls": {
"formatting.gofumpt": true
},
"go.lintTool": "staticcheck",
"go.lintOnSave": "file",
"workbench.colorTheme": "Default Dark+",
"workbench.editor.highlightModifiedTabs": true,
"solidity.linter": "solhint",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment