From e1166cd1ea0b1d43679232c5d34ef0b192a7faaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Enrique=20Ram=C3=ADrez?= Date: Fri, 17 Jan 2020 13:19:58 +0100 Subject: [PATCH 1/4] introduce template options for displaying commit sha --- autoload/blamer.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/blamer.vim b/autoload/blamer.vim index 7fcd18e..7e4b332 100644 --- a/autoload/blamer.vim +++ b/autoload/blamer.vim @@ -71,6 +71,8 @@ function! blamer#GetMessage(file, line_number, line_count) abort let l:lines = split(l:result, '\n') let l:info = {} + let l:info['commit-short'] = split(l:lines[0], ' ')[0][:7] + let l:info['commit-long'] = split(l:lines[0], ' ')[0] for line in l:lines let l:words = split(line, ' ') let l:property = l:words[0] From 714f24eb557aa9e906ab63d8b7290649c0500fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Enrique=20Ram=C3=ADrez?= Date: Fri, 17 Jan 2020 13:25:00 +0100 Subject: [PATCH 2/4] remove first line from lines for the rest of property parsing --- autoload/blamer.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/blamer.vim b/autoload/blamer.vim index 7e4b332..b4f0b31 100644 --- a/autoload/blamer.vim +++ b/autoload/blamer.vim @@ -73,7 +73,7 @@ function! blamer#GetMessage(file, line_number, line_count) abort let l:info = {} let l:info['commit-short'] = split(l:lines[0], ' ')[0][:7] let l:info['commit-long'] = split(l:lines[0], ' ')[0] - for line in l:lines + for line in l:lines[1:] let l:words = split(line, ' ') let l:property = l:words[0] let l:value = join(l:words[1:], ' ') From 4528a981de55ec1c83a2f6dd41ffa4c367e62399 Mon Sep 17 00:00:00 2001 From: Cesar Enrique Ramirez Date: Fri, 24 Jan 2020 16:47:08 +0100 Subject: [PATCH 3/4] update README to include the two new options --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9ef702..84ac0f4 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The template for the blame message that will be shown. Default: `', '` -Available options: ``, ``, ``, ``, ``, ``, ``. +Available options: ``, ``, ``, ``, ``, ``, ``, ``, ``. ``` let g:blamer_template = ' ' From 09d8673e7cdca65ce654a9b8deb84b587d002220 Mon Sep 17 00:00:00 2001 From: apzelos Date: Mon, 3 Feb 2020 10:31:24 +0200 Subject: [PATCH 4/4] Closes #14 adds configuration for visual modes --- README.md | 10 ++++++++++ autoload/blamer.vim | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 84ac0f4..e9dd101 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,16 @@ Default: `1000` let g:blamer_delay = 500 ``` +#### Show in visual modes + +Enables / disables blamer in visual modes. + +Default: `1` + +``` +let g:blamer_show_in_visual_modes = 0 +``` + #### Prefix The prefix that will be added to the template. diff --git a/autoload/blamer.vim b/autoload/blamer.vim index b4f0b31..3b5189b 100644 --- a/autoload/blamer.vim +++ b/autoload/blamer.vim @@ -15,6 +15,7 @@ let s:blamer_user_email = '' let s:blamer_info_fields = filter(map(split(s:blamer_template, ' '), {key, val -> matchstr(val, '\m\C<\zs.\{-}\ze>')}), {idx, val -> val != ''}) let s:blamer_namespace = nvim_create_namespace('blamer') let s:blamer_delay = get(g:, 'blamer_delay', 1000) +let s:blamer_show_in_visual_modes = get(g:, 'blamer_show_in_visual_modes', 1) let s:blamer_timer_id = -1 function! s:Head(array) abort @@ -119,6 +120,12 @@ function! blamer#Show() abort let l:buffer_number = bufnr('') let l:line_numbers = s:GetLines() + + let l:is_in_visual_mode = len(l:line_numbers) > 1 + if l:is_in_visual_mode == 1 && s:blamer_show_in_visual_modes == 0 + return + endif + for line_number in l:line_numbers let l:message = blamer#GetMessage(l:file_path, line_number, '+1') call blamer#SetVirtualText(l:buffer_number, line_number, l:message)