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

doc-comment and EmmyLua on function defined as table value #942

Open
FelipeLema opened this issue Jan 2, 2025 · 0 comments
Open

doc-comment and EmmyLua on function defined as table value #942

FelipeLema opened this issue Jan 2, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@FelipeLema
Copy link

Stylua will format a documented function defined as a table value in a way that EmmyLua complains about @param doc-comment.

Before formatting ↓, ---@param n is correctly recognized by EmmyLua (through lua-language-server). doc-comment lines are indented the same above the function(…) line. No complains from EmmyLua

local t = {
	plus_one =
    ---@param n number
	---@return number
    function(n)
		return n + 1
	end,
}

After formatting ↓, ---@param n is moved to the key line, and it's mis-aligned with the rest of the doc-comment lines, in this case the @return one. EmmyLua complains Undefined param n on ---@param n number .

local t = {
	plus_one = 	---@param n number
	---@return number
function(n)
		return n + 1
	end,
}

Expected behavior: doc-comment alignment has higher priority, so all doc-comment lines are kept at same indentation. Don't mind if this results in function(…) line having a different indent

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants