typstfmt icon indicating copy to clipboard operation
typstfmt copied to clipboard

Remove linebreaks within a paragraph when performing auto formatting

Open yjcui opened this issue 1 year ago • 4 comments

First thanks for this great extension!

I am using this extension with VSCode. When performing file formatting, automatic linebreaks will be inserted to break a paragraph, leaving a weired display of multiple lines with different length. Is it possible to keep one paragraph as a single line (in the sense that only one line number for one paragraph in VSCode) and leave the 'linebreak' to the word wrap function from VSCode?

Example

This is what initially put in VSCode editor, and what I want as the whole paragraph is one line (line 34). image

This is what I got after applying formatting through Typst LSP. One paragraph got broken into multiple lines (line 34-47). image

yjcui avatar Mar 29 '24 02:03 yjcui

Did you tried setting line_wrap to false?

FlandiaYingman avatar Mar 29 '24 04:03 FlandiaYingman

Not sure where this parameter is, since I did not specifically install typstfmt and assume typst lsp used it inherently.

Besides, I don't think line-wrap and linebreak are the same thing. line-wrap determines how the editor displays the code and has nothing to do with real linebreak.

yjcui avatar Mar 29 '24 04:03 yjcui

This is the right place for this ! :)

line_wrap option is exactly what you're looking for but it's a bit tedious to setup with typst-lsp, you have to have a typstfmt config file local to your project.

it's a problem with two solutions:

  • disable linewrap per default for the next release
  • better config handling in typst-lsp

astrale-sharp avatar Mar 29 '24 08:03 astrale-sharp

I would vote for better integration with typst-lsp. Maintaining a local file for each project is tedious.

FYI, I did find below section in typst-lsp's 'package.json' file. If set wordWrap to off, the whole paragraph will be displayed as literally one line without wrap. But automatic formatting through typst-lsp still break it into lines with multiple line numbers.

"configurationDefaults": {
			"[typst]": {
				"editor.wordWrap": "on",
				"editor.semanticHighlighting.enabled": true,
				"editor.tabSize": 2
			}
		},

yjcui avatar Mar 29 '24 13:03 yjcui