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

Add formatter settings on workspace initialization #789

Open
Tracked by #968 ...
khaosdoctor opened this issue Jan 15, 2023 · 0 comments · May be fixed by #790
Open
Tracked by #968 ...

Add formatter settings on workspace initialization #789

khaosdoctor opened this issue Jan 15, 2023 · 0 comments · May be fixed by #790
Labels

Comments

@khaosdoctor
Copy link

khaosdoctor commented Jan 15, 2023

Describe the bug

This is both a bug and a feature request (which I'm willing to implement if needed in #790), but when setting up the workspace, deno.fmt is enabled, but even with all the extensions disabled and just deno enabled, it doesn't seem to correctly set the default formatter to denoland.vscode_deno by default.

To Reproduce

To get a better reproducibility disable all your extensions by cmd+shif+p -> Disable all installed extensions:

image

Then enable only the deno extension on the extension manager.

  1. Set up a new directory anyywhere
  2. Initialize deno workspace, answer yes to all questions
  3. There should be a .vscode/settings.json file with these contents:
{
  "deno.enable": true,
  "deno.unstable": true,
}
  1. Create a *.ts file anywhere, type any full TS command with a different formatting then Deno expects, like:
import { resolve } from 'https://deno.land/std/path/mod.ts'
// 						/\ single quotes				  /\ missing ;
  1. Save the file, if you haven't configured editor.formatOnSave option, this shouldn't do anything by default, however if you do cmd+shift+p -> format document, is also doesn't do anything.

Expected behavior

It should apply deno.fmt on the file and the line should look like:

import { resolve } from "https://deno.land/std/path/mod.ts";
//					    /\ double			 			   /\ correct ;

Screenshots

This is a gif of the current behaviour:

Kap Recording - 2023-01-15 12 12 14

I figured out that, if you set "[typescript]": { "editor.defaultFormatter": "denoland.vscode_deno" } in the settings, this would work, like so:

deno-true

Versions

vscode: 1.74.3 deno: 1.29.2 extension: v3.16.0

Proposed solution

Include, by default, these lines in the settings when setting up the workspace:

{
  "[typescript]": {
    "editor.defaultFormatter": "denoland.vscode-deno"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "denoland.vscode-deno"
  }
}

Also would be a nice addition to ask if the user wants to format on save and then include editor.formatOnSave as true as I see there's #328 about it too.

khaosdoctor added a commit to khaosdoctor/vscode_deno that referenced this issue Jan 15, 2023
fix Deno.fmt seems not to be executing by default denoland#789

Signed-off-by: Lucas Santos <lhs.santoss@gmail.com>
@bartlomieju bartlomieju added bug Something isn't working high priority fmt dx labels Jul 10, 2023
@bartlomieju bartlomieju mentioned this issue Jul 11, 2023
17 tasks
@bartlomieju bartlomieju mentioned this issue Oct 9, 2023
7 tasks
@nayeemrmn nayeemrmn changed the title Deno.fmt seems not to be executing by default Add formatter settings on workspace initialization Oct 10, 2023
@nayeemrmn nayeemrmn added enhancement New feature or request and removed bug Something isn't working labels Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants