Skip to content

Types(fix): Give each settings operation its own options class - #4

Merged
tony merged 1 commit into
masterfrom
operation-options
Sep 25, 2026
Merged

tony merged 1 commit into
masterfrom
operation-options

Conversation

@tony

@tony tony commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Every option, hook and environment call shared one options type, so LuaLS hover, signature help and the libtmux.org reference offered fields the runtime rejects with invalid_options. session:run_hook(name, { scope = "window" }) type-checked and failed at runtime.

Each operation now has its own class, matching settings.lua's prepare() and environment.lua's validation:

Operation Fields
get option/hook scope, inherit, index, process
list options/hooks scope, inherit, process
set option/hook scope, index, append, process
unset option/hook scope, index, process
run_hook process
get_environment scope, inherit, process
list_environment scope, inherit, include_hidden, process
set_environment scope, hidden, process
unset/remove_environment scope, process

Types only; runtime behaviour is unchanged.

Verification

$ mise exec -- python scripts/check.py mid
$ mise exec -- python scripts/check.py types

LuaLS 3.19.1 neither completes nor diagnoses fields inside a table passed to a fun-typed field, so no editor check can enforce these shapes; the classes were checked field by field against the runtime's allow-lists.

One `libtmux.SettingOptions` served every option and hook call, and one
`libtmux.EnvironmentOptions` every environment call, so the reference
and hover offered fields the runtime rejects: `run_hook` accepts only
`process`, yet `{ scope = "window" }` type-checked and then failed with
`invalid_options`. The classes now match `settings.lua`'s `prepare()` and
`environment.lua`'s option validation field for field.

- Settings: get (scope, inherit, index), list (scope, inherit), set
  (scope, index, append), unset (scope, index), run_hook (process only).
- Environment: get (inherit), list (inherit, include_hidden), set
  (hidden), unset and remove (scope and process only).

`libtmux.SettingOptions` and `libtmux.EnvironmentOptions` remain as the
shared bases.
@tony
tony merged commit 294ebba into master Sep 25, 2026
21 checks passed
tony added a commit to libtmux/docs that referenced this pull request Sep 25, 2026
why: libtmux-lua 294ebba gives each option, hook and environment call
its own options class (libtmux/libtmux-lua#4), and the adapter now reads
method signatures.

what:
- Regenerate the Lua model, sidebar, paths and mentions from 294ebba
- Move Lua's cross-reference floor to what the assembled tree resolves:
  signatures add links to every parameter and return type, and the eight
  fields that linked `Entity` plus a snapshot record now link one class
tony added a commit to libtmux/docs that referenced this pull request Sep 26, 2026
why: libtmux-lua 294ebba gives each option, hook and environment call
its own options class (libtmux/libtmux-lua#4), and the adapter now reads
method signatures.

what:
- Regenerate the Lua model, sidebar, paths and mentions from 294ebba
- Move Lua's cross-reference floor to what the assembled tree resolves:
  signatures add links to every parameter and return type, and the eight
  fields that linked `Entity` plus a snapshot record now link one class
tony added a commit to libtmux/docs that referenced this pull request Sep 26, 2026
why: libtmux-lua 294ebba gives each option, hook and environment call
its own options class (libtmux/libtmux-lua#4), and the adapter now reads
method signatures.

what:
- Regenerate the Lua model, sidebar, paths and mentions from 294ebba
- Move Lua's cross-reference floor to what the assembled tree resolves:
  signatures add links to every parameter and return type, and the eight
  fields that linked `Entity` plus a snapshot record now link one class
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.

1 participant