Skip to content

Commit

Permalink
Add texlab.build.pdfDirectory setting
Browse files Browse the repository at this point in the history
See #911.
  • Loading branch information
pfoerster committed Aug 5, 2023
1 parent 78d2b25 commit 1b96dd9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add `texlab.build.pdfDirectory` setting ([#911](https://github.com/latex-lsp/texlab/issues/911))

## [5.8.0] - 2023-07-30

### Added
Expand Down
2 changes: 2 additions & 0 deletions crates/base-db/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct BuildConfig {
pub forward_search_after: bool,
pub aux_dir: String,
pub log_dir: String,
pub pdf_dir: String,
pub output_filename: Option<PathBuf>,
}

Expand Down Expand Up @@ -115,6 +116,7 @@ impl Default for BuildConfig {
forward_search_after: false,
aux_dir: String::from("."),
log_dir: String::from("."),
pdf_dir: String::from("."),
output_filename: None,
}
}
Expand Down
18 changes: 12 additions & 6 deletions crates/commands/src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ impl CleanCommand {
anyhow::bail!("document '{}' is not a local file", document.uri)
};

let dir = workspace.current_dir(&document.dir);
let dir = workspace
.output_dir(&dir, workspace.config().build.log_dir.clone())
.to_file_path()
.unwrap();
let base_dir = workspace.current_dir(&document.dir);

let flag = match target {
CleanTarget::Auxiliary => "-c",
CleanTarget::Artifacts => "-C",
};

let out_dir = match target {
CleanTarget::Auxiliary => &workspace.config().build.aux_dir,
CleanTarget::Artifacts => &workspace.config().build.pdf_dir,
};

let out_dir = workspace
.output_dir(&base_dir, out_dir.clone())
.to_file_path()
.unwrap();

let executable = String::from("latexmk");
let args = vec![
format!("-outdir={}", dir.display()),
format!("-outdir={}", out_dir.display()),
String::from(flag),
path.display().to_string(),
];
Expand Down
2 changes: 1 addition & 1 deletion crates/commands/src/fwd_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl ForwardSearch {

let dir = workspace.current_dir(&parent.dir);
let dir = workspace
.output_dir(&dir, workspace.config().build.log_dir.clone())
.output_dir(&dir, workspace.config().build.pdf_dir.clone())
.to_file_path()
.unwrap();

Expand Down
10 changes: 8 additions & 2 deletions crates/texlab/src/server/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct BuildOptions {
pub forward_search_after: bool,
pub aux_directory: Option<String>,
pub log_directory: Option<String>,
pub pdf_directory: Option<String>,
pub filename: Option<String>,
}

Expand Down Expand Up @@ -164,12 +165,17 @@ impl From<Options> for Config {
.or_else(|| value.aux_directory.clone())
.unwrap_or_else(|| String::from("."));

config.build.log_dir = value
config.build.pdf_dir = value
.build
.log_directory
.pdf_directory
.or_else(|| value.aux_directory)
.unwrap_or_else(|| String::from("."));

config.build.log_dir = value
.build
.log_directory
.unwrap_or_else(|| config.build.pdf_dir.clone());

config.build.output_filename = value.build.filename.map(PathBuf::from);

config.diagnostics.allowed_patterns = value
Expand Down

0 comments on commit 1b96dd9

Please sign in to comment.