vscode中的setting.json配置

530 阅读2分钟

vscode中的setting.json配置

1、vue2

{
  "files.associations": {
    "*.vue": "vue",
    "*.cshtml": "html",
    "*.js": "javascript",
    "*.dwt": "html"
  },
  // 配置 ESLint 检查的文件类型
  "eslint.validate": [
     // eslint规则对以下几种后缀文件生效. 默认为["javascript", "javascriptreact"]
    "html",
    "vue",
    "javascript",
    "typescript",
    "javascriptreact",
    "typescriptreact"
  ],
  "eslint.options": { //指定vscode的eslint所处理的文件的后缀
    "extensions": [
      "js",
      "vue",
      ".ts",
      ".tsx"
    ]
  },
  // 每次保存的时候将代码按eslint格式进行修复
  "eslint.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll": "explicit",
    "eslint.autoFixOnSave": "explicit"
  },
  "editor.wordWrapColumn": 220,// 在220个字符处折行
  // vue文件默认格式化方式vetur
  // "[vue]": {
  //   "editor.defaultFormatter": "yoyo930021.vuter"
  // },
  // "vetur.format.options.tabSize": 2,
  // "vetur.format.defaultFormatter.html": "esbenp.prettier-vscode",
  // "vetur.format.defaultFormatterOptions": {
  //   "js-beautify-html": {
  //     "wrap_attributes": "force-aligned",
  //     "wrap_line_length": 300 // 设置多个字符后换行 0 表示忽略
  //   }
  // },
  // "vetur.format.defaultFormatter.js": "prettier",
  "javascript.format.insertSpaceBeforeFunctionParenthesis": false, // 函数前加上空格 只有在默认vetur的时候生效
  // js文件默认格式化方式 和vue中的js保持一致使用编辑器自带的ts格式
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  // json文件默认格式化方式prettier
  "[json]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
  },
  // css文件默认格式化方式prettier
  "[css]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
  },
  "[scss]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
  },
   // 对html文件,使用 vscode.html-language-features(vscode内置规则) 进行格式化,不要使用 prettier
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "[vue]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  // 字体大小
  "editor.fontSize": 16,
  // 控制折行方式 - "on" (根据视区宽度折行)
  "editor.wordWrap": "on",
  "editor.tabSize": 2, // 换行默认以tab缩进 2个字符
  "editor.colorDecorators": false, // 控制编辑器是否显示内联颜色修饰器和颜色选取器。
  "editor.snippetSuggestions": "top", // 代码提示。许多插件都有代码提示,代码缩写提示优先显示在最上方
  "[jsonc]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "editor.fontLigatures": false,
  "editor.mouseWheelZoom": true, // crt+缩放
  "liveServer.settings.port": 0,
  "git.ignoreWindowsGit27Warning": true,
  "eslint.nodeEnv": "",
  "diffEditor.ignoreTrimWhitespace": false,
  "liveServer.settings.donotShowInfoMsg": true,
  "editor.formatOnSave": false,
  "markdownlint.focusMode": false,
  "eslint.format.enable": true,
  "eslint.lintTask.enable": true,
  "emmet.triggerExpansionOnTab": true,
  "emmet.includeLanguages": {
    "vue-html": "html",
    "vue": "html"
  },
  "files.defaultLanguage": "vue",
  "workbench.iconTheme": "vscode-icons",
  "workbench.productIconTheme": "vscode-v1-icons",
  "workbench.colorTheme": "Default Dark+",
  "git.confirmSync": false,
  "window.menuBarVisibility": "visible",
  "search.collapseResults": "auto",
  "search.decorations.badges": false,
  "workbench.editor.wrapTabs": true,
  "editor.fontVariations": false,
  "editor.smoothScrolling": true,
  "editor.cursorBlinking": "expand",
  "editor.cursorSmoothCaretAnimation": "on",
  "workbench.list.smoothScrolling": true,
  "editor.guides.bracketPairs": true, //彩虹括号与作用域块线条提示
  "editor.bracketPairColorization.enabled": true,//彩虹括号与作用域块线条提示
  "editor.autoClosingBrackets": "beforeWhitespace", //括号自动闭合, 默认是 "always"
  "editor.autoClosingDelete": "always",// 删除字符后自动关闭括号和引号
  "editor.autoClosingOvertype": "always", // 关闭括号或引号时是否覆盖当前光标后的内容
  "editor.autoClosingQuotes": "beforeWhitespace"
}

