vscode-postgres icon indicating copy to clipboard operation
vscode-postgres copied to clipboard

There is no document formatter for 'postgres'-files installed.

Open guybowden opened this issue 6 years ago • 2 comments

Not sure if this should be posted here but I'm having trouble with autoformatting "Postgres" files:

If the language mode is set to Postgres then this extension works, but I can't autoformat, if I change the language mode to SQL then I can autoformat, but this extension doesn't work.

How can I have both?

guybowden avatar Feb 15 '19 09:02 guybowden

Well that is correct, I haven't created a formatter for SQL so that explains why a Postgres file has that message.

However, I believe the stock SQL language doesn't have a formatter either, as I am getting a similar message for sql files. You might have some other extension installed that is providing that formatting for SQL files.

There is a formatter api so it could be done (part of a language server implementation). It would require an actual language parser (I'm currently doing just basic statement splitting and handing it of to postgres for actual analysis), and responding with a bunch of TextEdit operations to get the formatting to go - which doesn't sound simple. This other extension might be a starting point - but even then it would take some time to implement.

Borvik avatar Feb 15 '19 11:02 Borvik

Yes, I have a formatter plugin (https://github.com/bradymholt/vscode-pgFormatter) that works on SQL files but not on Postgres. I'm not a vs-code plugin dev, so not sure where to look to get a particular formatter plugin to work on particular file/language types.

guybowden avatar Feb 26 '19 08:02 guybowden