astrale-sharp / typstfmt

Apache License 2.0
253 stars 25 forks source link

Remove linebreaks within a paragraph when performing auto formatting #163

Open yjcui opened 7 months ago

yjcui commented 7 months ago

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

FlandiaYingman commented 7 months ago

Did you tried setting line_wrap to false?

yjcui commented 7 months ago

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.

astrale-sharp commented 7 months ago

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:

yjcui commented 7 months ago

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
            }
        },