Skip to content

Commit

Permalink
Resolve paths that are part of TEXINPUTS (#1252)
Browse files Browse the repository at this point in the history
Add paths in TEXINPUTS to the distro resolver similar to the way it is done for BIBINPUTS.
  • Loading branch information
pfoerster authored Oct 26, 2024
1 parent 52f9fdc commit d1f01f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support starred variants in "Go to References" ([#1234](https://github.com/latex-lsp/texlab/issues/1234))
- Add `texlab.latexindent.replacement` setting to allow passing a replacement flag to `latexindent` ([#1222](https://github.com/latex-lsp/texlab/issues/1222))
- Don't require a label to show section numbers for document symbols ([#910](https://github.com/latex-lsp/texlab/issues/910))
- Support navigating to files that are part of the `TEXINPUTS` similar to `BIBINPUTS` ([#1228](https://github.com/latex-lsp/texlab/discussions/1228))

### Fixed

Expand Down
17 changes: 12 additions & 5 deletions crates/distro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ mod language;
mod miktex;
mod texlive;

use std::process::{Command, Stdio};
use std::{
env,
process::{Command, Stdio},
};

use anyhow::Result;

Expand Down Expand Up @@ -70,8 +73,14 @@ impl Distro {
DistroKind::Tectonic | DistroKind::Unknown => FileNameDB::default(),
};

if let Some(bibinputs) = std::env::var_os("BIBINPUTS") {
for dir in std::env::split_paths(&bibinputs) {
Self::read_env_dir(&mut file_name_db, "TEXINPUTS");
Self::read_env_dir(&mut file_name_db, "BIBINPUTS");
Ok(Self { kind, file_name_db })
}

fn read_env_dir(file_name_db: &mut FileNameDB, env_var: &str) {
if let Some(paths) = env::var_os(env_var) {
for dir in env::split_paths(&paths) {
if let Ok(entries) = std::fs::read_dir(dir) {
for file in entries
.flatten()
Expand All @@ -83,7 +92,5 @@ impl Distro {
}
}
}

Ok(Self { kind, file_name_db })
}
}

0 comments on commit d1f01f8

Please sign in to comment.