从扩展中禁用 "wordBasedSuggestions" 等默认设置

Disable default settings like "wordBasedSuggestions" from an Extension

我正在为 VSCode 开发一个扩展,它提供完成项,但其中有单词建议。

我知道你可以在你的 User/Workspace 设置中禁用 editor.wordBasedSuggestions 但是有没有办法从扩展中做到这一点?

是的,扩展程序可以通过在 package.json 中贡献 configurationDefaults 来更改设置的默认值:

"contributes": {
    "configurationDefaults": {
        "[lang]": {
            "editor.wordBasedSuggestions": false
        }
    }
}

其中 lang 是相关语言的 ID。

这现在可以用通用的非特定语言方法来完成。参见 release notes: change configuration defaults

Configuration Defaults Overrides

You can now override defaults of other registered configurations through configurationDefaults contribution point in package.json. For example, the following snippet overrides the default behavior of files.autoSave setting to auto save files on focus change.

"contributes": {
  "configurationDefaults": {                 // applies to all languages
      "files.autoSave": "onFocusChange"
  }
}

Note: Configurations with application or machine scopes cannot be overridden.