Vscode_deno: Plugin does not respect user tab settings

Created on 10 Jun 2020  路  6Comments  路  Source: denoland/vscode_deno

Not to start a tabbing war, but I have explicitly set these settings, and they are ignored when formatting.

{
  "editor.insertSpaces": false,
  "editor.tabSize": 4
}
bug

All 6 comments

I haven't looked at the source for this, but I presume it's using deno fmt.

It seems to be overriding "editor.formatOnSave": true, as well, even though according to the deno docs, the deno.autoFmtOnSave is false by default and has not been implemented...

Also, for ticket completeness, I have uninstalled all vscode plugins, and its fine, install https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno or https://marketplace.visualstudio.com/items?itemName=justjavac.vscode-deno and problem occurs.

I decided to dig into this just now. You have control over which formatter is used for different filetypes in VS Code. There is information about how to customize this behavior and other language-specific behaviors at the VS Code docs > Get Started > Settings > Language specific editor settings.

When editing your settings.json file, intellisense will help you find the valid keys and values, but these are likely the settings that you want:

{
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "[javascriptreact]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
}

If you use those settings, VS Code will use the built-in formatter instead of the one provided by the Deno extension, when editing .js, .jsx, .ts, .tsx files.

If you are uncomfortable editing your settings.json file, you can use the command palette to change the default formatter while editing a document of that type. Here is an example while I was editing a TypeScript document:

vscode-default-formatter

Marvellous, Thank you for these suggestions and the link to the docs. They are super informative.

I've fixed my issues using the default formatter value vscode.typescript-language-features like you suggested, but only for javascript and typescript.

The extension does not have auto format on save anymore now. The tab size is determined by deno fmt for the deno formatter, and is not configurable. As for not enabling the extension by default, I agree: see #193.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heroboy picture heroboy  路  10Comments

Ciantic picture Ciantic  路  10Comments

Ragzouken picture Ragzouken  路  5Comments

chenguzhen87 picture chenguzhen87  路  5Comments

promethyttrium picture promethyttrium  路  10Comments