Skip to content

Commit

Permalink
contrib/helix: new package (23.05)
Browse files Browse the repository at this point in the history
  • Loading branch information
wezm authored and q66 committed Aug 22, 2023
1 parent 8ad2530 commit eff8edf
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
18 changes: 18 additions & 0 deletions contrib/helix/patches/fix-d-grammar.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
commit 3a75cfb80e88b2d1a7be14effb97b00aeee4264e
Author: Wesley Moore <wes@wezm.net>
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 <assert.h>
#include <ctype.h>
19 changes: 19 additions & 0 deletions contrib/helix/patches/fix-rescript-grammar.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
commit d9fc339805666b25482823cfad46c3c62074a4ea
Author: Wesley Moore <wes@wezm.net>
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;
68 changes: 68 additions & 0 deletions contrib/helix/patches/fix-ub-in-diff-gutter.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
From 269f637847140ddb9537efde4968bd92c91c9e1e Mon Sep 17 00:00:00 2001
From: Pascal Kuthe <pascal.kuthe@semimod.de>
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<Rope>,
+ doc: Box<Rope>,
num_tokens_diff_base: u32,
interned: InternedInput<RopeSlice<'static>>,
}
@@ -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<Rope>) {
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 {
37 changes: 37 additions & 0 deletions contrib/helix/template.py
Original file line number Diff line number Diff line change
@@ -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 <wes@wezm.net>"
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")

0 comments on commit eff8edf

Please sign in to comment.