diff options
Diffstat (limited to 'helix-core')
-rw-r--r-- | helix-core/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-core/src/lib.rs | 1 | ||||
-rw-r--r-- | helix-core/src/syntax.rs | 1 | ||||
-rw-r--r-- | helix-core/src/wrap.rs | 7 |
4 files changed, 10 insertions, 0 deletions
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index 6e019a42..ab937f0b 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -41,6 +41,7 @@ encoding_rs = "0.8" chrono = { version = "0.4", default-features = false, features = ["alloc", "std"] } etcetera = "0.3" +textwrap = "0.15.0" [dev-dependencies] quickcheck = { version = "1", default-features = false } diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index 02341265..a022a42a 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -27,6 +27,7 @@ pub mod syntax; pub mod test; pub mod textobject; mod transaction; +pub mod wrap; pub mod unicode { pub use unicode_general_category as category; diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 3f9e7bcf..eab3ab79 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -67,6 +67,7 @@ pub struct LanguageConfiguration { pub shebangs: Vec<String>, // interpreter(s) associated with language pub roots: Vec<String>, // these indicate project roots <.git, Cargo.toml> pub comment_token: Option<String>, + pub max_line_length: Option<usize>, #[serde(default, skip_serializing, deserialize_with = "deserialize_lsp_config")] pub config: Option<serde_json::Value>, diff --git a/helix-core/src/wrap.rs b/helix-core/src/wrap.rs new file mode 100644 index 00000000..eabc47d4 --- /dev/null +++ b/helix-core/src/wrap.rs @@ -0,0 +1,7 @@ +use smartstring::{LazyCompact, SmartString}; + +/// Given a slice of text, return the text re-wrapped to fit it +/// within the given width. +pub fn reflow_hard_wrap(text: &str, max_line_len: usize) -> SmartString<LazyCompact> { + textwrap::refill(text, max_line_len).into() +} |