@@ -27,7 +27,7 @@ pub use helix_core::register::Registers;
27use helix_core::syntax;
27use helix_core::syntax;
28use helix_core::{Position, Selection};
28use helix_core::{Position, Selection};
30−use serde::Deserialize;
30+use serde::{Deserialize, Serialize};
32fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error>
32fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error>
@@ -37,7 +37,7 @@ where
37 Ok(Duration::from_millis(millis))
37 Ok(Duration::from_millis(millis))
40−#[derive(Debug, Clone, PartialEq, Deserialize)]
40+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
41#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
41#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
42pub struct FilePickerConfig {
42pub struct FilePickerConfig {
43 /// IgnoreOptions
43 /// IgnoreOptions
@@ -77,7 +77,7 @@ impl Default for FilePickerConfig {
80−#[derive(Debug, Clone, PartialEq, Deserialize)]
80+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
81#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
82pub struct Config {
82pub struct Config {
83 /// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5.
83 /// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5.
@@ -109,7 +109,7 @@ pub struct Config {
109 pub true_color: bool,
109 pub true_color: bool,
112−#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
112+#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
113#[serde(rename_all = "kebab-case")]
113#[serde(rename_all = "kebab-case")]
114pub enum LineNumber {
114pub enum LineNumber {
115 /// Show absolute line number
115 /// Show absolute line number
@@ -119,6 +119,18 @@ pub enum LineNumber {
119 Relative,
119 Relative,
122+impl std::str::FromStr for LineNumber {
123+ type Err = anyhow::Error;
125+ fn from_str(s: &str) -> Result<Self, Self::Err> {
126+ match s.to_lowercase().as_str() {
127+ "absolute" | "abs" => Ok(Self::Absolute),
128+ "relative" | "rel" => Ok(Self::Relative),
129+ _ => anyhow::bail!("Line number can only be `absolute` or `relative`."),
122impl Default for Config {
134impl Default for Config {
123 fn default() -> Self {
135 fn default() -> Self {