From 0e3a73a20ebb58f52468e3bc7bb4dc14c334840d Mon Sep 17 00:00:00 2001 From: Luis Eduardo Bueso de Barrio Date: Fri, 6 Mar 2026 15:17:45 +0100 Subject: [PATCH] texlab-patched --- .gitignore | 1 + devshells/default.nix | 2 +- flake.nix | 9 ++++- pkgs/default.nix | 8 ++++- pkgs/texlab/default.nix | 24 +++++++++++++ pkgs/texlab/patches/subfile-diagnostics.patch | 36 +++++++++++++++++++ 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 pkgs/texlab/default.nix create mode 100644 pkgs/texlab/patches/subfile-diagnostics.patch diff --git a/.gitignore b/.gitignore index 3b21f02..bfbc55e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ result result-* .direnv /.envrc +/.agent-shell/ diff --git a/devshells/default.nix b/devshells/default.nix index 6edfd36..f3e0227 100644 --- a/devshells/default.nix +++ b/devshells/default.nix @@ -1,4 +1,3 @@ - { pkgs, system, @@ -12,6 +11,7 @@ pkgs.mkShell { nixfmt-rfc-style nil nix-tree + nix (jailed-agents.lib.${system}.makeJailed system { agentTool = "opencode"; extraPkgs = diff --git a/flake.nix b/flake.nix index 1fc8dd7..19b353f 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,10 @@ flake-utils.url = "github:numtide/flake-utils"; jailed-agents.url = "git+https://gitea@gitea.bueso.eu/luis/jailed-agents"; mcp-servers.url = "git+https://gitea@gitea.bueso.eu/luis/mcp-servers"; + texlab-src = { + url = "github:latex-lsp/texlab/v5.25.1"; + flake = false; + }; }; outputs = @@ -24,6 +28,7 @@ flake-utils, jailed-agents, mcp-servers, + texlab-src, }: flake-utils.lib.eachDefaultSystem ( system: @@ -31,7 +36,9 @@ pkgs = nixpkgs.legacyPackages.${system}; in { - packages = import ./pkgs { inherit pkgs; }; + packages = import ./pkgs { + inherit pkgs texlab-src; + }; devShells.default = import ./devshells { inherit pkgs system; diff --git a/pkgs/default.nix b/pkgs/default.nix index 3fef26e..5616cfb 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,7 @@ -{ pkgs }: +{ + pkgs, + texlab-src, +}: let self = { example-a = pkgs.callPackage ./example-a { }; @@ -9,6 +12,9 @@ let }; khal-export = pkgs.callPackage ./khal-export { }; org-zotero-export = pkgs.callPackage ./org-zotero-export { }; + texlab = pkgs.callPackage ./texlab { + inherit texlab-src; + }; }; in self // { default = self.example-a; } diff --git a/pkgs/texlab/default.nix b/pkgs/texlab/default.nix new file mode 100644 index 0000000..f8f8671 --- /dev/null +++ b/pkgs/texlab/default.nix @@ -0,0 +1,24 @@ +{ + lib, + rustPlatform, + pkg-config, + openssl, + texlab-src, +}: +rustPlatform.buildRustPackage { + pname = "texlab"; + version = "5.25.1-patched"; + src = texlab-src; + cargoLock.lockFile = "${texlab-src}/Cargo.lock"; + patches = [ ./patches/subfile-diagnostics.patch ]; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; + + meta = { + description = "Texlab with subfile diagnostic fix"; + mainProgram = "texlab"; + license = lib.licenses.mit; + platforms = lib.platforms.all; + }; +} diff --git a/pkgs/texlab/patches/subfile-diagnostics.patch b/pkgs/texlab/patches/subfile-diagnostics.patch new file mode 100644 index 0000000..3277f29 --- /dev/null +++ b/pkgs/texlab/patches/subfile-diagnostics.patch @@ -0,0 +1,36 @@ +diff --git a/crates/diagnostics/src/build_log.rs b/crates/diagnostics/src/build_log.rs +index 1234567..abcdefg 100644 +--- a/crates/diagnostics/src/build_log.rs ++++ b/crates/diagnostics/src/build_log.rs +@@ -14,8 +14,13 @@ pub fn update( + + let data = log_document.data.as_log()?; + +- let parents = deps::parents(workspace, log_document); +- let root_document = parents.iter().next()?; ++ // Try to find the compiled .tex file from the log file name first. ++ // This handles subfile compilation where the subfile is the actual root. ++ let root_document = find_compiled_document(workspace, log_document) ++ .or_else(|| { ++ // Fallback to original behavior: find parent via dependency graph ++ deps::parents(workspace, log_document).into_iter().next() ++ })?; + + let base_path = root_document + .path +@@ -57,3 +62,14 @@ fn find_range_of_hint(document: &Document, error: &BuildError) -> Option `/path/to/chapter.tex` ++fn find_compiled_document<'a>( ++ workspace: &'a Workspace, ++ log_document: &Document, ++) -> Option<&'a Document> { ++ let log_path = log_document.path.as_ref()?; ++ let tex_path = log_path.with_extension("tex"); ++ let tex_uri = Url::from_file_path(&tex_path).ok()?; ++ workspace.lookup(&tex_uri) ++}