sqls icon indicating copy to clipboard operation
sqls copied to clipboard

Formatting breaks PostgreSQL code

Open cs-clarence opened this issue 2 years ago • 8 comments

I'm using neovim with nanotee/sqls.nvim plugin but formatting doesn't seem to work properly.

For example, this code:

CREATE TABLE
  users (
    id BIGSERIAL PRIMARY KEY,
    username TEXT UNIQUE NOT NULL CHECK > 8,
    password TEXT NOT NULL
  );

Will be formatted to:

CREATETABLEusers(
  id BIGSERIALPRIMARYKEY,
  usernameTEXTUNIQUENOTNULLCHECK>8,
  passwordTEXTNOTNULL
);

cs-clarence avatar Sep 06 '22 12:09 cs-clarence

Check whether you have two sqls LSP servers active same time.

janneliukkonen avatar Sep 15 '22 13:09 janneliukkonen

Check whether you have two sqls LSP servers active same time.

I only have sqls for sql files

cs-clarence avatar Sep 17 '22 04:09 cs-clarence

Same Problem here:

NVIM v0.8.0-1210-gd367ed9b2 Build type: Release LuaJIT 2.1.0-beta3 sqls version: 0.2.22

The only Langauge Server Attached to the session are copilot and sqls: image

guilty-p01nt3r avatar Oct 04 '22 15:10 guilty-p01nt3r

Running into the same issue: image

After writing: image

Output of LspInfo: image

CiaronHowell avatar Oct 10 '22 15:10 CiaronHowell

just ran into same issue

AndrewWinterman avatar Oct 28 '22 19:10 AndrewWinterman

I have a hunch the nvim plugin is allowing the document formatting params to be their defaults, meaning InsertSpaces is false here:

type FormattingOptions struct {
	TabSize                float64 `json:"tabSize"`
	InsertSpaces           bool    `json:"insertSpaces"`
	TrimTrailingWhitespace bool    `json:"trimTrailingWhitespace,omitempty"`
	InsertFinalNewline     bool    `json:"insertFinalNewline,omitempty"`
	TrimFinalNewlines      bool    `json:"trimFinalNewlines,omitempty"`
}

AWinterman avatar Nov 04 '22 17:11 AWinterman

okay, this was actually quite silly, i had no conenctions configured because i thought the docs for the neovim plugin that wraps the underlying lsp plugin were all i needed to do.

AWinterman avatar Nov 04 '22 18:11 AWinterman

same happening to me, breaking all queries with auto format

gipo355 avatar Feb 06 '24 18:02 gipo355