- 投稿日:
Nanoで{Ctrl}
+{Q}
を終了に割り当ててたらVSCodeで終了できなくなったので、それを解消した話
確認環境
Env | Ver |
---|---|
Visual Studio Code | 1.85.2 |
方法
基本は"terminal.integrated.allowChords": false
で防げるが、それでも出てくるものについてはキーボードショートカットの設定から{Ctrl}
+{Q}
などで検索し、該当するコマンドを調べ"terminal.integrated.commandsToSkipShell": []
に、頭に-
を付加した、"-command"
形式で記載すると出てこなくなる。
例
{
"terminal.integrated.allowChords": false,
"terminal.integrated.commandsToSkipShell": [
"-workbench.action.quickOpenView",
],
}
- 投稿日:
新しくセットアップしたTypeScriptのプロジェクトでauto-importが機能しなかったので原因を調べた。
ここ数年ちまちま起きて、そろそろイラついて我慢の限界を覚えたので…。
確認環境
Env | Ver |
---|---|
VSCode | 1.83.0 |
typescript | 4.8.4 |
再現方法
再現用のサンプルリポジトリでsrc/index.ts
の下図コードに対してauto-importが発動する操作を行う。
発生条件
恐らく以下を全て満たすときにauto-import操作をしようとした時に発生する。地味にややこしい。
node_modules
配下に存在し、@types/
モジュールを持たないものでかつ、同一プロジェクト内でimportされておらず、package.json
のdependencies
に書かれていない。
因みにhoge/piyo/fuga
のようなモジュールはhoge
だけがdependencies
にいてもauto-importが動かない。これを全部package.json
のdependencies
に書いていくのは目眩がするので正直auto-importを諦めて自分でimportを調べて書くのが無難だと思う。
発生原因
TypeScript 4.0で実装されたSmarter Auto-Importsのせい。
node_modules
をクロールすると重すぎるので@types/
だけ読み込んで、あとはpackage.json
のdependencies
も見るようにしたよという内容らしい。
解消方法
package.json
のdependencies
に全部のモジュールを書いていくというのが解決方法になるが、気が遠くなるので諦めた方がいい。初回だけは苦痛でもimportパスをどうにかして調べて手動で書いて、あとはauto-importされるのを期待するのが良いだろう(そんな何度もimportしないと思うが…)
取り敢えず基本npm i
で入れて行き、スラッシュ区切りのやつは諦めるくらいがちょうどいいだろう。
再現用のサンプルリポジトリではpackage.json
のdependencies
に"firebase/app": "^10.4.0"
を追加することでsrc/index.ts
のinitializeApp
に対しauto-importが発動する様になるはずだ。
あとがき
早い話、node_modules
配下にあって@types/
を持たないものはTypeScriptに対応する気がないんだな程度に思っておくのが良いだろうが、TS化で@types/
を廃止したライブラリがある当たり、すごく微妙な感じがある。ちょっとなんとかしてほしい。
そもそもpackage.json
のdependencies
はnpm packageを公開する時に動作するために必要な依存関係を登録する場所で、型の補助をする場所ではなかったはずだ。
少なくともnpmjsのdevDependenciesには以下の記述がある。つまりモジュールを配布する時に動作に不要な依存関係を含まないようにするためにdevDependencies
があるということだ。つまりdependencies
には動作に必要なものだけを入れるべきで、モジュールを配布しない場合、このフィールドは不要になるはずである。
If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.
In this case, it's best to map these additional items in a devDependencies object.
ただTypeScriptがdependencies
に書かないとauto-importが失敗すると言っているので使うものはdependencies
に入れるというのが良いのだろう。(配布しないモジュールだとしても)
ただそれにしてもauto-importを動かすためだけに、dependencies
に同一モジュールのスラッシュ違いを大量に入れていくのはバカバカしいと思う。
"dependencies": {
"firebase": "^10.4.0",
"firebase/app": "^10.4.0",
"firebase/database": "^10.4.0",
"firebase/analytics": "^10.4.0",
...
}
かといってinitializeApp
がfirebase/app
にあるなんて知らんわけで、全部のパスに総当りしていくのも嫌だし、一々リファレンス漁るのも面倒だし、なんかもうちょっといい具合になって欲しい…。
- 投稿日:
{
"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"
],
"editor.stickyScroll.enabled": false,
"workbench.startupEditor": "newUntitledFile",
"workbench.iconTheme": "vscode-icons",
"workbench.editor.decorations.badges": false,
"workbench.editor.decorations.colors": false,
"workbench.tree.enableStickyScroll": false,
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"git.autorefresh": true,
"git.autoStash": true,
"git.suggestSmartCommit": false,
"diffEditor.ignoreTrimWhitespace": true,
"explorer.confirmDragAndDrop": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[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",
"git.mergeEditor": false,
"security.workspace.trust.untrustedFiles": "open",
"explorer.copyRelativePathSeparator": "/",
"workbench.layoutControl.enabled": false,
"git.openRepositoryInParentFolders": "never",
"workbench.editor.empty.hint": "hidden",
"typescript.tsserver.log": "off",
"gitlens.ai.experimental.generateCommitMessage.enabled": false,
"scm.showIncomingChanges": "never",
"scm.showOutgoingChanges": "never"
}
- 投稿日:
環境
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
}
]
}
- 投稿日:
確認環境
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を入れれば解決する