Closed jandamm closed 2 years ago
I think those are some very good changes! I can see it being very useful for copy-n-pasting some code into a new file
The once per buffer way seems better imo, but shouldn't it be made local to a buffer to avoid it being executed on another buffer by mistake?:
au BufNew * au BufWritePost <buffer=abuf> ++once lua IndentOMatic()
At least that's how I understood those commands as a beginner, feel free to correct me if I'm wrong!
That is completely true. Missed the buffer local autocmd.
What do you think of a :IndentOMatic
command?
I don't see it as a necessity rn, I personally use :lua IndentOMatic()
for testing everything
But maybe people would prefer if I provided :IndentOMatic
for maybe their config? Would it be better to have this command too?
The idea is that when the indent is incorrectly detected you can fix the first line and run a command. You can obviously run a lua function instead but command completion is faster.
I see, I'll add it then. Thanks a lot!
The detection works quite well for existing files but doesn't work for newly created files.
One way to tackle this would be to use
BufWritePost
:What do you think of those changes?