git: 9c7eb9528998 - main - editors/lapce: Integrate with tree-sitter-grammars

From: Nuno Teixeira <eduardo_at_FreeBSD.org>
Date: Thu, 11 Sep 2025 21:50:06 UTC
The branch main has been updated by eduardo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9c7eb95289985a7934e86299092bb9a938360e69

commit 9c7eb95289985a7934e86299092bb9a938360e69
Author:     Mikael Urankar <mikael@FreeBSD.org>
AuthorDate: 2025-09-11 21:29:56 +0000
Commit:     Nuno Teixeira <eduardo@FreeBSD.org>
CommitDate: 2025-09-11 21:33:38 +0000

    editors/lapce: Integrate with tree-sitter-grammars
    
    - Add RUN_DEPENDS on textproc/tree-sitter-grammars
    
    PR:             278837
---
 editors/lapce/Makefile                             |  5 ++++-
 .../lapce/files/patch-lapce-core_src_directory.rs  | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/editors/lapce/Makefile b/editors/lapce/Makefile
index 0b19128cec57..9e5aa15b4438 100644
--- a/editors/lapce/Makefile
+++ b/editors/lapce/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	lapce
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.4.5 # Cargo.lock patched: `make patch cargo-crates`
+PORTREVISION=	1
 CATEGORIES=	editors
 
 MAINTAINER=	eduardo@FreeBSD.org
@@ -15,7 +16,8 @@ NOT_FOR_ARCHS_REASON_i386=	doesn't build: [zstd-sys 2.0.1+zstd.1.5.2] AR_i686_un
 
 LIB_DEPENDS=	libssh2.so:security/libssh2 \
 		libgit2.so:devel/libgit2
-RUN_DEPENDS=	xdg-desktop-portal>0:deskutils/xdg-desktop-portal
+RUN_DEPENDS=	tree-sitter-grammars>0:textproc/tree-sitter-grammars \
+		xdg-desktop-portal>0:deskutils/xdg-desktop-portal
 
 USES=		cargo desktop-file-utils dos2unix gmake localbase:ldflags perl5 pkgconfig ssl xorg
 USE_GITHUB=	yes
@@ -44,5 +46,6 @@ post-install:
 post-patch:
 	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/cargo-crates/fontdb-0.16.2/src/lib.rs
 	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/cargo-crates/fontdb-0.23.0/src/lib.rs
+	@${REINPLACE_CMD} -e 's|%%DATADIR%%|${PREFIX}/share|g' ${WRKSRC}/lapce-core/src/directory.rs
 
 .include <bsd.port.mk>
diff --git a/editors/lapce/files/patch-lapce-core_src_directory.rs b/editors/lapce/files/patch-lapce-core_src_directory.rs
new file mode 100644
index 000000000000..b1ab0066a74c
--- /dev/null
+++ b/editors/lapce/files/patch-lapce-core_src_directory.rs
@@ -0,0 +1,22 @@
+--- lapce-core/src/directory.rs.orig	2025-08-30 05:01:02 UTC
++++ lapce-core/src/directory.rs
+@@ -176,17 +176,7 @@ impl Directory {
+     }
+ 
+     pub fn grammars_directory() -> Option<PathBuf> {
+-        if let Some(dir) = Self::data_local_directory() {
+-            let dir = dir.join("grammars");
+-            if !dir.exists() {
+-                if let Err(err) = std::fs::create_dir(&dir) {
+-                    tracing::error!("{:?}", err);
+-                }
+-            }
+-
+-            Some(dir)
+-        } else {
+-            None
+-        }
++         let mut dir = PathBuf::from(r"%%DATADIR%%/tree-sitter-grammars");
++         Some(dir)
+     }
+ }