Skip to main content
r/AstroNvim icon

r/AstroNvim

members
online

Lua source code formatting Lua source code formatting

Hi,

Status line shows lua_ls, stylua. You can change one line, and the whole file gets reformatted with alternate indentation. Later on, after another change it may or may not revert to the old indentation style.

My setup is the standard AstroNvim pack, never interfered with:

https://github.com/AstroNvim/astrocommunity/tree/main/lua/astrocommunity/pack/lua

Since this major trouble persists indefinitely, it could be my fault, somehow.


A streaming event for the eras is here. Stream The End of an Era, a six-episode behind-the-scenes docuseries chronicling the record-breaking tour and Taylor Swift | The Eras Tour | The Final Show, featuring THE TORTURED POETS DEPARTMENT for the first time.
Image A streaming event for the eras is here. Stream The End of an Era, a six-episode behind-the-scenes docuseries chronicling the record-breaking tour and Taylor Swift | The Eras Tour | The Final Show, featuring THE TORTURED POETS DEPARTMENT for the first time.



Triggering the current language formatter (astronvim) Triggering the current language formatter (astronvim)
Triggering the current language formatter (astronvim)

Astronvim (and neovim anyway) can "understand" a wide variety of text formats in their input and format it accordingly. Presumably, this is done using a formatter that changes depending (possibly) on the extension of the file being loaded.

How can i trigger this formatter mid writing some text?

Say for instance, I have a function application spread over 4 lines, I change the name of the function and now I have to edit the starting point of each line to align with the new position of the round brackets that denote the beginning of a function's arguments. I would like to hit a key combination and get the text re-aligned as per the obvious way for that point.

For individual languages (e.g. python), I can use the primitive way of passing the file through an external tool and get the reformatted text back. But, since neovim "understands" such a wide variety of formats, is it possible to trigger the reformatting of a given file in a buffer via a key combination?

I am using astronvim, if that makes any difference.

upvote comments