Skip to content

Commit

Permalink
feat(Config): Add config settings for editors
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome authored and alex-ketch committed Aug 6, 2021
1 parent 4471959 commit 9106e25
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
17 changes: 17 additions & 0 deletions node/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,23 @@ export interface Config {
*/
auto?: boolean
}
/**
* Configuration settings for document editors.
*/
editors?: {
/**
* Default format for new documents
*/
defaultFormat?: string
/**
* Show line numbers
*/
lineNumbers?: boolean
/**
* Enable wrapping of lines
*/
lineWrapping?: boolean
}
/**
* Configuration settings used when upgrading the application (and optionally plugins) automatically, in the background. These settings are NOT used as defaults when using the CLI `upgrade` command directly.
*/
Expand Down
28 changes: 24 additions & 4 deletions rust/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use crate::{logging, projects, telemetry, utils::schemas};
use defaults::Defaults;
use eyre::{bail, Result};
use once_cell::sync::Lazy;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::env;
use std::fs;
use std::io::Write;
use std::path::PathBuf;
use std::{env, fs, io::Write, path::PathBuf};
use tokio::sync::Mutex;
use validator::Validate;

Expand Down Expand Up @@ -49,11 +47,33 @@ pub struct Config {
#[validate]
pub binaries: crate::binaries::config::BinariesConfig,

pub editors: EditorsConfig,

#[cfg(feature = "upgrade")]
#[validate]
pub upgrade: crate::upgrade::config::UpgradeConfig,
}

/// Editors
///
/// Configuration settings for document editors.
#[derive(Debug, Defaults, PartialEq, Clone, JsonSchema, Deserialize, Serialize)]
#[serde(default, rename_all = "camelCase")]
#[schemars(deny_unknown_fields)]
pub struct EditorsConfig {
/// Default format for new documents
#[def = "\"md\".to_string()"]
pub default_format: String,

/// Show line numbers
#[def = "false"]
pub line_numbers: bool,

/// Enable wrapping of lines
#[def = "true"]
pub line_wrapping: bool,
}

impl Config {
const CONFIG_FILE: &'static str = "config.toml";

Expand Down

0 comments on commit 9106e25

Please sign in to comment.