Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Make main file configurable #426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt, path::PathBuf};
use std::{fmt, path::PathBuf, str::FromStr};

use anyhow::bail;
use futures::future::BoxFuture;
Expand Down Expand Up @@ -53,6 +53,7 @@ pub enum SemanticTokensMode {
pub type Listener<T> = Box<dyn FnMut(&T) -> BoxFuture<anyhow::Result<()>> + Send + Sync>;

const CONFIG_ITEMS: &[&str] = &[
"mainFile",
"exportPdf",
"rootPath",
"semanticTokens",
Expand Down Expand Up @@ -131,6 +132,20 @@ impl Config {
self.root_path = Some(root_path);
}
}
let main_file = update.get("mainFile");
if let Some(main_file) = main_file {
if main_file.is_null() {
self.main_file = None;
}
else {
self.main_file = main_file
.as_str()
// TODO support relative URLs
.map(Url::from_str)
// TODO user feedback when URL not ok
.and_then(|r| r.ok());
}
}

let semantic_tokens = update
.get("semanticTokens")
Expand Down
Loading