Darazaki / indent-o-matic

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

BUG: Wrong indent when using tabs #15

Closed captainko closed 2 years ago

captainko commented 2 years ago

image

As you can see in the picture above, when I insert a new line it only inserts 1 tab (not 2)

Darazaki commented 2 years ago

That's weird, could you tell me the output of :set expandtab? tabstop? softtabstop? shiftwidth? in the context in which this bug happens?

When does this bug happen? Is it limited to Lua files? Is it only after you type keywords like return or break?

Some IDEs like to assume that there should be one less tab after some of these keywords so it might be a Lua plugin doing that

Darazaki commented 2 years ago

Also sorry for the late answer but your issue didn't appear in my iOS Github app notifications for some reason :/

captainko commented 2 years ago

The output image

When does this bug happen? Is it limited to Lua files? Is it only after you type keywords like return or break?

It doesn't relate to those keywords, The bug doesn't appear when I switch back to vim-sleuth

Darazaki commented 2 years ago

That's even weirder because indent-o-matic does not override tabstop, softtabstop nor shiftwidth when it detect tabs (aka. when detected == 0) which seems to be your issue: https://github.com/Darazaki/indent-o-matic/blob/bf37c6e4ccd17197d32dee69cffab4f5bbe4cbf2/lua/indent-o-matic.lua#L156-L163

I'm guessing vim-sleuth override these which is fixing your issue even if it's hack-ish

Does this still happen when both indent-o-matic and vim-sleuth are disabled? Do you have anything in your config which sets softtabstop and shiftwidth independently from tabstop?

captainko commented 2 years ago

I think you are right, I can remove softtabstop and shiftwidth settings, but I need to keep the tabstop at 4 instead of 8; One more issue after a remove those 2 options: image now it adds 4 tabs

captainko commented 2 years ago

Oh I think this issue doesn't relate to indent-o-matic, must be something wrong with the latest tree-sitter-lua. Thank you for helping me.

Darazaki commented 2 years ago

You're welcome! :)

If you still have trouble with that, you can always attempt to ask for help at r/neovim (although I've seen a lot of questions being downvoted, most of them end up being answered)

I'm sorry that I can't help much since I'm still a bit noob-ish with Neovim but feel free to comment anything here if there's anything I can help with :)

I'll close this issue as "invalid" for now since it's not really an indent-o-matic bug