timakro / vim-yadi

Yet Another Detect Indent
MIT License
15 stars 3 forks source link

limit indent size to 8 #5

Open Konfekt opened 8 months ago

Konfekt commented 8 months ago

addresses https://github.com/timakro/vim-yadi/issues/4

timakro commented 8 months ago

I think the intent was to fall back to user preferences or file-type defaults in the case of a unrealistically large indentation?

For example, given a file like this

curl https://example.com/ -H "Content-Type: application/json" \
                          -H "Accept: application/json"

you wouldn't want to set shiftwidth and and softtabstop to 8, right?

You probably had something more like https://github.com/timakro/vim-yadi/commit/de2fd6cd28c0970ff54a9c8b40971e23d130c81f in mind.

Konfekt commented 8 months ago

Yes, such an example. User preferences are fine as well. I was not sure whether you preferred a max value instead. While at it, I noticed that some computation are only needed in special cases and moved them inside if clauses

timakro commented 8 months ago

I don't mean to make the maximum indentation value configurable, sorry for the confusion. I think 8 is good. I was trying to say that your PR would change shiftwidth and softtabstop given my example file while the intent as I understand it is to not change those settings in this scenario.

Konfekt commented 8 months ago

Yes, counting only up to 8 is a better solution, thank you. I adapted this PR accordingly, if there's still interest.

Edit: indent is computed relative to the last indent