Giter Site home page Giter Site logo

lambdalisue / gina.vim Goto Github PK

View Code? Open in Web Editor NEW
691.0 18.0 27.0 1.47 MB

๐Ÿ‘ฃ Asynchronously control git repositories in Neovim/Vim 8

Home Page: http://www.vim.org/scripts/script.php?script_id=5531

License: MIT License

Shell 0.19% AppleScript 0.20% Vim Script 99.60%
vim neovim git plugin jobs asynchronously vim-gita gina

gina.vim's Introduction

๐Ÿ‘ฃ gina.vim

Version 1.0 Support Vim 8.1 or above Support Neovim 0.4 or above Support Git 2.25 or above Powered by vital.vim MIT License Doc Doc (dev)

reviewdog vim neovim


WARNING

Development of gina.vim is stopped. Users should be patient with existing bugs or check gin.vim that is under active development. Any further improvements of features will be applied to gin.vim instead.


gina.vim (gina) is a plugin to asynchronously control git repositories.

Presentation

You've been Super Viman. After this talk, you could say you are Super Viman 2 -- Life with gina.vim

I've talked about what the gina.vim is in VimConf2017 (Slide). Check it out if you would like to feel what the gina.vim is.

Usage

The following is a schematic image of general working-flow with gina.

   โ”Œโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚     โ”‚          โ”‚
#DIRTY#  โ”‚          โ–ผ
   โ–ฒ     โ”‚    :Gina status  โ”‚ <<  : stage
   โ”‚     โ”‚          โ”‚       โ”‚ >>  : unstage
   โ”‚     โ”‚          โ”‚       โ”‚ --  : toggle
:write   โ”‚       #STAGED#   โ”‚ ==  : discard
   โ–ฒ     โ”‚          โ”‚       โ”‚ pp  : patch
   โ”‚     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค       โ”‚ dd  : diff
   โ”‚     โ”‚          โ–ผ
#CLEAN#  โ”‚     :Gina commit โ”‚ !   : switch --amend
   โ”‚     โ”‚          โ”‚       โ”‚ :w  : save cache
   โ”‚     โ–ผ          โ”‚       โ”‚ :q  : commit changes (confirm)
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚ :wq : commit changes (immediate)

So basically user would

  1. Edit contents in a git repository
  2. Stage changes with :Gina status
  3. Commit changes with :Gina commit

See :h gina-usage for advance usage. Gina provides a lot more features.

Pros.

  • A git detection is fast and accurate
    • It does not require git process so incredibly fast
    • Used in lambdalisue/vim-gita, for several years
  • Commands are asynchronously performed
    • Users don't have to wait :Gina push (git push)
    • Asynchronous feature in Neovim is great. :Gina log (git log) on Linux repository won't freeze Neovim
  • Single command. Users do not need to remember tons of commands
    • :Gina {command} will execute a gina command or a git raw command asynchronously
    • :Gina! {command} will execute a git raw command asynchronously
    • :Gina!! {command} will execute a git raw command in a shell (mainly for :Gina!! add -p or :Gina!! rebase -i)
  • Action based. Users do not need to remember tons of mappings
    • ? to see the help
    • a to select an action to perform (complete with <Tab>)
    • . to repeat previous action
    • All action can map to an actual keymap
  • Author tried to follow Vim's flavor
    • No mapping for ee or whatever which conflicts with Vim's native mappings (like vim-gita does...)
  • Customizable
    • Users can define action aliases and mappings
    • Users can define default options and aliases of command
    • More
  • Tested on all major platforms
    • Powered by vim-jp/vital.vim, mean that the things are unit tested
    • Gina add some behaviour test as well

Contribution

Any contribution including documentations are welcome.

Contributers should install thinca/vim-themis to run tests before sending a PR if they applied some modification to the code. PRs which does not pass tests won't be accepted.

License

The code in gina.vim follows MIT license texted in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.

gina.vim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gina.vim's Issues

Improve CI environment

Linux/Mac

  • Consider using CircleCI while Travis is way slow
  • Run tests with Vim
    • A minimum supported version (8.0.0134)
    • A latest release version (HEAD)
  • Run tests with Neovim
    • A minimum supported version (0.1.7)
    • A latest release version (HEAD)

Windows

Not sure the followings are possible while building Vim from source on Windows is painful.

  • Run tests with official Vim
    • A minimum supported version or close (8.0.0134)
    • A latest release version or close (HEAD)
  • Run tests with Kaoriya Vim
    • A minimum supported version or close (8.0.0134)
    • A latest release version or close (HEAD)
  • Run tests with Neovim if possible
    • A minimum supported version (0.1.7)
    • A latest release version (HEAD)

Guess line/col from the current buffer if possible

Rel. #45 (comment)

It would be nice if :Gina show, :Gina compare, :Gina chaperon, :Gina patch, and :Gina blame open a buffer with a current line/col. But it is a bit complicated

  1. If {treeish} of the current buffer is equal to a buffer will be open, line/col should be guessed
    e.g. :Gina show : on a real file, :Gina compare HEAD...: on gina://xxx:show/HEAD:...
  2. If {treeish} of the current buffer is equal to a buffer will be open but the current buffer is not a file content (e.g. diff), line/col should NOT be guessed
    e.g. :Gina show : on gina://xxx:diff/HEAD:...
  3. If {treeish} of the current buffer is not equal to a buffer will be open, line/col should NOT be guessed
    e.g. :Gina show :README.md on gina://xxx:grep/...

Use resolve in expand

Gina show would fail for a symlink file because expand return a path for a symlink file and the path does not belongs to the repository.

Add a pseudo cleanup mode 'verbose' for git commit --verbose

Partially related to #37

Currently gina use a fake cleanup method with --cleanup=scissors to support Gina commit --verbose but actually --cleanup=scissors won't remove commentary.
So the fake cleanup method should understand --verbose and do strip and scissors and make scissors as realy scissors.

Allow Gina tag -a without -m option

git tag -a requires a commit like content so it is not supported for now.
It would be nice if Gina tag -a xxx opens an editing buffer like Gina commit

Consider 'nomodeline'

Vim's modeline feature breaks filetype often in :Gina commit, :Gina show, :Gina diff, and :Gina blame. So I think these command should set nomodeline.

Rel. #45 (comment)

RFC: Settle what kind of actions are available on each buffer.

Currently, actions of each buffer are not settled while I haven't consider it carefully (rel. #22)
So I would like to hear your opinions for what kind of actions should be available on each buffer. Basically, I would like to hear what do you want to do in each buffer.

blame

  • Confirm a detail about the chunk (blame:echo)
  • Open a blame of the selected chunk (blame:open)
  • Back to the previous blame (blame:back)
  • Open a system browser to show a blame in remote (browse)
  • Open a content on a revision of a chunk (show)
  • Open a commit on a revision of a chunk (show:commit)
  • Find what kind of changes was applied on the content at the revision of the chunk
    (diff, compare)
  • Find which files has changed at the revision of a chunk
    (changes)

branch

  • Create a new branch (branch:new)
  • Rename a branch (branch:move)
  • Delete a branch (branch:delete)
  • Set an upsream of a branch (branch:set-upstream-to)
  • Unset an upstream of a branch (branch:unset-upstream)
  • Open a branch in remote (browse)
  • Find which files are changed from the current HEAD (changes)
  • Checkout a local branch (branch:checkout)
  • Checkout a remote branch as a detached head (branch:checkout)
  • Checkout a remote branch with a local branch with tarcking (branch:checkout:track)
  • Rebase a current HEAD with a selected branch (commit:rebase)
  • Merge a selected branch into a current HEAD (commit:merge)
  • Show a latest commit performed on the branch (show)

changes

grep

log

ls

reflog

status

tag

Change every backslash to forwardslash in pathspec on Windows

Gina log -- :/ drops fatal: :\: '\' is outside repository error on Windows. Changing the \ to / solves the problem.