2、vue3

{
  "[javascript]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint"
  },
  "[vue]": {
    "editor.defaultFormatter": "yoyo930021.vuter"
  },
  // "files.autoSave": "afterDelay", //超过屏幕视图换行
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "security.workspace.trust.untrustedFiles": "open",
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "[css]": {
    "editor.defaultFormatter": "Vue.volar"
  },
  "[scss]": {
    "editor.defaultFormatter": "Vue.volar"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
  },
  "workbench.colorCustomizations": {},
  "editor.tabSize": 4,
  "gitlens.defaultDateLocale": "zh-cn",
  "typescript.locale": "zh-CN",
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "workbench.colorTheme": "Default Dark+",
  "[jsonc]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  //  #去掉代码结尾的分号
  //  #使用带引号替代双引号
  "javascript.format.enable": true,
  // "eslint.format.enable": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "html",
    "vue",
    "typescript",
    "typescriptreact"
  ],
  "[markdown]": {
    "editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
  },
  "vue.complete.casing.tags": "autoKebab",
  "files.associations": {
    "*.vue": "vue"
  },
  "[plaintext]": {
    "editor.unicodeHighlight.ambiguousCharacters": false,
    "editor.unicodeHighlight.invisibleCharacters": false
  },
  "editor.minimap.renderCharacters": false,
  "editor.minimap.autohide": true,
  "editor.minimap.enabled": false,
  "gitlens.views.commitDetails.files.layout": "tree",
  "gitlens.advanced.fileHistoryShowAllBranches": true,
  "editor.foldingStrategy": "indentation",
  "windicss.enableCodeFolding": true,
  "editor.foldingImportsByDefault": true,
  "gitlens.menus": {
    "editor": {
      "blame": true,
      "clipboard": true,
      "compare": true,
      "history": true,
      "remote": true
    },
    "editorGroup": {
      "blame": true,
      "compare": true
    },
    "editorGutter": {
      "compare": true,
      "remote": true,
      "share": true
    },
    "editorTab": {
      "clipboard": true,
      "compare": true,
      "history": true,
      "remote": true
    },
    "explorer": {
      "clipboard": true,
      "compare": true,
      "history": true,
      "remote": true
    },
    "ghpr": {
      "worktree": true
    },
    "scm": {
      "graph": true
    },
    "scmRepositoryInline": {
      "graph": true,
      "stash": false
    },
    "scmRepository": {
      "authors": true,
      "generateCommitMessage": true,
      "graph": false
    },
    "scmGroupInline": {
      "stash": true
    },
    "scmGroup": {
      "compare": true,
      "openClose": true,
      "stash": true
    },
    "scmItemInline": {
      "stash": false
    },
    "scmItem": {
      "clipboard": true,
      "compare": true,
      "history": true,
      "remote": true,
      "share": true,
      "stash": true
    }
  },
  "vue.codeLens.enabled": false,
  // "vue.format.template.initialIndent": false,
  "vue.doctor.status": false,
  "vue.codeActions.enabled": false,
  "vue.splitEditors.layout.left": [
    "script",
    "scriptSetup",
    "styles"
  ],
  "editor.unicodeHighlight.allowedLocales": {
    "zh-hant": true
  },
  "editor.fontVariations": false,
  "diffEditor.ignoreTrimWhitespace": false,
  "editor.fontLigatures": false,
  "github.copilot.editor.enableAutoCompletions": true,
  "workbench.editor.enablePreview": false,
  "editor.fontWeight": "normal",
  "liveServer.settings.donotShowInfoMsg": true,
  "git.confirmSync": false,
}