Merge branch 'master' into vim_bindings_013

This commit is contained in:
Luís Tavares 2025-02-12 21:09:56 +00:00 committed by GitHub
commit 4e4034d0f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 37 additions and 22 deletions

View file

@ -293,6 +293,7 @@ pub fn build_exe(
.imports = &.{ .imports = &.{
.{ .name = "cbor", .module = cbor_mod }, .{ .name = "cbor", .module = cbor_mod },
.{ .name = "thespian", .module = thespian_mod }, .{ .name = "thespian", .module = thespian_mod },
.{ .name = "CaseData", .module = zg_dep.module("CaseData") },
}, },
}); });
@ -476,7 +477,6 @@ pub fn build_exe(
.{ .name = "color", .module = color_mod }, .{ .name = "color", .module = color_mod },
.{ .name = "diff", .module = diff_mod }, .{ .name = "diff", .module = diff_mod },
.{ .name = "help.md", .module = help_mod }, .{ .name = "help.md", .module = help_mod },
.{ .name = "CaseData", .module = zg_dep.module("CaseData") },
.{ .name = "fuzzig", .module = fuzzig_dep.module("fuzzig") }, .{ .name = "fuzzig", .module = fuzzig_dep.module("fuzzig") },
.{ .name = "zeit", .module = zeit_mod }, .{ .name = "zeit", .module = zeit_mod },
}, },
@ -502,6 +502,7 @@ pub fn build_exe(
exe.root_module.addImport("flags", flags_dep.module("flags")); exe.root_module.addImport("flags", flags_dep.module("flags"));
exe.root_module.addImport("cbor", cbor_mod); exe.root_module.addImport("cbor", cbor_mod);
exe.root_module.addImport("config", config_mod); exe.root_module.addImport("config", config_mod);
exe.root_module.addImport("Buffer", Buffer_mod);
exe.root_module.addImport("tui", tui_mod); exe.root_module.addImport("tui", tui_mod);
exe.root_module.addImport("thespian", thespian_mod); exe.root_module.addImport("thespian", thespian_mod);
exe.root_module.addImport("log", log_mod); exe.root_module.addImport("log", log_mod);
@ -543,6 +544,7 @@ pub fn build_exe(
check_exe.root_module.addImport("flags", flags_dep.module("flags")); check_exe.root_module.addImport("flags", flags_dep.module("flags"));
check_exe.root_module.addImport("cbor", cbor_mod); check_exe.root_module.addImport("cbor", cbor_mod);
check_exe.root_module.addImport("config", config_mod); check_exe.root_module.addImport("config", config_mod);
check_exe.root_module.addImport("Buffer", Buffer_mod);
check_exe.root_module.addImport("tui", tui_mod); check_exe.root_module.addImport("tui", tui_mod);
check_exe.root_module.addImport("thespian", thespian_mod); check_exe.root_module.addImport("thespian", thespian_mod);
check_exe.root_module.addImport("log", log_mod); check_exe.root_module.addImport("log", log_mod);
@ -550,6 +552,7 @@ pub fn build_exe(
check_exe.root_module.addImport("renderer", renderer_mod); check_exe.root_module.addImport("renderer", renderer_mod);
check_exe.root_module.addImport("input", input_mod); check_exe.root_module.addImport("input", input_mod);
check_exe.root_module.addImport("syntax", syntax_mod); check_exe.root_module.addImport("syntax", syntax_mod);
check_exe.root_module.addImport("color", color_mod);
check_exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file })); check_exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file }));
check_step.dependOn(&check_exe.step); check_step.dependOn(&check_exe.step);

View file

@ -18,8 +18,8 @@
.hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362", .hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362",
}, },
.thespian = .{ .thespian = .{
.url = "https://github.com/neurocyte/thespian/archive/db3ad5f45e707a04eaa51aa657995abe43ce967a.tar.gz", .url = "https://github.com/neurocyte/thespian/archive/9ca04ddfc715e0f7d29d3f6b39269ad9bf174230.tar.gz",
.hash = "1220bbfd147f41fa49d2e5406096f3529c62e9335f4d2a89ae381e679a76ce398f1f", .hash = "1220b05b5949454bf155a802d5034c060431b8bf59f9d4d2d5241397e9fd201d78d9",
}, },
.themes = .{ .themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz", .url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz",

View file

@ -59,3 +59,13 @@ pub fn utf8_sanitize(allocator: std.mem.Allocator, input: []const u8) error{
for (input) |byte| try writer.writeAll(try raw_byte_to_utf8(byte, &buf)); for (input) |byte| try writer.writeAll(try raw_byte_to_utf8(byte, &buf));
return output.toOwnedSlice(allocator); return output.toOwnedSlice(allocator);
} }
pub const CaseData = @import("CaseData");
var case_data: ?CaseData = null;
var case_data_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
pub fn get_case_data() *CaseData {
if (case_data) |*cd| return cd;
case_data = CaseData.init(case_data_arena.allocator()) catch @panic("CaseData.init");
return &case_data.?;
}

View file

@ -170,8 +170,8 @@
"line_numbers": "absolute", "line_numbers": "absolute",
"cursor": "beam", "cursor": "beam",
"press": [ "press": [
["jk", "enter_mode", "normal"],
["<Esc>", ["move_left_vim"], ["enter_mode", "normal"]], ["<Esc>", "enter_mode", "normal"],
["<Del>", "delete_forward"], ["<Del>", "delete_forward"],
["<BS>", "delete_backward"], ["<BS>", "delete_backward"],
["<CR>", "smart_insert_line"], ["<CR>", "smart_insert_line"],

View file

@ -41,6 +41,8 @@ pub fn main() anyerror!void {
} }
const a = std.heap.c_allocator; const a = std.heap.c_allocator;
const case_data = @import("Buffer").unicode.get_case_data();
_ = case_data; // no need to free case_data as it is globally static
const Flags = struct { const Flags = struct {
pub const description = pub const description =

View file

@ -86,7 +86,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_
self.vx.deinit(self.allocator, self.tty.anyWriter()); self.vx.deinit(self.allocator, self.tty.anyWriter());
self.tty.deinit(); self.tty.deinit();
} }
return std.builtin.default_panic(msg, error_return_trace, ret_addr); return std.builtin.default_panic(msg, error_return_trace, ret_addr orelse @returnAddress());
} }
pub fn run(self: *Self) !void { pub fn run(self: *Self) !void {

View file

@ -19,6 +19,7 @@ pub fn build(b: *std.Build) void {
.{ .name = "treez", .module = tree_sitter_dep.module("treez") }, .{ .name = "treez", .module = tree_sitter_dep.module("treez") },
ts_queryfile(b, tree_sitter_dep, "queries/cmake/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "queries/cmake/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-agda/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-agda/queries/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-bash/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-bash/queries/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-c-sharp/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-c-sharp/queries/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-c/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-c/queries/highlights.scm"),
@ -80,6 +81,7 @@ pub fn build(b: *std.Build) void {
ts_queryfile(b, tree_sitter_dep, "nvim-treesitter/queries/verilog/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "nvim-treesitter/queries/verilog/highlights.scm"),
ts_queryfile(b, tree_sitter_dep, "queries/cmake/injections.scm"), ts_queryfile(b, tree_sitter_dep, "queries/cmake/injections.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/injections.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-cpp/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-cpp/queries/injections.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-elixir/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-elixir/queries/injections.scm"),
ts_queryfile(b, tree_sitter_dep, "tree-sitter-gitcommit/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-gitcommit/queries/injections.scm"),

View file

@ -4,8 +4,8 @@
.dependencies = .{ .dependencies = .{
.@"tree-sitter" = .{ .@"tree-sitter" = .{
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-69775ce3ba8a5e331bba9feb760d1ba31394eea7/source.tar.gz", .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz",
.hash = "1220f9702ca6257f5464b31e576b1e92b0f441bf0e61733c4a2fbf95b7c0c55a3e22", .hash = "1220e9fba96c468283129e977767472dee00b16f356e5912431cec8f1a009b6691a2",
}, },
}, },
.paths = .{ .paths = .{

View file

@ -4,6 +4,14 @@ pub const agda = .{
.comment = "--", .comment = "--",
}; };
pub const astro = .{
.description = "Astro",
.icon = "",
.extensions = .{"astro"},
.comment = "//",
.language_server = .{ "astro-ls", "--stdio" },
};
pub const bash = .{ pub const bash = .{
.description = "Bash", .description = "Bash",
.color = 0x3e474a, .color = 0x3e474a,

View file

@ -9,7 +9,6 @@ const tracy = @import("tracy");
const text_manip = @import("text_manip"); const text_manip = @import("text_manip");
const syntax = @import("syntax"); const syntax = @import("syntax");
const project_manager = @import("project_manager"); const project_manager = @import("project_manager");
const CaseData = @import("CaseData");
const root_mod = @import("root"); const root_mod = @import("root");
const Plane = @import("renderer").Plane; const Plane = @import("renderer").Plane;
@ -350,8 +349,6 @@ pub const Editor = struct {
} = null, } = null,
} = null, } = null,
case_data: ?CaseData = null,
const WhitespaceMode = enum { indent, leading, eol, tabs, visible, full, none }; const WhitespaceMode = enum { indent, leading, eol, tabs, visible, full, none };
const StyleCache = std.AutoHashMap(u32, ?Widget.Theme.Token); const StyleCache = std.AutoHashMap(u32, ?Widget.Theme.Token);
@ -468,7 +465,6 @@ pub const Editor = struct {
self.handlers.deinit(); self.handlers.deinit();
self.logger.deinit(); self.logger.deinit();
if (self.buffer) |p| self.buffer_manager.retire(p, meta.items); if (self.buffer) |p| self.buffer_manager.retire(p, meta.items);
if (self.case_data) |cd| cd.deinit();
} }
fn from_whitespace_mode(whitespace_mode: []const u8) WhitespaceMode { fn from_whitespace_mode(whitespace_mode: []const u8) WhitespaceMode {
@ -492,12 +488,6 @@ pub const Editor = struct {
Widget.need_render(); Widget.need_render();
} }
fn get_case_data(self: *Self) *CaseData {
if (self.case_data) |*cd| return cd;
self.case_data = CaseData.init(self.allocator) catch @panic("CaseData.init");
return &self.case_data.?;
}
fn buf_for_update(self: *Self) !*const Buffer { fn buf_for_update(self: *Self) !*const Buffer {
if (!self.pause_undo) { if (!self.pause_undo) {
self.cursels_saved.clearAndFree(); self.cursels_saved.clearAndFree();
@ -5063,7 +5053,7 @@ pub const Editor = struct {
var sfa = std.heap.stackFallback(4096, self.allocator); var sfa = std.heap.stackFallback(4096, self.allocator);
const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop; const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop;
defer allocator.free(cut_text); defer allocator.free(cut_text);
const ucased = self.get_case_data().toUpperStr(allocator, cut_text) catch return error.Stop; const ucased = Buffer.unicode.get_case_data().toUpperStr(allocator, cut_text) catch return error.Stop;
defer allocator.free(ucased); defer allocator.free(ucased);
root = try self.delete_selection(root, cursel, allocator); root = try self.delete_selection(root, cursel, allocator);
root = self.insert(root, cursel, ucased, allocator) catch return error.Stop; root = self.insert(root, cursel, ucased, allocator) catch return error.Stop;
@ -5091,7 +5081,7 @@ pub const Editor = struct {
var sfa = std.heap.stackFallback(4096, self.allocator); var sfa = std.heap.stackFallback(4096, self.allocator);
const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop; const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop;
defer allocator.free(cut_text); defer allocator.free(cut_text);
const ucased = self.get_case_data().toLowerStr(allocator, cut_text) catch return error.Stop; const ucased = Buffer.unicode.get_case_data().toLowerStr(allocator, cut_text) catch return error.Stop;
defer allocator.free(ucased); defer allocator.free(ucased);
root = try self.delete_selection(root, cursel, allocator); root = try self.delete_selection(root, cursel, allocator);
root = self.insert(root, cursel, ucased, allocator) catch return error.Stop; root = self.insert(root, cursel, ucased, allocator) catch return error.Stop;
@ -5122,9 +5112,9 @@ pub const Editor = struct {
self_: *Self, self_: *Self,
result: *std.ArrayList(u8), result: *std.ArrayList(u8),
const Error = @typeInfo(@typeInfo(@TypeOf(CaseData.toUpperStr)).Fn.return_type.?).ErrorUnion.error_set; const Error = @typeInfo(@typeInfo(@TypeOf(Buffer.unicode.CaseData.toUpperStr)).Fn.return_type.?).ErrorUnion.error_set;
pub fn write(writer: *@This(), bytes: []const u8) Error!void { pub fn write(writer: *@This(), bytes: []const u8) Error!void {
const cd = writer.self_.get_case_data(); const cd = Buffer.unicode.get_case_data();
const flipped = if (cd.isLowerStr(bytes)) const flipped = if (cd.isLowerStr(bytes))
try cd.toUpperStr(writer.self_.allocator, bytes) try cd.toUpperStr(writer.self_.allocator, bytes)
else else