Visual Studio Codeで導入するべきプラグインと設定

Visual Studio Codeで導入するべきプラグインと設定

自分はVisual Studio Code(VSCode)をメインのエディタとして利用しています。

VSCodeは、プラグインが豊富で軽量なので使いやすいですよね。

この記事では自分の備忘録を兼ねて、VSCodeのおすすめ設定を紹介します

こんな人向けの設定
  • Docker使う人
  • 計算機サーバーのファイルを直接編集したい人
  • VSCodeを動かすOSはWindows10

setting.jsonの編集

VSCodeでは設定をsetting.jsonで管理しているので、ここに直接設定値を書き込んでいきます。

setting.jsonは、ctrl+shift+Pでパレットを開いて、”open setting”と調べてJSONを開くことで編集が可能です。

共通設定

右側のminimapを消す、末尾の空白を削除、保存時にフォーマットをする、ホイールズームの有効化等々です。

"editor.minimap.enabled": false,
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": true,
"editor.mouseWheelZoom": true,
"workbench.colorTheme": "Monokai",
"editor.wordWrap": "on",

フォント

フォントはRicty Diminishedを利用しています。

"editor.fontFamily": "Ricty Diminished",
"editor.fontSize": 16,
"terminal.integrated.fontFamily": "Cascadia Code",

※Windows10へのRictyのインストール方法は下記記事を参考にしてください。

Pythonの設定

autopep8を使った自動フォーマットとlintによる構文チェックを行います。

pathを追加するときにimportの順番などを自動で変更されるのは嫌なので、E402エラーは無視しています。

自分はpythonの仮想環境としてvenvを利用しています。仮想環境はホームディレクトリ以下のvenvディレクトリで管理しているので、vscodeから ~/venv/以下の仮想環境を認識できるようにパスを追加しています。

    "python.linting.lintOnSave": true,
    "python.linting.pylintEnabled": false,
    "python.linting.pep8Enabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "--ignore=W293, W504",
        "--max-line-length=150",
        "--max-complexity=20"
    ],
    "python.formatting.provider": "autopep8",
    "python.formatting.autopep8Args": [
        "--aggressive",
        "--aggressive",
        "--ignore",
        "E402",
    ],
    "python.venvFolders": [
        "envs",
        ".pyenv",
        ".direnv",
        "venv"
    ]

Goの設定

python同様にlintと自動フォーマット程度です。

    "go.useLanguageServer": true,
    "go.lintTool": "golangci-lint",
    "[go]": {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        }
    }

拡張機能

おすすめの拡張機能です

拡張機能説明
vscode-iconsアイコンをきれいに表示
GoGoの開発で必須
PythonPythonの開発で必須
YAMLyamlファイルの編集に必須
Visual Studio InteliCode補完機能
PrettierCode Formatter
RainbowCSVCSVの見た目を整えてくれる
Remote SSHリモートPCのファイルを直接編集
Remote ContainerDockerコンテナ内のファイルを直接編集
Remote WSLWSL内でVSCodeを利用する