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

Incorrect Lua type of the modules field of tabufline/statusline config table #287

Closed
fishBone000 opened this issue May 26, 2024 · 10 comments

Comments

@fishBone000
Copy link

fishBone000 commented May 26, 2024

---@field modules? table<string, fun(): string>

is inconsistent with
for _, v in ipairs(order) do
local module = modules[v]
module = type(module) == "string" and module or module()
table.insert(result, module)
end
return table.concat(result)
end

@siduck
Copy link
Member

siduck commented May 26, 2024

whats incorrect here? 🤔

@fishBone000
Copy link
Author

fishBone000 commented May 27, 2024

Eh, like, the module can be a string:

	statusline = {
		modules = {
			cursor = "%#St_pos_sep#" .. "" .. "%#St_pos_icon# %#St_pos_text# %l,%v %p %% "
		}
	}

but ---@field modules? table<string, fun(): string> says it must be a func that returns a string

@siduck
Copy link
Member

siduck commented May 27, 2024

ohh, idk about lua types, @lucario387 and @KorigamiK and @mgastonportillo have contributed to it 😃

@lucario387
Copy link
Collaborator

well, before it was only allowed to be a func :)

Things changed, but the types were not updated

@mgastonportillo
Copy link
Contributor

mgastonportillo commented May 27, 2024

I can push an update if that's fine. I noticed the script got updated as well.

Edit: wait, what's wrong with the type definition? It says modules can be either strings or functions that return a string, and that's correct

Edit2: found the issue

@mgastonportillo
Copy link
Contributor

@lucario387 can you confirm if the script could have added types from some user's chadrc? I updated it as a chore before sending the PR and I see some types removed, but they seem to be external, like NeogitDiffDeleteHighlight

@KorigamiK
Copy link
Contributor

@lucario387 can you confirm if the script could have added types from some user's chadrc? I updated it as a chore before sending the PR and I see some types removed, but they seem to be external, like NeogitDiffDeleteHighlight

Yeah these might be plugin highlights that get loaded after. It's probably best to not maintain them as a chore every time.

@mgastonportillo
Copy link
Contributor

I'll look at it today and see where the tables merge. Maybe I can update the script first. I just need a confirmation to see if this behaviour is intended.

@fishBone000
Copy link
Author

By the way, I found this is incorrect too:

---@field separator_style? '"default"'|'"round"'|'"block"'|'"arrow"'

Since it can be table too:
local separators = (type(sep_style) == "table" and sep_style) or default_sep_icons[sep_style]

So perhaps there's some more lines to be changed in
https://github.com/NvChad/ui/blob/0c283b6aed4eed585a497c9031b18b5009bfe4dd/nvchad_types/chadrc.lua

@siduck
Copy link
Member

siduck commented Jul 9, 2024

image

the error's fixed in recent commits i believe

@siduck siduck closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants