Skip to content

Commit

Permalink
feat: let callback function use all available parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Jan 10, 2023
1 parent 8a98c7d commit 480badd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Each component may contain _any_ of the following fields:
- `on_click`:
- Type: `table` with the following fields:
- `callback`: (vim/)lua function to be called on mouse click(s). The function
has the signature `function(self, minwid, nclicks, button)`
has the signature `function(self, minwid, nclicks, button, mods)`
(see `:h 'statusline'` description for `@`). If a `string` is provided,
it is interpreted as the _raw_ function name (`v:lua.` is not prepended)
of an already defined function accessible from vim global scope.
Expand Down
4 changes: 2 additions & 2 deletions lua/heirline/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ local function register_global_function(component)
return "v:lua." .. func_name
end

_G[func_name] = function(minwid, nclicks, button)
on_click.callback(component, minwid, nclicks, button)
_G[func_name] = function(...)
on_click.callback(component, ...)
end
return "v:lua." .. func_name
end
Expand Down

0 comments on commit 480badd

Please sign in to comment.