Darazaki / indent-o-matic

Dumb automatic fast indentation detection for Neovim written in Lua
MIT License
176 stars 13 forks source link

Breaks on indentation with odd number of spaces #5

Closed heygarrett closed 2 years ago

heygarrett commented 2 years ago

https://github.com/Darazaki/indent-o-matic/blob/ee5283eedc75c32a7ad312b7ab54feee23582790/lua/indent-o-matic.lua#L88-L93

I work with Markdown files that use 3-space indentation. 🙈 Would it be feasible to check for either a range (eg, 2–8 spaces) or just more than two spaces rather than checking specifically for 2, 4 or 8 spaces?

Darazaki commented 2 years ago

Hi, sorry for the late answer. Sadly I can't really do that since allowing weird indentations could increase the number of cases where something that isn't an indentation gets treated as one:

// Align arguments (6 spaces here)
int f(int x,
      int y);

int main(void) {
  // Actual indentation (2 spaces)
}

However, I could try to add user defined space configuration! Maybe:

require('indent-o-matic').setup {
    -- ...
    standard_widths = { 2, 3, 4, 8 }
}

Would that solve your issue?

Darazaki commented 2 years ago

Hi again @heygarrett! I've added the feature I've talked about since it seemed to be pretty close to what you wanted

If for some reason it doesn't work for you please let me know why and I'll reopen the issue to try and fix it

Have a nice day! :)

heygarrett commented 2 years ago

Sorry for my delayed response! Thanks for looking into this. I'll give it a try!