summaryrefslogtreecommitdiff
path: root/book/src
diff options
context:
space:
mode:
authorClément Delafargue2023-03-08 02:02:11 +0000
committerGitHub2023-03-08 02:02:11 +0000
commit8dd1ab48997fe774165b3aee5d366833c9660710 (patch)
tree3a60b99ae424514b3516301127623518de58fb16 /book/src
parentf4bdbe4674e6d023a63d2e64aec48c8c8598be67 (diff)
Softwrapping improvements (#5893)
* use max_line_width + 1 during softwrap to account for newline char Helix softwrap implementation always wraps lines so that the newline character doesn't get cut off so he line wraps one chars earlier then in other editors. This is necessary, because newline chars are always selecatble in helix and must never be hidden. However That means that `max_line_width` currently wraps one char earlier than expected. The typical definition of line width does not include the newline character and other helix commands like `:reflow` also don't count the newline character here. This commit makes softwrap use `max_line_width + 1` instead of `max_line_width` to correct the impedance missmatch. * fix typos Co-authored-by: Jonathan Lebon <jonathan@jlebon.com> * Add text-width to config.toml * text-width: update setting documentation * rename leftover config item * remove leftover max-line-length occurrences * Make `text-width` optional in editor config When it was only used for `:reflow` it made sense to have a default value set to `80`, but now that soft-wrapping uses this setting, keeping a default set to `80` would make soft-wrapping behave more aggressively. * Allow softwrapping to ignore `text-width` Softwrapping wraps by default to the viewport width or a configured `text-width` (whichever's smaller). In some cases we only want to set `text-width` to use for hard-wrapping and let longer lines flow if they have enough space. This setting allows that. * Revert "Make `text-width` optional in editor config" This reverts commit b247d526d69adf41434b6fd9c4983369c785aa22. * soft-wrap: allow per-language overrides * Update book/src/configuration.md Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de> * Update book/src/languages.md Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de> * Update book/src/configuration.md Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de> --------- Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de> Co-authored-by: Jonathan Lebon <jonathan@jlebon.com> Co-authored-by: Alex Boehm <alexb@ozrunways.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'book/src')
-rw-r--r--book/src/configuration.md14
-rw-r--r--book/src/languages.md2
2 files changed, 9 insertions, 7 deletions
diff --git a/book/src/configuration.md b/book/src/configuration.md
index 5410024b..aebf5ff0 100644
--- a/book/src/configuration.md
+++ b/book/src/configuration.md
@@ -55,6 +55,7 @@ signal to the Helix process on Unix operating systems, such as by using the comm
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
+| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap_at_text_width` is set | `80` |
### `[editor.statusline]` Section
@@ -314,12 +315,13 @@ Currently unused
Options for soft wrapping lines that exceed the view width:
-| Key | Description | Default |
-| --- | --- | --- |
-| `enable` | Whether soft wrapping is enabled | `false` |
-| `max-wrap` | Maximum free space left at the end of the line | `20` |
-| `max-indent-retain` | Maximum indentation to carry over when soft wrapping a line | `40` |
-| `wrap-indicator` | Text inserted before soft wrapped lines, highlighted with `ui.virtual.wrap` | `↪ ` |
+| Key | Description | Default |
+| --- | --- | --- |
+| `enable` | Whether soft wrapping is enabled. | `false` |
+| `max-wrap` | Maximum free space left at the end of the line. | `20` |
+| `max-indent-retain` | Maximum indentation to carry over when soft wrapping a line. | `40` |
+| `wrap-indicator` | Text inserted before soft wrapped lines, highlighted with `ui.virtual.wrap` | `↪ ` |
+| `wrap-at-text-width` | Soft wrap at `text-width` instead of using the full viewport size. | `false` |
Example:
diff --git a/book/src/languages.md b/book/src/languages.md
index 8a8f3bb6..5ed69505 100644
--- a/book/src/languages.md
+++ b/book/src/languages.md
@@ -63,7 +63,7 @@ These configuration keys are available:
| `config` | Language Server configuration |
| `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 |
-| `max-line-length` | Maximum line length. Used for the `:reflow` command and soft-wrapping |
+| `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` |
### File-type detection and the `file-types` key