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

trim git commit message if message length > window width #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ See Git Blame information in the status bar for the currently selected line.

![](https://wx2.sinaimg.cn/large/bceaad1fly1frwfmv50ytj21kw0in42a.jpg)

Additional Feature
------------------

This fork has the trim message length in the status line, mainly for users who use 1 line height to avoid git commit message > 1 line height and gets prompted to PRESS ENTER TO CONTINUE.

Installation
--------------

Expand All @@ -36,16 +41,16 @@ then simply copy and paste:
Using [vim-plug](https://github.com/junegunn/vim-plug):

```vim
Plug 'zivyangll/git-blame.vim'
Plug 'wotzhs/git-blame.vim'
```

Using [Vundle](https://github.com/VundleVim/Vundle.vim)

```viml
Plugin 'zivyangll/git-blame.vim'
Plugin 'wotzhs/git-blame.vim'
```

Please setting bindings
Manual binding
-----------------

** You must push the map in your vimrc to avoid conflicts with other plugins you may have installed.: **
Expand All @@ -54,6 +59,17 @@ Please setting bindings
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>
```

Auto git blame on current line
-----------------

Taking the cue from [@Edo78](https://github.com/Edo78)'s [comment](https://github.com/zivyangll/git-blame.vim/issues/20#issuecomment-534526591), add the following to your `~/.vimrc`:

```vim
autocmd CursorHold * :call gitblame#echo()
```

This will display the git blame after the cursor is held momentarily.

Quick start guide
-----------------

Expand Down
4 changes: 4 additions & 0 deletions autoload/gitblame.vim
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function! gitblame#echo()
let l:echoMsg = '['.l:gb['error'].']'
else
let l:echoMsg = '['.l:gb['commit_hash'][0:8].'] '.l:gb['summary'] .l:blank .l:gb['author_mail'] .l:blank .l:gb['author'] .l:blank .'('.l:gb['author_time'].')'
let excess = strwidth(l:echoMsg) - winwidth(0)
if excess > 0
let l:echoMsg = '['.l:gb['commit_hash'][0:8].'] '.l:gb['summary'][:strwidth(l:gb['summary'])-excess-5] .'...' .l:blank .l:gb['author_mail'] .l:blank .l:gb['author'] .l:blank .'('.l:gb['author_time'].')'
endif
endif
if (g:GBlameVirtualTextEnable)
let l:ns = nvim_create_namespace('gitBlame'.b:GBlameVirtualTextCounter)
Expand Down