use serde::{Deserialize, Serialize}; use std::path::PathBuf; #[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum BibtexFormatter { Texlab, Latexindent, } impl Default for BibtexFormatter { fn default() -> Self { Self::Texlab } } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct BibtexFormattingOptions { pub line_length: Option, pub formatter: Option, } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] pub struct LatexForwardSearchOptions { pub executable: Option, pub args: Option>, } #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)] #[serde(rename_all = "camelCase")] pub struct LatexLintOptions { pub on_change: Option, pub on_save: Option, } impl LatexLintOptions { pub fn on_change(&self) -> bool { self.on_change.unwrap_or(false) } pub fn on_save(&self) -> bool { self.on_save.unwrap_or(false) } } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct LatexBuildOptions { pub executable: Option, pub args: Option>, pub on_save: Option, pub output_directory: Option, pub forward_search_after: Option, } impl LatexBuildOptions { pub fn executable(&self) -> String { self.executable .as_ref() .map(Clone::clone) .unwrap_or_else(|| "latexmk".to_owned()) } pub fn args(&self) -> Vec { self.args.as_ref().map(Clone::clone).unwrap_or_else(|| { vec![ "-pdf".to_owned(), "-interaction=nonstopmode".to_owned(), "-synctex=1".to_owned(), ] }) } pub fn on_save(&self) -> bool { self.on_save.unwrap_or(false) } pub fn forward_search_after(&self) -> bool { self.forward_search_after.unwrap_or(false) } } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct LatexOptions { pub forward_search: Option, pub lint: Option, pub build: Option, pub root_directory: Option, } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct BibtexOptions { pub formatting: Option, } #[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Options { pub latex: Option, pub bibtex: Option, }