Skip to content

feat(api): expose generic "*_to" functions#141

Merged
aserowy merged 5 commits into
aserowy:mainfrom
rudenkornk:api
Apr 13, 2026
Merged

feat(api): expose generic "*_to" functions#141
aserowy merged 5 commits into
aserowy:mainfrom
rudenkornk:api

Conversation

@rudenkornk

Copy link
Copy Markdown
Contributor

I have a little annoying move and resize dispatchers in neovim config, which could be avoided if I could have access to generic navigation.

Copilot AI review requested due to automatic review settings April 9, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes generic direction-based APIs (e.g., *_to) in the public tmux Lua module to allow consumers (like Neovim configs) to call move/resize/swap operations with a runtime direction instead of dedicated per-direction functions.

Changes:

  • Add move_to(direction) as a generic navigation wrapper.
  • Add resize_to(direction, step) as a generic resize dispatcher.
  • Export swap_to(direction) via the top-level tmux module and document these APIs in the README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
README.md Documents the new generic *_to APIs and updates resize examples to show optional step usage.
lua/tmux/resize.lua Adds M.to(direction, step) dispatcher that routes to to_left/to_bottom/to_top/to_right.
lua/tmux/navigation/init.lua Adds M.to(direction) wrapper calling into navigate.to(direction).
lua/tmux/init.lua Exposes move_to, resize_to, and swap_to on the public require("tmux") API surface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aserowy

aserowy commented Apr 10, 2026

Copy link
Copy Markdown
Owner

omfg this bs copilot review. im sorry.

@aserowy

aserowy commented Apr 10, 2026

Copy link
Copy Markdown
Owner

disabled..

Repository owner deleted a comment from Copilot AI Apr 10, 2026
Repository owner deleted a comment from Copilot AI Apr 10, 2026
Repository owner deleted a comment from Copilot AI Apr 10, 2026
Repository owner deleted a comment from Copilot AI Apr 10, 2026
Repository owner deleted a comment from Copilot AI Apr 10, 2026
Repository owner deleted a comment from Copilot AI Apr 10, 2026
@aserowy

aserowy commented Apr 10, 2026

Copy link
Copy Markdown
Owner

hmm, im unsure about this one. it abstracts the motion away by hjkl and is not really verbose. i would go with e.g. *_to('left'), but this will not help you either :D

@rudenkornk

Copy link
Copy Markdown
Contributor Author

WDYM by abstracting from hjkl? Current API does not focus on these nvim commands either, only left/right/top/bottom.

I can replace direction arg with more verbose left/right/top/bottom instead of hjkl. Does that sound good?

@aserowy

aserowy commented Apr 11, 2026

Copy link
Copy Markdown
Owner

I can replace direction arg with more verbose left/right/top/bottom instead of hjkl. Does that sound good?

sry, not a native speaker :D and yes, exactly that was what i meant.

Comment thread lua/tmux/swap.lua Outdated
end

function M.to(direction)
function M._to(direction)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

since this api is changing to be consinstent with other to directions, add the mapping from direction to hjkl directly here and rework the calls inside to_left...

thus, we have a clean api and not .to and ._to which can be confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread lua/tmux/swap.lua Outdated
M._to("l")
end

-- Note: this function is exposed to public API and uses "left/right/top/bottom" as direction,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

remove all comments. they are redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@rudenkornk

Copy link
Copy Markdown
Contributor Author

I pushed diff as a separate commit (if that is what you asked).
Do not forget to keep only the first commit message upon merging to keep messages clean :)

@rudenkornk rudenkornk requested a review from aserowy April 12, 2026 07:45
@aserowy

aserowy commented Apr 12, 2026

Copy link
Copy Markdown
Owner

coverage decreases. please add specs accordinly.

kind regards
alexander

@rudenkornk

Copy link
Copy Markdown
Contributor Author

Done, I think

@aserowy aserowy merged commit 32ceaf2 into aserowy:main Apr 13, 2026
2 checks passed
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.

3 participants