From 5a5cafded6aa6a42c4baacaa2aa65c20a38d6fae Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Sat, 5 Aug 2023 17:42:06 +1000 Subject: [PATCH] contrib/helix: new package (23.05) --- contrib/helix/patches/fix-d-grammar.patch | 18 +++++ .../helix/patches/fix-rescript-grammar.patch | 19 ++++++ .../helix/patches/fix-ub-in-diff-gutter.patch | 68 +++++++++++++++++++ contrib/helix/template.py | 37 ++++++++++ 4 files changed, 142 insertions(+) create mode 100644 contrib/helix/patches/fix-d-grammar.patch create mode 100644 contrib/helix/patches/fix-rescript-grammar.patch create mode 100644 contrib/helix/patches/fix-ub-in-diff-gutter.patch create mode 100644 contrib/helix/template.py diff --git a/contrib/helix/patches/fix-d-grammar.patch b/contrib/helix/patches/fix-d-grammar.patch new file mode 100644 index 0000000000..c54b568318 --- /dev/null +++ b/contrib/helix/patches/fix-d-grammar.patch @@ -0,0 +1,18 @@ +commit 3a75cfb80e88b2d1a7be14effb97b00aeee4264e +Author: Wesley Moore +Date: Wed Aug 2 21:55:37 2023 +1000 + + Fix build with -std=c11 + +diff --git a/runtime/grammars/sources/d/src/scanner.c b/runtime/grammars/sources/d/src/scanner.c +index 6753ba0..d5dc16d 100644 +--- a/runtime/grammars/sources/d/src/scanner.c ++++ b/runtime/grammars/sources/d/src/scanner.c +@@ -7,6 +7,7 @@ + * (See accompanying file LICENSE.txt or https://opensource.org/licenses/MIT) + * SPDX-License-Identifier: MIT + */ ++#define _XOPEN_SOURCE + #include "tree_sitter/parser.h" + #include + #include diff --git a/contrib/helix/patches/fix-rescript-grammar.patch b/contrib/helix/patches/fix-rescript-grammar.patch new file mode 100644 index 0000000000..39b5cdbaeb --- /dev/null +++ b/contrib/helix/patches/fix-rescript-grammar.patch @@ -0,0 +1,19 @@ +commit d9fc339805666b25482823cfad46c3c62074a4ea +Author: Wesley Moore +Date: Wed Aug 2 21:28:08 2023 +1000 + + Fix error when building with Clang + +diff --git a/runtime/grammars/sources/rescript/src/scanner.c b/runtime/grammars/sources/rescript/src/scanner.c +index 9bf9fa4..113ca35 100644 +--- a/runtime/grammars/sources/rescript/src/scanner.c ++++ b/runtime/grammars/sources/rescript/src/scanner.c +@@ -131,7 +131,7 @@ bool tree_sitter_rescript_external_scanner_scan( + const bool* valid_symbols + ) { + ScannerState* state = (ScannerState*)payload; +- const in_string = state->in_quotes || state->in_backticks; ++ const bool in_string = state->in_quotes || state->in_backticks; + + if (valid_symbols[TEMPLATE_CHARS]) { + lexer->result_symbol = TEMPLATE_CHARS; diff --git a/contrib/helix/patches/fix-ub-in-diff-gutter.patch b/contrib/helix/patches/fix-ub-in-diff-gutter.patch new file mode 100644 index 0000000000..e0c88ac10e --- /dev/null +++ b/contrib/helix/patches/fix-ub-in-diff-gutter.patch @@ -0,0 +1,68 @@ +From 269f637847140ddb9537efde4968bd92c91c9e1e Mon Sep 17 00:00:00 2001 +From: Pascal Kuthe +Date: Sun, 4 Jun 2023 16:59:01 +0200 +Subject: [PATCH] fix UB in diff gutter + +--- + helix-vcs/src/diff/line_cache.rs | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/helix-vcs/src/diff/line_cache.rs b/helix-vcs/src/diff/line_cache.rs +index 8e48250f157e..460a2065e8ed 100644 +--- a/helix-vcs/src/diff/line_cache.rs ++++ b/helix-vcs/src/diff/line_cache.rs +@@ -20,8 +20,8 @@ use super::{MAX_DIFF_BYTES, MAX_DIFF_LINES}; + /// A cache that stores the `lines` of a rope as a vector. + /// It allows safely reusing the allocation of the vec when updating the rope + pub(crate) struct InternedRopeLines { +- diff_base: Rope, +- doc: Rope, ++ diff_base: Box, ++ doc: Box, + num_tokens_diff_base: u32, + interned: InternedInput>, + } +@@ -34,8 +34,8 @@ impl InternedRopeLines { + after: Vec::with_capacity(doc.len_lines()), + interner: Interner::new(diff_base.len_lines() + doc.len_lines()), + }, +- diff_base, +- doc, ++ diff_base: Box::new(diff_base), ++ doc: Box::new(doc), + // will be populated by update_diff_base_impl + num_tokens_diff_base: 0, + }; +@@ -44,19 +44,19 @@ impl InternedRopeLines { + } + + pub fn doc(&self) -> Rope { +- self.doc.clone() ++ Rope::clone(&*self.doc) + } + + pub fn diff_base(&self) -> Rope { +- self.diff_base.clone() ++ Rope::clone(&*self.diff_base) + } + + /// Updates the `diff_base` and optionally the document if `doc` is not None + pub fn update_diff_base(&mut self, diff_base: Rope, doc: Option) { + self.interned.clear(); +- self.diff_base = diff_base; ++ self.diff_base = Box::new(diff_base); + if let Some(doc) = doc { +- self.doc = doc ++ self.doc = Box::new(doc) + } + if !self.is_too_large() { + self.update_diff_base_impl(); +@@ -74,7 +74,7 @@ impl InternedRopeLines { + .interner + .erase_tokens_after(self.num_tokens_diff_base.into()); + +- self.doc = doc; ++ self.doc = Box::new(doc); + if self.is_too_large() { + self.interned.after.clear(); + } else { diff --git a/contrib/helix/template.py b/contrib/helix/template.py new file mode 100644 index 0000000000..fde2711a20 --- /dev/null +++ b/contrib/helix/template.py @@ -0,0 +1,37 @@ +pkgname = "helix" +pkgver = "23.05" +pkgrel = 0 +build_style = "cargo" +hostmakedepends = ["cargo", "git"] +makedepends = ["rust"] +pkgdesc = "Fast modal terminal-based text editor" +maintainer = "Wesley Moore " +license = "MPL-2.0" +url = "https://github.com/helix-editor/helix" +source = f"{url}/releases/download/{pkgver}/helix-{pkgver}-source.tar.xz" +sha256 = "c1ca69facde99d708175c686ce5bf3585e119e372c83e1c3dc1d562c7a8e3d87" + + +def do_install(self): + self.cargo.install(wrksrc="helix-term") + runtime_dir = "usr/libexec/helix/runtime" + self.install_dir(runtime_dir) + self.mv(self.destdir / "usr/bin/hx", self.destdir / "usr/libexec/helix") + self.install_link("/usr/libexec/helix/hx", "usr/bin/hx") + + self.install_files("runtime/queries", runtime_dir) + self.install_files("runtime/themes", runtime_dir) + self.install_file("runtime/tutor", runtime_dir) + self.install_file( + "runtime/grammars/*.so", + f"{runtime_dir}/grammars", + mode=0o755, + glob=True, + ) + + self.install_completion("contrib/completion/hx.bash", "bash", "hx") + self.install_completion("contrib/completion/hx.fish", "fish", "hx") + self.install_completion("contrib/completion/hx.zsh", "zsh", "hx") + + self.install_file(f"contrib/{pkgname}.png", "usr/share/pixmaps") + self.install_file("contrib/Helix.desktop", "usr/share/applications")