From 8abfb3fbc60046ab98e8c164991d85d429eb39e4 Mon Sep 17 00:00:00 2001
From: Mario Rodas <marsam@users.noreply.github.com>
Date: Tue, 7 Jun 2022 04:20:00 +0000
Subject: [PATCH] ltex-ls: init at 15.2.0

---
 pkgs/tools/text/ltex-ls/default.nix | 34 +++++++++++++++++++++++++++++
 pkgs/top-level/all-packages.nix     |  2 ++
 2 files changed, 36 insertions(+)
 create mode 100644 pkgs/tools/text/ltex-ls/default.nix

diff --git a/pkgs/tools/text/ltex-ls/default.nix b/pkgs/tools/text/ltex-ls/default.nix
new file mode 100644
index 000000000000..c21ab2e038ab
--- /dev/null
+++ b/pkgs/tools/text/ltex-ls/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchurl, makeBinaryWrapper, jre_headless }:
+
+stdenv.mkDerivation rec {
+  pname = "ltex-ls";
+  version = "15.2.0";
+
+  src = fetchurl {
+    url = "https://github.com/valentjn/ltex-ls/releases/download/${version}/ltex-ls-${version}.tar.gz";
+    sha256 = "sha256-ygjCFjYaP9Lc5BLuOHe5+lyaKpfDhicR783skkBgo7I=";
+  };
+
+  nativeBuildInputs = [ makeBinaryWrapper ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -rfv bin/ lib/ $out
+    rm -fv $out/bin/*.bat
+    for file in $out/bin/{ltex-ls,ltex-cli}; do
+      wrapProgram $file --set JAVA_HOME "${jre_headless}"
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    homepage = "https://valentjn.github.io/ltex/";
+    description = "LSP language server for LanguageTool";
+    license = licenses.mpl20;
+    maintainers = [ maintainers.marsam ];
+    platforms = jre_headless.meta.platforms;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index a53c9dca0590..d4eeed1bca33 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -27893,6 +27893,8 @@ with pkgs;
 
   lsp-plugins = callPackage ../applications/audio/lsp-plugins { php = php74; };
 
+  ltex-ls = callPackage ../tools/text/ltex-ls { };
+
   luminanceHDR = libsForQt5.callPackage ../applications/graphics/luminance-hdr { };
 
   lxdvdrip = callPackage ../applications/video/lxdvdrip { };