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

Vim Motions #10

Closed
diego-rapoport opened this issue Apr 16, 2024 · 19 comments · Fixed by #46
Closed

Vim Motions #10

diego-rapoport opened this issue Apr 16, 2024 · 19 comments · Fixed by #46

Comments

@diego-rapoport
Copy link

Is it planned to have Vim motions in general navigation and editing?

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 16, 2024

Hello!
Yes it is part of the things planned for after v1.0.0 (which will come out soon).
Something I was wondering since I am not a vim user, do you mean "command-like" bindings e.g. :wq, or just the basic key binding?

@Julien-cpsn Julien-cpsn added the enhancement New feature or request label Apr 16, 2024
@diego-rapoport
Copy link
Author

Hi!

I was first thinking about vim motions like hjkl as arrow keys to move arround, even to replace TAB as moving. Maybe have something like vim mode as INSERT to edit the url and then come back to NORMAL so you can keep moving.
Command-like bindings sounds good too but I can't think right now how it could do usefull things.

@brandon1024
Copy link

I would love to see this too. I use Vim as my primary editor and vim motions feel so natural to me, so I initially had a hard time playing around with atac.

@mzndr
Copy link

mzndr commented Apr 19, 2024

Ideally you would navigate with hjkl instead of arrow keys. Whenever you have to delete something, you'd usually add dd as an input for that. Editing request bodies etc. should also also mimic vim to a reasonable extend. It would be great to enable a workflow where you can use actual vim for editing requests, but to be honest, I haven't looked into the file structure that atac generates yet, maybe its possible to raw-dog these files with nvim.

A great start would be something like this:
hjkl instead of arrow keys
dd to delete stuff
CTRL + D or CTRL + U to navigate up/down a bunch
/ to search for stuff.

I think lazygit has a good implementation, btm also comes to mind.

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 19, 2024

Ideally you would navigate with hjkl instead of arrow keys. Whenever you have to delete something, you'd usually add dd as an input for that. Editing request bodies etc. should also also mimic vim to a reasonable extend. It would be great to enable a workflow where you can use actual vim for editing requests, but to be honest, I haven't looked into the file structure that atac generates yet, maybe its possible to raw-dog these files with nvim.

A great start would be something like this: hjkl instead of arrow keys dd to delete stuff CTRL + D or CTRL + U to navigate up/down a bunch / to search for stuff.

I think lazygit has a good implementation, btm also comes to mind.

I am currently working on it in https://github.com/Julien-cpsn/ATAC/tree/10-vim-motions.

The implemenation will be simple at first.
And I will try to make the full bindings implemenation on the request body text area so you don't loose your mind :)

@mzndr
Copy link

mzndr commented Apr 19, 2024

Thats great! I'll happily test that feature and provide feedback.

