2022/06/06(月)VSCodeの設定メモ
更新日:
投稿日:
投稿日:
{
"terminal.integrated.defaultProfile.windows": "MSYS2",
"terminal.integrated.profiles.windows": {
"MSYS2": {
"overrideName": true,
"path": ["C:\\env\\msys64\\msys2_shell.cmd"],
"args": [
"-defterm",
"-here",
"-use-full-path",
"-no-start",
"-mingw64",
"-shell",
"zsh"
]
},
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "zsh"
},
"bash": {
"path": "bash"
}
},
"terminal.integrated.automationProfile.windows": {
"path": "${env:windir}\\System32\\cmd.exe",
"args": [],
"icon": "terminal-cmd"
},
"terminal.integrated.allowChords": false,
"terminal.integrated.commandsToSkipShell": [
"-workbench.action.quickOpenView",
"-workbench.action.terminal.focusFind"
],
"workbench.startupEditor": "newUntitledFile",
"workbench.iconTheme": "vscode-icons",
"workbench.editor.decorations.badges": false,
"workbench.editor.decorations.colors": false,
"workbench.tree.enableStickyScroll": false,
"workbench.layoutControl.enabled": false,
"workbench.editor.empty.hint": "hidden",
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"scm.showIncomingChanges": "never",
"scm.showOutgoingChanges": "never",
"git.autorefresh": true,
"git.autoStash": true,
"git.suggestSmartCommit": false,
"git.mergeEditor": false,
"git.openRepositoryInParentFolders": "never",
"remote.autoForwardPortsSource": "hybrid",
"diffEditor.ignoreTrimWhitespace": true,
"diffEditor.renderGutterMenu": false,
"explorer.confirmDragAndDrop": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.stickyScroll.enabled": false,
"[markdown]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"php.validate.run": "onSave",
"vsicons.dontShowNewVersionMessage": true,
"pasteImage.path": "${currentFileDir}/${currentFileNameWithoutExt}.assets",
"todo-tree.filtering.excludeGlobs": ["**/node_modules/**/*"],
"todo-tree.highlights.customHighlight": {
"TODO": {
"foreground": "#f8ff96",
"type": "text-and-comment"
},
"FIXME": {
"foreground": "#ff9696",
"type": "text-and-comment"
}
},
"todo-tree.general.tags": ["TODO", "FIXME"],
"todo-tree.regex.regex": "(//|#|<!--|/\\*|^\\s*\\*)\\s*($TAGS)",
"gitlens.currentLine.format": "${author, }${date}${' via 'pullRequest}${ • message|50?}",
"gitlens.statusBar.format": "${author}, ${date}${' via 'pullRequest}",
"gitlens.statusBar.tooltipFormat": "${avatar} __${author}__, ${date}${' via 'pullRequest}\n\n${message}${\n\n---\n\nfootnotes}\n\n${commands}",
"gitlens.hovers.detailsMarkdownFormat": "${avatar} __${author}__, ${date}${' via 'pullRequest}\n\n${message}${\n\n---\n\nfootnotes}\n\n${commands}",
"gitlens.views.formats.stashes.description": "${date}",
"gitlens.views.formats.commits.description": "${author, }${date}",
"gitlens.defaultDateFormat": "YYYY-MM-DD",
"terminal.integrated.shellIntegration.decorationsEnabled": "never",
"security.workspace.trust.untrustedFiles": "open",
"explorer.copyRelativePathSeparator": "/",
"typescript.tsserver.log": "off",
"gitlens.ai.experimental.generateCommitMessage.enabled": false,
"redhat.telemetry.enabled": true
}
2022/01/04(火)Windows + VSCode + Xdebugの環境を作る
更新日:
投稿日:
投稿日:
環境
Windows 10
| Env | Ver |
|---|---|
| PHP | 8.0.2 |
| Xdebug | 3.0.2 |
php.ini
zend_extension="xdebug-3.0.2-8.0-vs16-nts-x86_64"
xdebug.start_with_request=yes
xdebug.mode=debug
settings.json
別になくてもデバッグは出来る
"php.validate.executablePath": "C:/path/to/php.exe",
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
2021/05/12(水)Golang + Docker + VSCodeでのデバッグをする方法
更新日:
投稿日:
投稿日:
確認環境
| Env | Ver | Misc |
|---|---|---|
| golang | 1.16.4-alpine3.13 | DockerImage |
| VSCode | 1.56.0 | |
| golang.go | 0.24.2 | VSCode 拡張 |
サンプルコード
Dockerfile
シェルが貧弱なので、ついでに好きなシェルも入れておくのが無難
FROM golang:1.16.4-alpine3.13
RUN apk add git gcc libc-dev
RUN go get golang.org/x/tools/gopls \
&& go get -u github.com/go-delve/delve/cmd/dlv
.vscode/settings.json
- あとはF5を押せば起動する
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/"
},
]
}
トラブルシュート
デバッグしようとして起きるエラーとか
上のサンプルコードを使っている限り起きないはず
exec: "gcc": executable file not found in $PATH
gccを入れれば解決する
_cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory
libc-devを入れれば解決する
2021/03/10(水)VSCodeでXdebugからの余計な例外を無視する
更新日:
投稿日:
投稿日:
余計な例外を投げてくるのが面倒なのでそれを無視できるように
確認環境
| Env | Ver |
|---|---|
| PHP | 7.1.3 |
| Xdebug | 2.9.4 |
| VSCode | 1.48.0 |
内容
"ignore"セクションを追加してそこに書いたファイルから出た例外は無視される
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"ignore": [
"**/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
]
}
]
}
2021/03/09(火)VSCode + MSYS2でSSHのパスフレーズ入力を記憶させる
更新日:
投稿日:
投稿日:
VSCodeのRemote - SSH拡張でSSH接続する時に毎回秘密鍵のパスフレーズを求められるのが面倒すぎるので、パスフレーズを記憶させて入力を省略させる方法を調べた
前提
- Windows 10 or 11
- Remote - SSH拡張を利用した公開鍵認証接続(パスフレーズあり)ができている
- MSYS2を入れている
手順1
- PowerShellを管理者権限で起動させて次のコマンドを流す
Set-Service ssh-agent -StartupType Automatic Start-Service ssh-agent Get-Service ssh-agent - 秘密鍵をssh-agentに食べさせる
ssh-add C:\Users\hoge\.ssh\id_rsa - パスフレーズを求められるので入力
- 追加した秘密鍵が登録されていることを確認
ssh-add -l - VSCodeからRemote - SSHを使って接続する
- パスフレーズ無しで入れればOK、パスフレーズを求められたら以下の手順2へ
手順2
以下の警告が流れてうまく行かないケース、この場合はWindows付属のOpenSSHが腐っているので入れ替える
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
- PowerShellを管理者権限で起動させて次のコマンドを流して標準のOpenSSHをアンインストールする
Get-Service -Name ssh-agent | Stop-Service sc.exe delete ssh-agent Remove-WindowsCapability -Online -Name "OpenSSH.Client~~~~0.0.1.0" Remove-WindowsCapability -Online -Name "OpenSSH.Server~~~~0.0.1.0" - Chocolateyを入れる
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) - OpenSSHをインストールする
choco install openssh --package-parameters="/SSHAgentFeature" - サービスから
ssh-agentが実行中で自動起動するようになっていることを確認 - 秘密鍵をssh-agentに食べさせる
ssh-add C:\Users\hoge\.ssh\id_rsa - 追加した秘密鍵が登録されていることを確認
ssh-add -l - VSCodeからRemote - SSHを使って接続する
- パスフレーズ無しで入れればOK