Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

常用 VS Code 扩展推荐 #43

Open
toFrankie opened this issue Feb 25, 2023 · 0 comments
Open

常用 VS Code 扩展推荐 #43

toFrankie opened this issue Feb 25, 2023 · 0 comments
Labels
2020 2020 年撰写 Editor 与 VS Code 等开发编辑器相关的文章

Comments

@toFrankie
Copy link
Owner

toFrankie commented Feb 25, 2023

配图源自 Freepik

写在前面

在此记录日常中 VS Code 用得较多的插件,会偏向 Web 前端多一些。

主题类

作为颜值党,第一反应是更换默认主题。下面这配色一见钟情,深得我心。

https://github.com/antfu/vscode-theme-vitesse

目前在使用的插件:

我的配置 👇

{
  "workbench.iconTheme": "material-icon-theme",
  "workbench.colorTheme": "Vitesse Black",
  "workbench.productIconTheme": "icons-carbon",
  "autoDetectColorScheme": false,
  "workbench.preferredDarkColorTheme": "Vitesse Black",
  "workbench.preferredLightColorTheme": "Vitesse Light"
}

编辑类

HTML/JSX

支持 JSX/TSX 等扩展语法。

关于自动重命名标签,其实有内置 editor.linkedEditing(默认关闭)。开启后,不安装第三方插件也可以实现相同的效果,使用 1.87 版本亲测,已支持 HTML、Vue Template、JSX/TSX。但像 Vue 可能要安装 Vue - Official 插件才可以正常识别。

JS/TS

个人用得较多的是 impimdclg,对应为 import fs from fsimport { rename } from 'fs'console.log()。其实 VS Code 是有内置 Import Statement,但体验上感觉不如该插件。

重命名

  • change-case - 更改命名规则,提供了非常丰富的规则,比如 fooBarFOO_BAR 等。

智能提示类

  • Path Intellisense - 路径智能提示,键入 .../ 即可自动触发路径提示。
  • CSS Modules - 如果你在使用 CSS Module 的话,它可以提供提示,且可以快速跳转至定义处。
  • CSS Peek - 跟上面插件类似,假设在 HTML 中引入了外部 CSS,点击 idclass 处可以快速跳转至定义处。

快速跳转,需 ⌘ + Click 或 Ctrl + Click 组合。也可使用 ⌘ + ⌥ + Click 在侧栏打开。

快速跳转,本质上是利用了 Go to Definition(转到定义)的能力。

检查与格式化类

这个就不多说了。

它们都要求本地/全局有按照相应依赖。

像 ESLint 如果没有安装依赖,VS Code 会有安装的提示。

像 Stylelint 如果找不到依赖,则不做任何格式化处理。

像 Prettier 如果本地找不到任意本地配置文件(比如 .prettierrc),则使用插件本身的默认配置,可手动配置。

其中 CSScomb 是一个相对小众的插件吧,目前已不再维护,我主要用来对 CSS 属性进行排序(保存时)。感兴趣可看这篇文章

我的配置 👇

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.fixAll.prettier": "explicit",
    "source.fixAll.stylelint": "explicit"
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  
  "prettier.printWidth": 100,
  "prettier.semi": false,
  "prettier.arrowParens": "avoid",
  "prettier.singleQuote": true,
  
  "eslint.options": {
    "extensions": [".js", ".ts", "jsx", ".tsx"],
    "fix": true
  },
  "eslint.workingDirectories": [
    {
      "mode": "auto"
    }
  ],
  
  
  "csscomb.formatOnSave": true,
  "csscomb.syntaxAssociations": {
    "*.wxss": "css",
    "*.acss": "css"
  },
  "csscomb.ignoreFilesOnSave": ["node_modules/**"],
  "csscomb.preset": "~/Library/Mobile Documents/com~apple~CloudDocs/Terminal/csscomb/preset-custom.json",
}

提示类

  • Import Cost - 显示导入包的大小。
  • Image preview - 图片预览,可支持本地/网络链接图片。
  • TODO Highlight - 高亮 TODO:FIXME: 等注释,以便更明显地提醒还有尚未完成的事情。

其中 Image preview 有时不能正确解析到一些不以 .png 等常见扩展名结尾的图片链接,可以配置 gutterpreview.urlDetectionPatterns 选项处理。比如微信公众号的图片资源链接。

我的配置 👇

{
  "importCost.mediumPackageDarkColor": "#7cc36e4d",
  "importCost.smallPackageDarkColor": "#7cc36e4d",
  "importCost.mediumPackageLightColor": "#7cc36e4d",
  "importCost.smallPackageLightColor": "#7cc36e4d",
  "importCost.largePackageLightColor": "#d44e404d",
  "importCost.largePackageDarkColor": "#d44e404d",
  
  "gutterpreview.urlDetectionPatterns": ["/^http(s)*://mmbiz.qpic.cn/i"],
  
  "todohighlight.isEnable": true,
  "todohighlight.isCaseSensitive": true,
  "todohighlight.keywords": [
    {
      "text": "TIPS:",
      "color": "#fff",
      "backgroundColor": "#64aaf0",
      "isWholeLine": false
    }
  ]
}

由于 Import Cost 默认颜色有点喧宾夺主的意思,于是在原来颜色基础上调整到 30% 的不透明度。

其他

有时需要写个临时 HTML 示例来调试/验证某些功能,诸如此类的,Live Server 是一个非常不错的选择,很便捷。

References

@toFrankie toFrankie added Editor 与 VS Code 等开发编辑器相关的文章 持续更新 将会持续更新的文章 labels Feb 25, 2023
@toFrankie toFrankie added the 2020 2020 年撰写 label Apr 26, 2023
@toFrankie toFrankie added 部分已过时 表示部分已过时、或不适用于最新版本,或有更好的替代方案等 and removed 持续更新 将会持续更新的文章 labels Jul 16, 2023
@toFrankie toFrankie changed the title VS Code 插件 常用 VS Code 扩展推荐 Mar 31, 2024
@toFrankie toFrankie removed the 部分已过时 表示部分已过时、或不适用于最新版本,或有更好的替代方案等 label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2020 2020 年撰写 Editor 与 VS Code 等开发编辑器相关的文章
Projects
None yet
Development

No branches or pull requests

1 participant