Trying to implement the full range of vim motions in the text area might be way too much (unless theres a library for that or something), since theres a lot of more complex motions that vim users frequently rely on (for examlple ci", da}, dap, caW), so don't aim too high. It might be better to implement the basics, and enable a workflow where one can use their editor of choice to edit requests. As a vim user I'll always prefer to do the heavy lifting of text editing with my actual configured instance of nvim.

@Julien-cpsn
Copy link
Owner

@mzndr the text area lib that I use has an implementation of it
https://github.com/rhysd/tui-textarea/blob/main/examples/vim.rs

So I'll try to do something like this

@mzndr
Copy link

mzndr commented Apr 19, 2024

Sounds great! A lot of vim is muscle memory, so its always hard to tell whats missing before you actually use it. But lets be honest, even basic vim motions would be a huge improvement for vim users, and its really great that you're working on it. Love to see it!

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 21, 2024

@mzndr @brandon1024 @diego-rapoport @ndtoan96 @greyblake @kayuxx
Hello guys!

I have been working on the configurable key-bindings and Vim implementation for the last 20 hours (no joke)
Since it reworks most the application's key and event systems, I would like some people to test it before pushing it into prod.

All the code is here: https://github.com/Julien-cpsn/ATAC/tree/10-vim-motions

You can pull it. At first you will see that almost nothing has changed.
If you want to enable the "Vim config" you have to set the ATAC_KEY_BINDINGS env variable to a key-bindings config file. Luckily I made one for Vim users in key_bindings_templates/vim_key_bindings.toml. I am not a vim user so it may not be perfect.
You can have it here https://github.com/Julien-cpsn/ATAC/blob/10-vim-motions/key_bindings_templates%2Fvim_key_bindings.toml

The Vim shortcuts are almost fully implemented when editing the request body

If you struggle finding keys etc, you can press Ctrl-h (or Shift-h with the Vim config) from anywhere to display the key-bindings help

Also, if you have any question, do not hesitate

Enjoy!

@Julien-cpsn
Copy link
Owner

@kayuxx is your backspace problem resolved? (when editing the URL)

@diego-rapoport
Copy link
Author

diego-rapoport commented Apr 22, 2024

Hey @Julien-cpsn!!
Thanks for your time and work for this feature. I know that many devs who works directly on the terminal would love some vim keybindings.
I tested a bit and the side panel with the collections are very good just as editing the body request. Just what I expected.
Haven't tried the cookies part but the keybindings seems good either.

Still getting used to it, but most of default keybinds were already good like u for editing the URL. a to change auth and t for tab. Also no need to delete with the x key on the URL, but move around with Ctrl h and Ctrl l is very helpfull.

I could think of another good key: ciw as change inside word

I had some difficulties trying to edit the value of params.

If you want me to test some other things I'd be very glad to help!

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 22, 2024

Thanks for your precious feedback!

I did some changes regarding what @ndtoan96 said here https://github.com/Julien-cpsn/ATAC/pull/44/files and my personnal thoughts.
You can pull the branch to get those updates!

Here are the updates:

  • delete_forward was x and is now Backspace
  • added alt_move_cursor for generic navigation (the k j inputs were never received as a reel char input while creating a request, because it was used for selecting a collection):
# Used when the base keys are not available (Selecting collection while creating a new request)
# Might not happen when using the default config
alt_move_cursor_up = "Ctrl-k"
alt_move_cursor_down = "Ctrl-j"
alt_move_cursor_left = "Ctrl-h"
alt_move_cursor_right = "Ctrl-l"

Still getting used to it, but most of default keybinds were already good like u for editing the URL. a to change auth and t for tab. Also no need to delete with the x key on the URL, but move around with Ctrl h and Ctrl l is very helpfull.

The x key has been fixed!

I could think of another good key: ciw as change inside word
I had some difficulties trying to edit the value of params.

Actually, the c key came from cw but it's really not that practical, and I cannot implement multi-key combinations such as ciw or cw. So choose another :)) (temporarily set to Enter)

If you want me to test some other things I'd be very glad to help!

I am begging you to do so 😆

@NachoNievaG
Copy link

This would be a natural UX enhancement as TUI apps (like LazyGit) already have some sort of vim navigations at least.
Not necessarily related, I made a floating term client for ATAC inside neovim, so hopefully the vim motions inside ATAC + nvim plugin will make a fairly comfortable combo.

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 22, 2024

This would be a natural UX enhancement as TUI apps (like LazyGit) already have some sort of vim navigations at least.

Read 3 messages before this one in order to test it out hahah. I wrote down the procedure
#10 (comment)

Not necessarily related, I made a floating term client for ATAC inside neovim, so hopefully the vim motions inside ATAC + nvim plugin will make a fairly comfortable combo.

Very good! Can I put it in my readme ?

@NachoNievaG
Copy link

NachoNievaG commented Apr 22, 2024

Very good! Can I put it in my readme ?

Of course! 🚀

Read 3 messages before this one in order to test it out hahah. I wrote down the procedure

In this matter, I made the copy as curl feature in my fork, i don't know if you want the PR to go straight to main branch or create with vim-motions branch as target. Please LMK !

@Julien-cpsn
Copy link
Owner

@NachoNievaG very great!
Main branch is great

@kayuxx
Copy link

kayuxx commented Apr 23, 2024

@Julien-cpsn Yeah, it works. I just checked the keybindings and it was mapped to x instead of Backspace, so I remapped it and it works fine. Thank you for the feature!

@Julien-cpsn
Copy link
Owner

Julien-cpsn commented Apr 23, 2024

@kayuxx is it ready for production you think?

Btw you can pull the branch to get some updates

@kayuxx
Copy link

kayuxx commented Apr 23, 2024

@Julien-cpsn Yes, I think it's ready to be used. It just has one thing to do. It would be great to implement these Vim keybindings #44.

@Julien-cpsn Julien-cpsn linked a pull request Apr 23, 2024 that will close this issue
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants