Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic-slots #26

Merged
merged 5 commits into from
Mar 22, 2025
Merged

Conversation

Darukutsu
Copy link
Contributor

@Darukutsu Darukutsu commented Mar 21, 2025

new config option dynamicSlots can have 3 states:

  1. disabled -> use static slots, default behaviour
  2. original -> works as original neovim recording impl
  3. rotate -> goes through letters [a-z], if end is encountered it goes(overwrites) from start(a...)

I'm now reading I didn't need to edit .txt, oops. I tried implementing multiple features in single file I hope they will work after splitting. Sorry for formatting seems like lua_ls behaves differently than stylua.

@Darukutsu Darukutsu changed the title feature: add dynamic-slots feat: add dynamic-slots Mar 21, 2025
Copy link
Owner

@chrisgrieser chrisgrieser left a comment

Choose a reason for hiding this comment

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

Other than the smaller requested changes:

  • please use stylua to use this project's formatting standard, the diff is otherwise hard to read
  • it is not really clear to me what the difference between static and original slot behavior is supposed to be. I'm also not even sure what the use case for rotating between 26 slots would be?

@Darukutsu
Copy link
Contributor Author

Darukutsu commented Mar 21, 2025

offtopic question...Is there a way to have lua_ls and stylua at same time and it will automatically chose what to use depending on project dotfiles, and if there are none then prefer one over other?
I would like to be prepared for future multiple project standards, I use Mason and it's pretty much plug&play experience.

new config option dynamicSlots can have 3 states:
1. static   -> use static slots, default behaviour
2. original -> works as original neovim recording impl
3. rotate   -> rotates through letters specified in slots[]
@Darukutsu
Copy link
Contributor Author

sorry I wanted to make it easier for you to review... I encountered bug with "original" state. To replicate:

  1. record 2 macros
  2. switch to first recorded macro
  3. replay it and for some reason it starts recording new macro to @ however I can't see where the problem could be

@Darukutsu
Copy link
Contributor Author

  • it is not really clear to me what the difference between static and original slot behavior is supposed to be. I'm also not even sure what the use case for rotating between 26 slots would be?

original means that you press q followed by any letter {0-9a-zA-Z"}... maybe I should add there restriction so only letters from that range are allowed since i do reg = fn.nr2char(fn.getchar()). We don't need to specify them in slot... muscle memory :D

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 22, 2025

Before you invest even more time into this: let me repeat that it is still not clear to me what problem this PR solves.

  • for the "original" slot logic, why not just use macros without this plugin? Would be simpler to copypaste the one or two features this plugin then offers to you rather than using this plugin.
  • for the "rotating" system: what is the use case for it? It looks like a very niche use case for users who want to record a lot of different macros at the same time.

As it stands right now, I am not convinced that the PR adds enough benefit to justify merging it.

@Darukutsu
Copy link
Contributor Author

I like that I can yank macros, edit them, have notification when recording etc, however I don't like that I have to specify them and manually switch between them when I need to have 2 macros at same time. Thus if someone wants those features they can either use original or use rotate without needing to do <C-q> to switch.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 22, 2025

So the benefit of original is to save one C-q keystroke in case of multiple macros, at the cost of adding one keystroke (the register) in case of multiple macros or a simple one-of macro. That even looks like a net increase of keystrokes to me, while the feature does require a bunch of code which potentially adds bugs.

rotating, too, only saves occasionally one key stroke, but in case of a quick one-of macro, you need to manually switch back to the register you recorded a macro in. So at least in the case of recording multiple macros in parallel I can see a minor benefit. While not a big benefit, the added code is not a lot and quite straightforward and I can see at glance that it won't add potential for bugs.

Thus, I think reducing this PR to just adding the recording behavior would make the most sense.

@Darukutsu
Copy link
Contributor Author

Darukutsu commented Mar 22, 2025

I recorded 3 macros (reg abc) and when want to change regb I need to do 2 times <C-q> when on regc. Thus original

I accidentally pressed q without changing register with <C-q>, realized it after recording half of macro and overwrote reqa which I wanted to keep. Thus rotate.

but in case of a quick one-of macro, you need to manually switch back to the register you recorded a macro in

What you mean? Q works because we rotate when recording to new slot and stay there.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 22, 2025

I recorded 3 macros (reg abc) and when want to change reg b I need to do 2 times when on regc. Thus original

Imo, the rare case of saving one key stroke here simply does not justify the amount of complexity added by that feature. As an open source maintainer I have to weigh benefit and future maintenance cost, sorry.

The benefit of rotating is rather small, but it requires not a lot of code, so it's fine.

All in all, the case for rotating sounds convincing to me, the one for original does not. So I suggest just to add the former in this PR.

@Darukutsu
Copy link
Contributor Author

Sure np, your project... Imo the code for original uses standard lua there is not a lot of complicated logic. Only call that could change in future is reg = fn.nr2char(fn.getchar()). Ofc it might complicate reworks of code in future, but in terms of bugs I haven't experienced any(after fix) and I could offer myself with maintaining that part of code, just ping me. If not then nwm.

Is there anything you would like me to do with rotate, or just remove original.
I'm asking if you could try rotate yourself to see if impl is ok for you...
Like when you have reg abc it starts from b so maybe I should add something to start from a when opening buffer first time.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 22, 2025

Remove original, and make rotate start with a yes. Then I can have a look.

I think the simplest solution to start with a is to just use a firstRun variable and not switch the slot on the first start of a recording.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 22, 2025

offtopic question...Is there a way to have lua_ls and stylua at same time and it will automatically chose what to use depending on project dotfiles, and if there are none then prefer one over other?
I would like to be prepared for future multiple project standards, I use Mason and it's pretty much plug&play experience.

As far as I can tell, most nvim plugins use stylua. Reason being that it's easier to add to a ci pipeline and also more established, at least for formatting.

I personally only use stylua for formatting and never worked in a project that uses lua_ls. If you work on some projects that use stylua and others that use lua_ls, you could write a small custom function that calls the respective formatting command depending on the presence of a stylua.toml.

Copy link
Owner

@chrisgrieser chrisgrieser left a comment

Choose a reason for hiding this comment

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

Minor point, otherwise looks good

@chrisgrieser chrisgrieser merged commit d422d0f into chrisgrieser:main Mar 22, 2025
4 checks passed
@chrisgrieser
Copy link
Owner

Thanks for the PR!

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