Since Gina log -- path/to/directory shows the changes of a directory, it can be used to show the history of certain files too, for example Gina log -- :/ :!/**.vim will list the commits of non-Vim files (try git log --name-status -- :/ :!/**.vim to see the files changed in that commits).

Gina blame text not helpful

This is what I see when typing :Gina blame :. It is almost impossible to figure out what the text is.

image

If I resize the window it shows the diff marker but doesn't do right align.

image

I'm using vim8 on windows.

Investigate why Gina branch duplicate only in Travis.

I could not reproduce the following in local and AppVeyor.

https://travis-ci.org/lambdalisue/gina.vim/jobs/204637762#L1563

Failures:

  1) gina#command#branch Use cases might be called without arguments

     Error occurred line:

       4:       Assert Equals(getline(1, '$'), [ '  develop^[[m', '* ^[[32mmaster^[[m',])

     The equivalent values were expected, but it was not the case.

     

         expected: ['  develop^[[m', '* ^[[32mmaster^[[m']

              got: ['  develop^[[m', '* ^[[32mmaster^[[m  develop^[[m', '* ^[[32mmaster^[[m']

Now the test is skipped in Travis.
ef43fec

RFC: Auto detection of encoding/format for gina:// buffers

Any buffer opened by gina.vim cannot detect the content encoding/format automatically.
Users have to set these options manually if the these are different from the default (open with :Gina xxx ++enc=xxx ++ff=xxx or re-read content with :e ++enc=xxx ++ff=xxx).

This limitation is due to the performance issue. If I use Vim.Buffer.edit_content() internally, the encoding/format can be automatically detected by Vim but the feature is a bit slow.
Personally, I use utf-8 and most of project I interested also use utf-8 so current implementation is OK for me.
So I'd like to ask that who want auto-detection and what the priority of the feature for them?

If the priority of the auto-detectin feature is high, I'll probably implement that somehow.

Improve actions

  • Add <mods> feature so that users can perform with e.g. verbose
  • Add mark feature so that user first can select target candidates (e.g. denite.nvim)
  • Add params feature and use that instead of show:right or so on.

Gina commit show an error message on newly cloned repository

"prompt.py" 287L, 9447C
1 line less
"prompt.py" 286L, 9410C written
Error detected while processing function <SNR>323_BufReadCmd[3]..gina#core#exception#call[1]..<SNR>271_call[7]..<SNR>323_get_commitmsg[3]..<SNR>323_get_commitmsg_template:
line    3:
E484: Can't open file /Users/alisue/Code/github.com/lambdalisue/neovim-prompt/.git/COMMIT_EDITMSG

Related to #44 but #44 changes a lot so quick fix is required.

Support git rebase -i without :! or :term

Gina supports git's interactive feature by :Gina!! but it use :! or :term.
It would be nice if gina.vim support it without using :! or :term like :Gina patch which use three buffers to apply patch (alternative to :Gina!! add -p or :Gina!! reset -p)

The code for the git rebase -i is

https://github.com/git/git/blob/master/git-rebase--interactive.sh#L1312

So it seems not impossible once I made a special editor which

  1. Communicate with a current Vim
  2. Open .git/rebase-merge/git-rebase-todo on a current Vim
  3. Wait until the opened buffer is closed

But it is a bit complicated (especially Neovim omit --client feature and I don't know alternative) so may not be implemented.

Filetype incorrectly set when opening Gina blame :

When using with tscompletejob :Gina blame : doesn't work.

Instead I get the following error:
image

I add more logs to tscompletejob and found that the filetype of gina is set typescript hence tscompletejob throws error:

image

I add echom log in tscompletejob/autoload/tscompletejob/bufmanager.vim to print the filetype

func! s:addBuffer(filename) dict
    echom a:filename . ' ' . &ft
    let bn = s:getkey(a:filename)
    let filename = tscompletejob#utils#abspath(a:filename)
    if (l:bn == -1)
        throw "invalid buffer"
    elseif (!has_key(self.buffers, string(bn)))
        let self.buffers[string(l:bn)] = {
                    \ "filename" : filename,
                    \ "tmpfile" : tempname(),
                    \ "is_opened" : 0,
                    \ }
    endif
    return bn
endfunc

Seems to me more like a bug in Gina than in tscompletejob.

Note: I'm using vim8 on windows.

Gina commit fail to open a commit buffer sometime

The error message was

"gina://rook:commit" line 22 of 49 --44%-- col 12
Fail: git --no-pager -c core.editor=false -C /Users/alisue/.homesick/repos/rook commit --verbose --file=/var/folders/f_/dypbhlxd4cqg63lb40ykq0580000gn/T/nvimiiM3vS/24
[master 17a2d26] Update delay # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Your branch is up-to-date with 'origin/master'. # # Changes to be committed: #^Imodified:   home/.config/karabiner/karabiner.json #
 1 file changed, 4 insertions(+), 4 deletions(-)
Error detected while processing function <SNR>148_BufReadCmd[7]..gina#core#buffer#assign_content[3]..<SNR>108_edit_content[13]..<SNR>108_read_content:
line   33:
E94: No matching buffer for /var/folders/f_/dypbhlxd4cqg63lb40ykq0580000gn/T/nvimiiM3vS/25

Not sure how to reproduce this.

Window closed

If using terminal feature Gina!! [command] and more than one window, the focused window is removed.

Make a behavior clear for symlink file

  1. Find .git from a file path
  2. If fail, try to find .git from a resolved path

So a symlink file in a git repository would belongs to the repository. A symlink file not in a git repository may belongs to a git repository of an original file belongs.

Write tests for this behavior and document it more clearly.

Consider support +cmd

							*+cmd* *[+cmd]*
The [+cmd] argument can be used to position the cursor in the newly opened
file, or execute any other command:
	+		Start at the last line.
	+{num}		Start at line {num}.
	+/{pat}		Start at first line containing {pat}.
	+{command}	Execute {command} after opening the new file.
			{command} is any Ex command.
To include a white space in the {pat} or {command}, precede it with a
backslash.  Double the number of backslashes. >
	:edit  +/The\ book	     file
	:edit  +/dir\ dirname\\      file
	:edit  +set\ dir=c:\\\\temp  file
Note that in the last example the number of backslashes is halved twice: Once
for the "+cmd" argument and once for the ":set" command.

Export self-vital modules into external vital modules

The following self-vital modules should be exported to external vital modules while the performance and usability of self-vital modules are bit less than the external vital modules

  • Data.Queue
  • System.Store
  • Vim.Buffer.Group
  • Vim.BufferWriter (maybe Vim.Buffer.Writer)
  • Vim.Exception (maybe rename)
  • Vim.Highlight
  • Action (maybe App.Action)
  • Argument
  • Emitter (maybe App.Emitter)
  • Git (maybe VCS.Git)

ArchLinuxใฎNeoVim0.1.7-2ไธŠใง:Gina commitใ‚’่กŒใ†ใจไพ‹ๅค–ใŒๅ‡บใ‚‹

ๅ†็พๆƒ…ๅ ฑ

  1. gina.vimๅค–้ƒจใงgit add -a
  2. NeoVimใ‚’้–‹ใ„ใฆ:Gina commit
  3. commitใƒกใƒƒใ‚ปใƒผใ‚ธใ‚’ๅ…ฅๅŠ›ใ—ใฆ:wq
  4. ไปฅไธ‹ใฎไพ‹ๅค–ใŒๅ‡บใ‚‹
function <SNR>268_BufWriteCmd[3]..gina#core#exception#call[1]..<SNR>228_call[7]..<SNR>268_set_commitmsg[3]..<SNR>268_get_cleanup_mode[6]..gina#core#repo#config[7]..<SNR>2
66_extend_config ใฎๅ‡ฆ็†ไธญใซใ‚จใƒฉใƒผใŒๆคœๅ‡บใ•ใ‚Œใพใ—ใŸ:
่กŒ    6:
E713: ่พžๆ›ธๅž‹ใซ็ฉบใฎใ‚ญใƒผใ‚’ไฝฟใ†ใ“ใจใฏใงใใพใ›ใ‚“

NeoVimใฎใƒใƒผใ‚ธใƒงใƒณ

:version
NVIM 0.1.7
Build type: Release
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -Wconversion -O2 -DNDEBUG -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-param
eter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -D_GNU_SOURCE -I/build/neovim
/src/build/config -I/build/neovim/src/neovim-0.1.7/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/n
eovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Compiled by builduserใจใชใฃใฆใ„ใพใ™ใŒใ€ใ“ใกใ‚‰ใฏArchๅ…ฌๅผใƒชใƒใ‚ธใƒˆใƒชใ‹ใ‚‰ๅพ—ใ‚‰ใ‚Œใ‚‹ๆœ€ๆ–ฐ็‰ˆใฎNeoVimใงใ™ใ€‚

๐Ÿ˜„

Add statusline/tabline component

Like vim-gita provides. At least the followings are required

  • A local branch name
  • A tracked remote name
  • A tracked remote branch name
  • Commit count behind or ahead of remote
  • Current status (e.g. Hom many files are modified)

Change the command syntax for {revision} and/or {path}

I think there are some inconsistent behavior in the plugin from the view of a (command line) Git user.

For example Gina info invokes git show, while Gina show is some kind of buffer-related-git-show. I think it would be consistent to swap the command names.

Another thing what I don't understand: why it has to clean the commit message manually (07c177f)? Why don't you leave it to Git to do what already knows? Actually it trims the blank lines at the top of the buffer for me (on Windows, using commit message template via Git commit.templateconfig) plus when a new commit.cleanup option will be added to Git, you have to write the same function for Gina.

The summary line of a commit message is removed

It seems a first line of a commit message is removed...

Fail: git --no-pager -c core.editor=false -C /home/alisue/Code/github.com/lambdalisue/gina.vim commit --allow-empty --verbose --no-edit --file=/tmp/nvimh7wmVE/7
Aborting commit due to empty commit message.

Support shell/term execution

Related to #54, it seems vim-fugitive support git add -p or git rebase -i by using :! or :term (tpope/vim-fugitive#821)

While gina.vim use job, this kind of interactive feature could not be used. So it would be nice if :Gina add -p (even that gina.vim has :Gina patch instead) or :Gina rebase -i automatically recognize the options and use :! or :term instead or :Gina!! {command} execute a command with :! or :term (not sure if it is possible)

But this does not work on GVim while GVim does not have a shell (I've tested during development of vim-gita, at least for GVim in Linux or MacVim in Mac).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.