lemminx icon indicating copy to clipboard operation
lemminx copied to clipboard

Snippet should respect formatting settings

Open angelozerr opened this issue 5 years ago • 5 comments

Snippet should respect formatting settings

angelozerr avatar May 12 '20 16:05 angelozerr

snippets should simply be processed by the formatter before being sent back to the client

fbricon avatar May 12 '20 16:05 fbricon

snippets should simply be processed by the formatter before being sent back to the client

Indeed it's the simple mean to fix thi sissue, but it means each time you type something, you will format all available snippets?

angelozerr avatar May 13 '20 08:05 angelozerr

yes, but since they're small, it should be fast

fbricon avatar May 13 '20 08:05 fbricon

they can even be cached, until preferences changes

fbricon avatar May 13 '20 08:05 fbricon

If we wish to apply formatter to the snippet, it requires to improve dramasticly the formatter to format invalid content. For instance if you try to format:

<!DOCTYPE ${1:root-element} PUBLIC \"${2:public-id}\" \"${3:file}.dtd\">
<${1:root-element}>${0}
</${1:root-element}>

the formatter result is very bad:

<!DOCTYPE ${1:root-element} PUBLIC \"${2:public-id}\" \"${3:file}.dtd\">
<null>${0}

The hard thing is that <${1:root-element}> is not a valid tag name (because it contains $), so the parser (today) cannot consider it's a valid tag name. This issue is very hard and requires some investigation about formatting invalid content and in same time $ must be considered as a valid tag name (for the snippet usecase).

angelozerr avatar Jun 11 '20 06:06 angelozerr