Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring the PDF directory explicitly #914

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Use bibliographies found in `BIBINPUTS` environment variable ([#493](https://github.com/latex-lsp/texlab/issues/493))
- Add `texlab.build.pdfDirectory` setting ([#911](https://github.com/latex-lsp/texlab/issues/911))

## [5.8.0] - 2023-07-30

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