lambdalisue / vim-gina

👣 Asynchronously control git repositories in Neovim/Vim 8
http://www.vim.org/scripts/script.php?script_id=5531
MIT License
689 stars 27 forks source link

RFC: An action or mapping for switching gina-status/gina-commit #207

Closed ulidtko closed 5 years ago

ulidtko commented 5 years ago

Continuing from #203; basically, if I stand in gina status buffer and hit ? -- I get a quick cheatsheet menu, and there's no commit action if that menu. Similarly the a action menu doesn't have commit. It is pretty trivial to add a custom action for :Gina commit, but perhaps it's better to offer something by default, since committing is a pretty common action (at least, in my workflows).

I'd suggest capital C as the shortcut, leading from status buffer to a commit buffer.

I also think this is easy enough to implement, so me (or anybody else) might come up with a PR, if the change is generally agreed on.

lambdalisue commented 5 years ago

tl;dr

Use gina#custom#mapping#nmap() to define mappings for switch like

call gina#custom#mapping#nmap(
      \ 'status', 'C', ':<C-u>Gina commit<CR>',
      \ { 'nnoremap': 1, 'silent': 1 },
      \)
call gina#custom#mapping#nmap(
      \ 'commit', 'C', ':<C-u>Gina status<CR>',
      \ { 'nnoremap': 1, 'silent': 1 },
      \)

detail

It's still not clear to me why action is required because your explanation is mainly for mappings instead of actions (yeah, action is mainly for mappings but with candidates I feel).

If the commit action just execute :Gina commit and you just need a mapping for that, use Vim's native way to define mappings like

autocmd FileType gina-status
      \ nnoremap <silent><buffer> C
      \ :<C-u>Gina commit<CR>
autocmd FileType gina-commit
      \ nnoremap <silent><buffer> C
      \ :<C-u>Gina status<CR>

Or with gina#custom#mapping#nmap() (See :help gina-custom-mapping)

call gina#custom#mapping#nmap(
      \ 'status', 'C', ':<C-u>Gina commit<CR>',
      \ { 'nnoremap': 1, 'silent': 1 },
      \)
call gina#custom#mapping#nmap(
      \ 'commit', 'C', ':<C-u>Gina status<CR>',
      \ { 'nnoremap': 1, 'silent': 1 },
      \)

I think the above code is simple and easy enough to be written in your .vimrc. You don't need action just for mapping.

Actually, I use <C-^> to switch in my vimrc so I understand if you meant you would love to have default mappings for switching gina-status and gina-commit.

However, I'm not going to provide this feature as default mappings while the above code is simple and easy enough I feel (and I don't want to provide default mappings a lot.) Maybe this should be documented in somewhere?

lambdalisue commented 5 years ago

historical reason

I remember that in alpha version or vim-gita, there are default mappings for that. However I felt that users might think the following behavior as bug if I provide default mappings for that

  1. Hit :Gina commit --allow-empty
  2. Hit C to switch to gina-status
  3. Hit C to switch to gina-commit
  4. The --allow-empty option is not assigned to the gina-commit anymore

It's not too difficult to solve above issue, but it makes things way complicated so I decided to NOT provide mappings for switching.

ulidtko commented 5 years ago

Well OK, excellent description!

I did suspect that this is in a way intentional, to stimulate going through the route of custom config, just to show how easy it is :smiley: I'd need it anyway, sooner or later (e.g. blame -w, or --alow-empty, no GUI can do that). So no, I don't think a new action is needed.

Anyway, this issue makes a better FAQ entry than it would make a PR! Thanks for your work :)