Skip to content

Lua indentation is broken #36

Closed

Description

@Umckgil

Lua Settings
"Lua": {
"tab_size": 3,
"formatter": "language_server",
"format_on_save": "off",
"language_servers": ["lua-language-server"],
},

Actual Behavior:

Image

Expected Behavior:

it should put 'else' and 'elseif' under 'if' in conditional statements. this is correct in vscode.

Hi please find below more gifs to demostrate the issue:

this one still is using tab_size 3

Image

these are when using tab_size 4

Image
Image

from vscode:
Image

@yeskunall

Zed Version and System Specs

Zed: v0.217.3+stable.105.80433cb239e868271457ac376673a5f75bc4adb1 (Zed)
OS: macOS 26.2
Memory: 18 GiB
Architecture: aarch64

Activity

  1. yeskunall commented on Jan 8, 2026

    @yeskunall
    Member

    @Umckgil acknowledging your message on Plain. Feel free to ping me here once you have the GIFs ready and I’ll be happy to take a look at this issue.

  2. Fringale commented on Feb 26, 2026

    @Fringale
    Contributor

    @Umckgil I don't know if you've resolved your issue, but if not: I see you have explicitly set the formatter as being the language server ("formatter": "language_server"), but have you also overridden the language server default formatting configuration (format.defaultConfig.indent_style / indent_size / tab_width / continuation_indent / etc.)?

    As I see in your gifs that it seems to autoformat with 4 spaces, which is LuaLS' (actually, EmmyLuaCodeStyle's) default formatting.

    For reference:

  3. Umckgil commented on Feb 26, 2026

    @Umckgil
    Author

    hi @Fringale, yes most of the issues resolve if 4 spaces is used, thats what I did as a workaround.

    however auto indentation in conditional statements is still distracting:
    Image

    I tried modifying defaultConfig values in .luarc.json, no luck. please note that this behavior wasn't always like this.

  4. Fringale commented on Feb 26, 2026

    @Fringale
    Contributor

    Ah understood, it seems there are two different things at play here:

    1. Regarding the wrong indent size when setting "tab_size": 3 and "formatter": "language_server", as per the 2nd gif in your initial post: try putting this in your .luarc.json (or settings file) so that it matches the 3-char space indent defined in Zed
    "format.enable": true,
    "format.defaultConfig": {
    	"indent_size": "3"
    }
    
    1. Regarding the initial wrong indent for else/elseif (indented) and for the first line after (not indented): that's weird indeed and I have the same issue, I would say this has to do with the extension tree-sitter queries managing indents.
  5. Umckgil commented on Feb 26, 2026

    @Umckgil
    Author

    thanks yeah that does solve the 3 sized indent issue.

    for the auto indentation issues, I tried to play around with indents.scm but couldnt improve.

  6. Fringale commented on Mar 1, 2026

    @Fringale
    Contributor

    I opened PR #42 to fix the elseif / else indentation issue.

  7. Umckgil commented on Mar 1, 2026

    @Umckgil
    Author

    thanks. tested it. seems resolve it at least for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions