Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support LuaCATS comment formatting #851

Open
UtkarshVerma opened this issue Jan 20, 2024 · 3 comments
Open

feat: Support LuaCATS comment formatting #851

UtkarshVerma opened this issue Jan 20, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@UtkarshVerma
Copy link

LuaCATS offers a way to specify the types through comments. Currently, stylua does not format it. For example, the code below:

---@param server string
---@param cond fun( root_dir, config): boolean
function M.disable(server, cond) end

should be formatted as:

---@param server string
---@param cond fun(root_dir, config): boolean
function M.disable(server, cond) end
@JohnnyMorganz
Copy link
Owner

It will be somewhat difficult to support this. We currently don't bother formatting comments at all, since comments could consist of anything.

We could support formatting specifically doc comments, however there is no "standardised" way of defining documentation comments in Lua (luadoc, emmylua, LuaCATs, moonwave, etc.), so it isn't clear which one, if any, we should support.

@lewis6991
Copy link

At the very minimum, we could enforce consistent whitespace in doc comments:

---text1
--- text2
--- @param a
---@return string

becomes:

--- text1
--- text2
--- @param a
--- @return string

Where the padding maybe configurable.

@seflue
Copy link

seflue commented Jun 1, 2024

Also line-breaks would be very nice to have. If I write some longer API documentation, it would be great, if stylua could at least wrap long lines to what was specified in column_width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants