sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
132 stars 11 forks source link

Option to remove whitspace around autocompleted import statements #166

Closed silverwind closed 1 year ago

silverwind commented 1 year ago

Is there an option to change space around variables in a autocompleted import statement? e.g.

import { something } from "./something.js";

into

import {something} from "./something.js";

I tried disabling space-related settings but none seem to have any effect on import statements.

rchl commented 1 year ago

Not aware of a setting for that.

Your options are to create a feature request in https://github.com/microsoft/TypeScript/issues or use LSP-eslint with specific rule that correct that on save.

silverwind commented 1 year ago

Ok, assuming typescript gains this option, do you need to add support here or is that automatic?

rchl commented 1 year ago

I pick up all new typescript options whenever typescript adds new ones so more or less "automatic". No need for an issue for tracking.

silverwind commented 1 year ago

Okay, closing here then.

rchl commented 1 year ago

Actually I think there is already an option for this: typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces or the javascript equivalent.

rchl commented 1 year ago

If it doesn't work after setting this one then try formatting the document first (LSP: Format file) and then try completions again. If it works then then it's something that should be fixed in the server.

rchl commented 1 year ago

Tested this myself and noticed that depending on how the import is completed, it either follows or doesn't follow the setting:

https://user-images.githubusercontent.com/153197/192781891-75440cef-0463-4b23-86bd-cd609fdcfb90.mov

I've reproduced it in VSCode also so I would suggest just reporting it as a bug in TypeScript.

If you report mentioning the issue being reproducible in VSCode then it has much higher chance of being looked at. It's enough to set "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false to reproduce there.

silverwind commented 1 year ago

I can reproduce in ST as well, import foo<tab>, looks to just ignore the insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces option.

rchl commented 1 year ago

Yes, I know it reproduces but since both TypeScript and VSCode are made by Microsoft it's easier for them to look at reports that report against VSCode.

silverwind commented 5 months ago

I looked into this again. Behaviour is the same in VSCode, so it's definitely not a bug in LSP, but in vscode or its typescript extension.

Reported it at https://github.com/microsoft/TypeScript/issues/57834.