[prettier-plugin-sql] does not return cursor Position
I added prettier-plugin-sql to my Prettier extension for Nova. I also use Prettiers formatWithCursor to retrieve the correct cursor Position after formatting.
prettier-plugin-sql seems to always return 0 as position, so the cursor always jumps to the beginning of the document.
Please provide a online runnable reproduction. I'm not familiar with the formatWithCurson API.
Dumb, question, but what would be an online runnable reproduction? I can only point you to the API doc.
https://prettier.io/docs/api/#prettierformatwithcursorsource--options
I'm just handing the cursor position to Prettier it and retrieve the new cursor position after formatting. That works for all languages supported by Prettier and all other plugins I use. e.g @prettier/plugin-xml and @prettier/plugin-php. So, not sure what I can do here?
I didn't find what the plugin author need to do with formatWithCursor API or even cursor keyword: https://prettier.io/docs/plugins#developing-plugins
Maybe we can do better here?
https://github.com/un-ts/prettier/blob/2b277b89f9d1bb96ba20364cc60480828eabc0e3/packages/sql/src/index.ts#L46-L47
cc @fisker
Here is how the cursor node is located https://github.com/prettier/prettier/blob/c2ad588ec38f204427cad076fa58d608a3e9e02d/src/main/get-cursor-node.js#L20, Prettier will insert two prettier.doc.builders.cursor around that node when printing node.
As a side note, the TOML plugin has the same issue.