|
| 1 | +---@meta |
| 2 | +---@diagnostic disable:unused-local |
| 3 | + |
| 4 | +---@class Chord.KeyEntry |
| 5 | +---@field key string WezTerm key name. |
| 6 | +---@field mods? string WezTerm modifier string, such as `CTRL|SHIFT`. |
| 7 | +---@field action any WezTerm action assigned to the key. |
| 8 | +---@field desc? string Optional command-palette or hint-bar description. |
| 9 | + |
| 10 | +---@class Chord.VimMapping |
| 11 | +---@field [1]? string Vim-style left-hand side, such as `<C-Space>`. |
| 12 | +---@field [2]? any WezTerm action. |
| 13 | +---@field [3]? string Optional description. |
| 14 | +---@field lhs? string Vim-style left-hand side. |
| 15 | +---@field rhs? any WezTerm action. |
| 16 | +---@field action? any WezTerm action. |
| 17 | +---@field desc? string Optional description. |
| 18 | + |
| 19 | +---@class Chord.OverrideSpec |
| 20 | +---@field enabled? boolean Disable a mapping group when set to `false`. |
| 21 | +---@field disable? (string|Chord.KeyEntry|Chord.VimMapping)[] Mappings to remove. |
| 22 | +---@field override? table<string, any> Mappings to replace by Vim-style lhs. |
| 23 | +---@field add? Chord.VimMapping[] Mappings to append. |
| 24 | + |
| 25 | +---@class Chord.Overrides |
| 26 | +---@field enabled? { keys?: boolean, key_tables?: boolean } |
| 27 | +---@field keys? Chord.OverrideSpec |
| 28 | +---@field key_tables? table<string, Chord.OverrideSpec> |
| 29 | + |
| 30 | +---@class Chord.KeyMeta |
| 31 | +---@field i string Short icon or label for the key table. |
| 32 | +---@field txt string Display text for the key table. |
| 33 | +---@field bg string Background color for the key table. |
| 34 | +---@field pad? integer Optional display padding. |
| 35 | +---@field name? string Runtime key-table name. |
| 36 | + |
| 37 | +---@class Chord.KeyTableDef |
| 38 | +---@field meta Chord.KeyMeta Key-table metadata used by hints and mode displays. |
| 39 | +---@field keys Chord.VimMapping[] Key definitions in Vim-style notation. |
| 40 | + |
| 41 | +---@alias Chord.KeyTableDefFn fun(theme: table): Chord.KeyTableDef |
| 42 | + |
| 43 | +---@class Chord.HintsConfig |
| 44 | +---@field separator string Separator between hint entries. |
| 45 | +---@field page_cache_prefix string Prefix for per-pane hint page cache keys. |
| 46 | + |
| 47 | +---@class Chord.CommandConfig |
| 48 | +---@field key string Key binding that opens the command picker. |
| 49 | +---@field desc string Description for the injected command picker binding. |
| 50 | +---@field title string InputSelector title. |
| 51 | +---@field fuzzy boolean Whether InputSelector fuzzy matching is enabled. |
| 52 | +---@field description string InputSelector description. |
| 53 | +---@field fuzzy_description string InputSelector fuzzy description. |
| 54 | +---@field alphabet? string InputSelector shortcut alphabet. |
| 55 | +---@field include_registered boolean Include commands registered through `chord.command.register`. |
| 56 | +---@field include_keys boolean Include top-level `config.keys` entries. |
| 57 | +---@field include_key_tables boolean Include `config.key_tables` entries. |
| 58 | +---@field include_defaults boolean Include `wezterm.gui.default_keys()` entries. |
| 59 | +---@field include_undocumented boolean Include entries without `desc` or `label`. |
| 60 | +---@field dedupe boolean Dedupe entries by binding identity. |
| 61 | + |
| 62 | +---@class Chord.LogConfig |
| 63 | +---@field enabled boolean |
| 64 | +---@field threshold string|integer |
| 65 | + |
| 66 | +---@class Chord.Config |
| 67 | +---@field aliases table<string, string> Vim-style key aliases mapped to WezTerm key names. |
| 68 | +---@field modifiers table<string, string> Vim-style modifier aliases mapped to WezTerm modifiers. |
| 69 | +---@field leader string Leader token used in Vim-style key notation. |
| 70 | +---@field hints Chord.HintsConfig |
| 71 | +---@field command Chord.CommandConfig |
| 72 | +---@field log Chord.LogConfig |
| 73 | + |
| 74 | +---@alias Chord.CommandSource "registered"|"keys"|"key_table"|"default" |
| 75 | + |
| 76 | +---@class Chord.Command |
| 77 | +---@field id string Stable command identifier. |
| 78 | +---@field label string User-facing command label. |
| 79 | +---@field action any WezTerm action executed when the command is selected. |
| 80 | +---@field lhs? string Vim-style key label, when the command is key-backed. |
| 81 | +---@field source Chord.CommandSource Source collection where the command came from. |
| 82 | +---@field table_name? string Key table name for `key_table` commands. |
| 83 | +---@field binding_id? string Normalized binding identity used for deduplication. |
| 84 | + |
| 85 | +---@class Chord.CommandSpec |
| 86 | +---@field [1]? string Vim-style left-hand side. |
| 87 | +---@field [2]? any WezTerm action. |
| 88 | +---@field [3]? string Optional command label. |
| 89 | +---@field id? string Stable command identifier. |
| 90 | +---@field label? string User-facing command label. |
| 91 | +---@field desc? string User-facing command label. |
| 92 | +---@field lhs? string Vim-style left-hand side. |
| 93 | +---@field key? string Native WezTerm key name. |
| 94 | +---@field mods? string Native WezTerm modifier string. |
| 95 | +---@field rhs? any WezTerm action. |
| 96 | +---@field action? any WezTerm action. |
| 97 | + |
| 98 | +---@class Chord.CommandApi |
| 99 | +local Command = {} |
| 100 | + |
| 101 | +---Clear commands registered through `chord.command.register`. |
| 102 | +function Command.clear() end |
| 103 | + |
| 104 | +---Register an action-only command or a key-backed command. |
| 105 | +---@param spec Chord.CommandSpec |
| 106 | +---@return Chord.Command|nil command |
| 107 | +function Command.register(spec) end |
| 108 | + |
| 109 | +---Register many commands. |
| 110 | +---@param specs Chord.CommandSpec[] |
| 111 | +function Command.register_many(specs) end |
| 112 | + |
| 113 | +---Collect commands from registered entries, config keys, key tables, and defaults. |
| 114 | +---@param config_table table WezTerm config table. |
| 115 | +---@param opts? table Command options merged over `Chord.CommandConfig`. |
| 116 | +---@return Chord.Command[] commands |
| 117 | +function Command.collect(config_table, opts) end |
| 118 | + |
| 119 | +---Return a WezTerm action that opens the command picker. |
| 120 | +---@param config_table table WezTerm config table. |
| 121 | +---@param opts? table Command options merged over `Chord.CommandConfig`. |
| 122 | +---@return table action |
| 123 | +function Command.action(config_table, opts) end |
| 124 | + |
| 125 | +---Inject a trigger binding that opens the command picker. |
| 126 | +---@param config_table table WezTerm config table. |
| 127 | +---@param opts? table Command options merged over `Chord.CommandConfig`. |
| 128 | +---@return table action |
| 129 | +function Command.apply(config_table, opts) end |
| 130 | + |
| 131 | +---@class Chord |
| 132 | +---@field aliases table<string, string> |
| 133 | +---@field modifiers table<string, string> |
| 134 | +---@field command Chord.CommandApi |
| 135 | +local M = {} |
| 136 | + |
| 137 | +---Configure Chord. |
| 138 | +---@param opts? table Partial Chord configuration. |
| 139 | +---@return Chord chord Public API. |
| 140 | +function M.setup(opts) end |
| 141 | + |
| 142 | +---Return the active Chord configuration. |
| 143 | +---@return Chord.Config config |
| 144 | +function M.config() end |
| 145 | + |
| 146 | +---Validate a Vim-style key expression. |
| 147 | +---@param lhs string Vim-style key expression. |
| 148 | +---@return boolean valid |
| 149 | +---@return string|nil error_message |
| 150 | +function M.validate(lhs) end |
| 151 | + |
| 152 | +---Normalize a Vim-style key expression to a WezTerm key entry fragment. |
| 153 | +---@param lhs string Vim-style key expression. |
| 154 | +---@return table|nil entry |
| 155 | +---@return string|nil error_message |
| 156 | +function M.normalize(lhs) end |
| 157 | + |
| 158 | +---Create a WezTerm key entry from either native syntax or Vim-style syntax. |
| 159 | +---@param lhs_or_spec string|Chord.VimMapping|Chord.KeyEntry |
| 160 | +---@param action? any WezTerm action when `lhs_or_spec` is a string. |
| 161 | +---@param desc? string Optional description. |
| 162 | +---@return Chord.KeyEntry|nil entry |
| 163 | +function M.key(lhs_or_spec, action, desc) end |
| 164 | + |
| 165 | +---Append a single key mapping to a target table. |
| 166 | +---@param lhs_or_spec string|Chord.VimMapping|Chord.KeyEntry |
| 167 | +---@param action any WezTerm action. |
| 168 | +---@param target table Target list to mutate. |
| 169 | +function M.map(lhs_or_spec, action, target) end |
| 170 | + |
| 171 | +---Append a batch of key mappings to a target table. |
| 172 | +---@param mappings (Chord.VimMapping|Chord.KeyEntry)[] |
| 173 | +---@param target table Target list to mutate. |
| 174 | +function M.map_batch(mappings, target) end |
| 175 | + |
| 176 | +---Convert Vim-style mappings to a WezTerm key table. |
| 177 | +---@param mappings (Chord.VimMapping|Chord.KeyEntry)[] |
| 178 | +---@return Chord.KeyEntry[] key_table |
| 179 | +function M.table(mappings) end |
| 180 | + |
| 181 | +---Append mappings to `config.keys`. |
| 182 | +---@param config_table table WezTerm config table. |
| 183 | +---@param mappings (Chord.VimMapping|Chord.KeyEntry)[] |
| 184 | +function M.maps(config_table, mappings) end |
| 185 | + |
| 186 | +---Register modal key tables and write them into `config.key_tables`. |
| 187 | +---@param config_table table WezTerm config table. |
| 188 | +---@param defs table<string, Chord.KeyTableDef|Chord.KeyTableDefFn> |
| 189 | +function M.tables(config_table, defs) end |
| 190 | + |
| 191 | +---Apply user overrides to already-built keys and key tables. |
| 192 | +---@param config_table table WezTerm config table. |
| 193 | +---@param overrides Chord.Overrides |
| 194 | +function M.apply_overrides(config_table, overrides) end |
| 195 | + |
| 196 | +---Return registered key-table metadata for mode displays. |
| 197 | +---@param theme table Theme or color table passed to key-table definition functions. |
| 198 | +---@return table<string, Chord.KeyMeta> modes |
| 199 | +function M.get_modes(theme) end |
| 200 | + |
| 201 | +---Render a plain-text key-hint bar for the active key table. |
| 202 | +---@param config_table table WezTerm config table. |
| 203 | +---@param name? string Key-table name. `nil` uses top-level keys. |
| 204 | +---@param width_cols integer Available terminal columns. |
| 205 | +---@param window Window WezTerm window. |
| 206 | +---@return string hint |
| 207 | +function M.hint(config_table, name, width_cols, window) end |
| 208 | + |
| 209 | +---Render a Ribbon key-hint bar for the active key table. |
| 210 | +---@param config_table table WezTerm config table. |
| 211 | +---@param name? string Key-table name. `nil` uses top-level keys. |
| 212 | +---@param width_cols integer Available terminal columns. |
| 213 | +---@param window Window WezTerm window. |
| 214 | +---@param opts { theme: table, mode_bg: string } |
| 215 | +---@return Ribbon layout |
| 216 | +function M.hint_layout(config_table, name, width_cols, window, opts) end |
| 217 | + |
| 218 | +---Return an action callback that changes the visible hint page. |
| 219 | +---@param name? string Key-table name. |
| 220 | +---@param direction integer Page delta. |
| 221 | +---@return table action |
| 222 | +function M.hint_action(name, direction) end |
| 223 | + |
| 224 | +-- vim: set ts=2 sts=2 sw=2 et ai si sta: |
0 commit comments