summaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-22 04:47:39 +0000
committerBlaž Hrastnik2021-03-22 04:53:36 +0000
commit5e6716c89c0909bc374e26bedbba703427f9aa26 (patch)
tree658163e26962c436d0406f8dcf0d5f900116efdc /helix-view/src/document.rs
parent698e4ddea46e9c94d537c8e4a6c69e7dc9ee1947 (diff)
Add tab_width and indent_unit config.
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index e606ec3c..f6c7c70d 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -296,6 +296,26 @@ impl Document {
self.syntax.as_ref()
}
+ /// Tab size in columns.
+ pub fn tab_width(&self) -> usize {
+ self.language
+ .as_ref()
+ .and_then(|config| config.indent_config.as_ref())
+ .map(|config| config.tab_width)
+ .unwrap_or(4) // fallback to 4 columns
+ }
+
+ /// Returns a string containing a single level of indentation.
+ pub fn indent_unit(&self) -> &str {
+ self.language
+ .as_ref()
+ .and_then(|config| config.indent_config.as_ref())
+ .map(|config| config.indent_unit.as_str())
+ .unwrap_or(" ") // fallback to 2 spaces
+
+ // " ".repeat(TAB_WIDTH)
+ }
+
#[inline]
/// File path on disk.
pub fn path(&self) -> Option<&PathBuf> {