aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorJJ2023-11-01 00:37:26 +0000
committerJJ2023-11-01 04:08:32 +0000
commit5c371208692df2727d02a37646b7829f011680a8 (patch)
tree5f6cce3547e367942746ceb6499018628297a595 /helix-view/src/editor.rs
parentf6021dd0cdd8cf6795f024e396241cb0af2ca368 (diff)
Add file explorer and tree helper
ref: https://github.com/helix-editor/helix/issues/200 ref: https://github.com/helix-editor/helix/pull/2377 ref: https://github.com/helix-editor/helix/pull/5566 ref: https://github.com/helix-editor/helix/pull/5768 Co-authored-by: cossonleo <cossonleo@foxmail.com> Co-authored-by: wongjiahau <hou32hou@gmail.com>
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 7af28ccc..f285aa99 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -212,6 +212,30 @@ impl Default for FilePickerConfig {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
+pub struct ExplorerConfig {
+ pub position: ExplorerPosition,
+ /// explorer column width
+ pub column_width: usize,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+pub enum ExplorerPosition {
+ Left,
+ Right,
+}
+
+impl Default for ExplorerConfig {
+ fn default() -> Self {
+ Self {
+ position: ExplorerPosition::Left,
+ column_width: 36,
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct Config {
/// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5.
pub scrolloff: usize,
@@ -280,6 +304,8 @@ pub struct Config {
pub bufferline: BufferLine,
/// Vertical indent width guides.
pub indent_guides: IndentGuidesConfig,
+ /// Explorer configuration.
+ pub explorer: ExplorerConfig,
/// Whether to color modes with different colors. Defaults to `false`.
pub color_modes: bool,
pub soft_wrap: SoftWrap,
@@ -835,6 +861,7 @@ impl Default for Config {
whitespace: WhitespaceConfig::default(),
bufferline: BufferLine::default(),
indent_guides: IndentGuidesConfig::default(),
+ explorer: ExplorerConfig::default(),
color_modes: false,
soft_wrap: SoftWrap {
enable: Some(false),
@@ -1011,6 +1038,18 @@ pub enum CloseError {
SaveError(anyhow::Error),
}
+impl From<CloseError> for anyhow::Error {
+ fn from(error: CloseError) -> Self {
+ match error {
+ CloseError::DoesNotExist => anyhow::anyhow!("Document doesn't exist"),
+ CloseError::BufferModified(error) => {
+ anyhow::anyhow!(format!("Buffer modified: '{error}'"))
+ }
+ CloseError::SaveError(error) => anyhow::anyhow!(format!("Save error: {error}")),
+ }
+ }
+}
+
impl Editor {
pub fn new(
mut area: Rect,