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

lsp: does not honor "typescript.preferences.quoteStyle" when adding imports #15487

Closed
johnspurlock opened this issue Aug 7, 2021 · 11 comments · Fixed by #20891
Closed

lsp: does not honor "typescript.preferences.quoteStyle" when adding imports #15487

johnspurlock opened this issue Aug 7, 2021 · 11 comments · Fixed by #20891
Assignees
Labels
feat new feature (which has been agreed to/accepted) lsp related to the language server

Comments

@johnspurlock
Copy link
Contributor

If the user sets their preferred quote style (say to single quoting), the deno extension does not honor it when adding new imports.

To Reproduce

  1. Set TypeScript › Preferences: Quote Style to 'single' (ie "typescript.preferences.quoteStyle": "single" )
  2. Use the deno extension to add a new import

Notice the new import is added with the default double quotes
i.e. import { Foo } from "./whatever.ts";

Expected behavior

The new import should be added with single quotes
i.e. import { Foo } from './whatever.ts';

Versions

vscode: 1.58 deno: 1.12.2 extension: 3.7.0

@johnspurlock
Copy link
Contributor Author

I still hit this every single day - perhaps someone could point me to the spot where these imports are generated in the extension? I'm new to vscode extension development

@kitsonk kitsonk transferred this issue from denoland/vscode_deno Aug 17, 2022
@kitsonk kitsonk changed the title Deno extension does not honor "typescript.preferences.quoteStyle" when adding imports lsp: does not honor "typescript.preferences.quoteStyle" when adding imports Aug 17, 2022
@kitsonk kitsonk added feat new feature (which has been agreed to/accepted) lsp related to the language server and removed enhancement labels Aug 17, 2022
@kitsonk
Copy link
Contributor

kitsonk commented Aug 17, 2022

This is non-trivial to implement, which is why it has been sort of sitting there for a long time.

The things that would need to be done:

  • The language server reads the typescript.preferences (or we implement deno.preferences to avoid breaking changes in the typescript space we can't control)
  • The language server forms those into the user settings options bag that is sent into the TypeScript language server (using how vscode manages it as a reference point)
  • Update the non-TypeScript language server to respect them.
  • Write integration tests to test the functionality.

The whole config to TypeScript language server "user preferences" is fairly complex, but once done it would unlock a lot of other things when the TypeScript language server provides code completions.

One of the reasons it has been been a lower priority too is the prevalence of auto-formatter, either the one built in to Deno or prettier, which then reformats on save in an opinionated way.

@KaKi87
Copy link

KaKi87 commented Jul 15, 2023

Hello,
Any news on this ?
Thanks

@nayeemrmn
Copy link
Collaborator

As of #20184 you can add { "fmt": { "singleQuote": true } } to your deno.json and it'll be respected.

We could easily support typescript.preferences.quoteStyle now too with #20593, but it's not good to introduce differences between completion formatting and deno fmt.

@KaKi87
Copy link

KaKi87 commented Oct 10, 2023

We could easily support typescript.preferences.quoteStyle now too

This issue should stay open until support is implemented since that's precisely what has been asked, which I'm in favor of, otherwise it means that every project requires a deno.json file just because of that preference even if it didn't ever need one to this day.

Thanks

@nayeemrmn
Copy link
Collaborator

This issue should stay open until support is implemented since that's precisely what has been asked, which I'm in favor of, otherwise it means that every project requires a deno.json file just because of that preference even if it didn't ever need one to this day.

The deno.json solution wasn't working at the time this issue was open, so I did some inference if that's okay.

The typescript.preferences.quoteStyle option is probably a wontfix because to come along with that there are a bunch of options in typescript.format.*. Let's say we pass them through but favour deno.json if the same option is specified there. Well there are lots of options in typescript.format that deno fmt doesn't support, and by passing those through there would be irresolvable conflicts between deno fmt and the formatter. Hope that makes sense.

@KaKi87
Copy link

KaKi87 commented Oct 10, 2023

I'm sorry it's not really okay because we're asking for the ability to globally set the preference while that solution requires to be applied to every single individual project.

@johnspurlock
Copy link
Contributor Author

I see what @nayeemrmn means, but I think in the scenario where deno.json doesn't exist, or fmt key isn't specified, the plugin should respect typescript.preferences.quoteStyle - there really is no ambiguity there, and it would help so many of us out here

@nayeemrmn
Copy link
Collaborator

Okay we can consider passing through these options when there's no deno.json

@nayeemrmn
Copy link
Collaborator

Hmm it looks like the typescript.format section shouldn't be factored in for auto-imports, quickfixes etc. That's used for Format Document in the command palette and the like. So it would just be typescript.preferences.quoteStyle.

@johnspurlock
Copy link
Contributor Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted) lsp related to the language server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants