Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set soft-wrap.enable true should be set by default in text-based files #8331

Open
tapyu opened this issue Sep 19, 2023 · 13 comments
Open

set soft-wrap.enable true should be set by default in text-based files #8331

tapyu opened this issue Sep 19, 2023 · 13 comments
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@tapyu
Copy link

tapyu commented Sep 19, 2023

I suppose that it is sensible to set the soft-wrap feature to true in the default settings for markdown files as it often involves long paragraphs....

@tapyu tapyu added the C-enhancement Category: Improvements label Sep 19, 2023
@archseer
Copy link
Member

Agreed but that config option is currently global. It'll require some work to introduce document specific/language specific config.

@tapyu
Copy link
Author

tapyu commented Sep 19, 2023

@archseer I am really sorry, but what do you mean by "being global"? Can't we set this config for markdown files only? For instance:

[[language]]
name = "markdown"
scope = "source.md"
injection-regex = "md|markdown"
file-types = ["md", "markdown", "PULLREQ_EDITMSG"]
soft-wrap.enable = true
roots = [".marksman.toml"]
language-servers = [ "marksman" ]
indent = { tab-width = 2, unit = "  " }

??

@kirawi
Copy link
Member

kirawi commented Sep 19, 2023

No. By global it means that it's only in config.toml

@gabydd
Copy link
Member

gabydd commented Sep 19, 2023

In the case of softwrap it can be set per language, I don't think it is in the docs but it does work and is defined here:

pub soft_wrap: Option<SoftWrap>,

@tapyu
Copy link
Author

tapyu commented Sep 19, 2023

I also confirm that the soft-wrap feature can be set to a specific language. At least, it properly works for the ~/.config/helix/languages.toml file

❯ cat languages.toml
[[language]]
name = "markdown"
soft-wrap.enable = true

@archseer
Copy link
Member

Hmm seems that this isn't documented

| Key | Description |
| ---- | ----------- |
| `name` | The name of the language |
| `language-id` | The language-id for language servers, checkout the table at [TextDocumentItem](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem) for the right id |
| `scope` | A string like `source.js` that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually `source.<name>` or `text.<name>` in case of markup languages |
| `injection-regex` | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential [language injection][treesitter-language-injection] site. |
| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. See the file-type detection section below. |
| `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` |
| `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |
| `auto-format` | Whether to autoformat this language when saving |
| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `Error`, `Warning`, `Info`, `Hint`) |
| `comment-token` | The token to use as a comment-token |
| `indent` | The indent to use. Has sub keys `unit` (the text inserted into the document when indenting; usually set to N spaces or `"\t"` for tabs) and `tab-width` (the number of spaces rendered for a tab) |
| `language-servers` | The Language Servers used for this language. See below for more information in the section [Configuring Language Servers for a language](#configuring-language-servers-for-a-language) |
| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
| `formatter` | The formatter for the language, it will take precedence over the lsp when defined. The formatter must be able to take the original file as input from stdin and write the formatted file to stdout |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set, defaults to `editor.text-width` |
| `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml`. Overwrites the setting of the same name in `config.toml` if set. |

@arcstur
Copy link

arcstur commented Dec 5, 2023

Since the PR was merged I think this can be closed

@the-mikedavis
Copy link
Member

That PR added the docs for soft-wrap in the languages.toml config but this issue is about adding soft-wrap = true for the markdown block in the default languages.toml config in this repo:

helix/languages.toml

Lines 1328 to 1335 in c3cb179

[[language]]
name = "markdown"
scope = "source.md"
injection-regex = "md|markdown"
file-types = ["md", "markdown", "PULLREQ_EDITMSG", "mkd", "mdwn", "mdown", "markdn", "mdtxt", "mdtext", "workbook"]
roots = [".marksman.toml"]
language-servers = [ "marksman" ]
indent = { tab-width = 2, unit = " " }

@the-mikedavis the-mikedavis added E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR A-language-support Area: Support for programming/text languages labels Dec 5, 2023
@arcstur
Copy link

arcstur commented Dec 5, 2023

Oh, you're right, haha. So, are we going to add that? If yes I can make the PR.

@the-mikedavis
Copy link
Member

Yep feel free to send a PR

@wmstack
Copy link
Contributor

wmstack commented Mar 5, 2024

Also text files? This is how it is in Zed.

@tapyu
Copy link
Author

tapyu commented Mar 8, 2024

It is also sensible to set it to .txt files, for sure.

@tapyu tapyu changed the title set soft-wrap.enable true should be set by default in .md files set soft-wrap.enable true should be set by default in text-based files Mar 8, 2024
@wmstack
Copy link
Contributor

wmstack commented Mar 8, 2024

Would that work for empty scratch buffers by default as well? Are they assumed to be text-based?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants