feat: make indent size and tab width configurable and add indent guide mode

This commit is contained in:
CJ van den Berg 2024-10-10 23:14:55 +02:00
parent 55fb6d29a0
commit d2238bf847
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
15 changed files with 363 additions and 323 deletions

View file

@ -78,11 +78,11 @@ fn inspect_location(self: *Self, row: usize, col: usize) void {
fn get_buffer_text(self: *Self, buf: []u8, sel: Buffer.Selection) ?[]const u8 {
const root = self.editor.get_current_root() orelse return null;
return root.get_range(sel, buf, null, null, self.plane.metrics()) catch return null;
return root.get_range(sel, buf, null, null, self.plane.metrics(self.editor.tab_width)) catch return null;
}
fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32, _: usize, ast_node: *const syntax.Node) error{Stop}!void {
const sel = self.pos_cache.range_to_selection(range, self.editor.get_current_root() orelse return, self.plane) orelse return;
const sel = self.pos_cache.range_to_selection(range, self.editor.get_current_root() orelse return, self.editor.metrics) orelse return;
var update_match: enum { no, add, set } = .no;
var match = ed.Match.from_selection(sel);
@ -113,7 +113,7 @@ fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32,
const ast_parent = parent.asSExpressionString();
_ = self.plane.print("parent: {s}\n", .{ast_parent}) catch {};
syntax.Node.freeSExpressionString(ast_parent);
const sel_parent = self.pos_cache.range_to_selection(parent.getRange(), self.editor.get_current_root() orelse return, self.plane) orelse return;
const sel_parent = self.pos_cache.range_to_selection(parent.getRange(), self.editor.get_current_root() orelse return, self.editor.metrics) orelse return;
var match_parent = ed.Match.from_selection(sel_parent);
if (self.theme) |theme| match_parent.style = .{ .bg = theme.editor_gutter_added.fg };
switch (update_match) {