Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indentation limited to 2 spaces ? #46

Open
vincent-peugnet opened this issue Oct 20, 2024 · 2 comments
Open

indentation limited to 2 spaces ? #46

vincent-peugnet opened this issue Oct 20, 2024 · 2 comments

Comments

@vincent-peugnet
Copy link

Hi and thanks for this superb tool! I'm very excited of using it during HTML workshops for beginners!

I did some tests, but I couldn't figure out how to use another indentation strategy (like using tabs, or 4 spaces)

I was wondering if it was a limitation of the project, or if I'm just missed something 🥴.

I'm on VS code:

Version: 1.94.0
Commit: d78a74bcdfad14d5d3b1b782f87255d802b57511
Date: 2024-10-02T13:08:12.626Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Linux x64 5.15.0-122-generic

with

Name: SuperHTML
Id: LorisCro.super
Description: Language Server for HTML and SuperHTML Templates.
Version: 0.5.1
Publisher: Loris Cro
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=LorisCro.super
@tanj
Copy link

tanj commented Dec 8, 2024

I'm seeing the same thing in helix 24.7 with the language configured as:

[[language]]
name = "html"
scope = "source.html"
roots = []
file-types = ["html"]
language-servers = [ "superhtml-lsp" ]
indent = { tab-width = 4, unit = "    "}

@tanj
Copy link

tanj commented Dec 8, 2024

I went and read the code and yes, the two spaces is hard coded. I wrote my own patch to change it to four spaces which is what I normally use. This is really hacky and will break the tests.

If I knew a bit more about lsp servers I'd maybe attempt a PR to use a workspace config to allow this configuration.

diff --git a/src/html/Ast.zig b/src/html/Ast.zig
index a91b687..951c5ec 100644
--- a/src/html/Ast.zig
+++ b/src/html/Ast.zig
@@ -6,7 +6,6 @@ const Language = root.Language;
 const Span = root.Span;
 const Tokenizer = @import("Tokenizer.zig");

-const indent_string = "    ";
 const log = std.log.scoped(.@"html/ast");

 const TagNameMap = std.StaticStringMapWithEql(
@@ -563,7 +562,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
                         log.debug("adding a newline", .{});
                         try w.writeAll("\n");
                         for (0..indentation) |_| {
-                            try w.writeAll(indent_string);
+                            try w.writeAll("  ");
                         }
                     }
                 }
@@ -599,7 +598,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
                     if (open_was_vertical) {
                         try w.writeAll("\n");
                         for (0..indentation) |_| {
-                            try w.writeAll(indent_string);
+                            try w.writeAll("  ");
                         }
                     }
                 }
@@ -746,7 +745,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
                                 if (vertical) {
                                     try w.print("\n", .{});
                                     for (0..indentation + extra) |_| {
-                                        try w.print(indent_string, .{});
+                                        try w.print("  ", .{});
                                     }
                                 } else {
                                     try w.print(" ", .{});
@@ -772,7 +771,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
                     if (vertical) {
                         try w.print("\n", .{});
                         for (0..indentation + extra -| 1) |_| {
-                            try w.print(indent_string, .{});
+                            try w.print("  ", .{});
                         }
                     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants