Skip to content

feat(lua): install Lua meta types#617

Open
idursun wants to merge 3 commits intomainfrom
feat/lua-type-generation
Open

feat(lua): install Lua meta types#617
idursun wants to merge 3 commits intomainfrom
feat/lua-type-generation

Conversation

@idursun
Copy link
Copy Markdown
Owner

@idursun idursun commented Mar 26, 2026

This PR adds an experimental convenience feature for users who customise jjui with Lua scripts.

It introduces a new CLI command, jjui --install-lua-types, which installs a Lua type definition file into the user’s jjui config directory. That file is generated automatically from jjui’s intent metadata, so the exposed action and API surface stays in sync with the application rather than being maintained by hand.

The goal is to make Lua-based customisation easier in editors that support LuaLS by providing autocomplete and basic type information while writing config.lua and related scripts. This is intended as a lightweight quality-of-life improvement for people already using jjui’s Lua scripting support, rather than a new core workflow.

}

luaRCPath := filepath.Join(configDir, ".luarc.json")
created, err := ensureLuaRC(luaRCPath, dest)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i already made my own .luarc.json before, and running --install-lua-types gives below:

Image

resulting in ~/.config/jjui/.luarc.json exists but does not include ~/.config/jjui/types.lua

im thinking this is because of this line here. although i don't imagine most user probably don't have an existing one (and probably .luarc.json won't be updated often), for those who do like me, this skip on .luarc.json cuases workspace.library to not be updated

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought we shouldn't touch the file if the user has already put something in place as they are very like to be power users and know what they are doing.

b.WriteString("\n")

// Generate action classes for each owner
for _, owner := range allOwners {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allOwners comes from actionsByOwner, which only contains owners that have actions directly attached, and seems like this is causing jjui.status and jjui.revisions.quick_search to be left out ?

seeing this two fields being undefined in my editor with lua lsp

Image

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good catch! I'll have a look at this.

I had implemented this a couple of weeks ago and then did a refactor of the code generator then rebased this on top of the latest changes. I assumed all is good because there was no conflict but seems like some things might be out of sync now.


---Copy text to the system clipboard
---@param text string Text to copy
function copy_to_clipboard(text) end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this function returns something like bool, string

copyToClipboardFn := L.NewFunction(func(L *lua.LState) int {
text := L.CheckString(1)
if err := clipboard.WriteAll(text); err != nil {
L.Push(lua.LNil)
L.Push(lua.LString(err.Error()))
return 2
}
L.Push(lua.LBool(true))
L.Push(lua.LNil)
return 2
})

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll update this. Thanks!

@idursun idursun force-pushed the feat/lua-type-generation branch from 099cad6 to 336e1f5 Compare April 12, 2026 14:01
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

Successfully merging this pull request may close these issues.

2 participants