mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:50:05 +08:00
feat(git): use notify api to display error
`Git log` should not open log buffer for non-git repository files
This commit is contained in:
parent
ba3d524c13
commit
ff2c5a4d6c
@ -1,7 +1,9 @@
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
||||
let s:NOTI = SpaceVim#api#import('notify')
|
||||
|
||||
let g:git_log_pretty = 'tformat:%Cred%h%Creset - %s %Cgreen(%an %ad)%Creset'
|
||||
let s:bufnr = -1
|
||||
|
||||
function! git#log#run(...) abort
|
||||
if len(a:1) == 1 && a:1[0] ==# '%'
|
||||
@ -9,8 +11,6 @@ function! git#log#run(...) abort
|
||||
else
|
||||
let cmd = ['git', 'log', '--graph', '--date=relative', '--pretty=' . g:git_log_pretty] + a:1
|
||||
endif
|
||||
let s:bufnr = s:openLogBuffer()
|
||||
let s:lines = []
|
||||
call git#logger#info('git-log cmd:' . string(cmd))
|
||||
call s:JOB.start(cmd,
|
||||
\ {
|
||||
@ -22,11 +22,16 @@ function! git#log#run(...) abort
|
||||
endfunction
|
||||
|
||||
function! s:on_stdout(id, data, event) abort
|
||||
if !bufexists(s:bufnr)
|
||||
let s:bufnr = s:openLogBuffer()
|
||||
endif
|
||||
call s:BUFFER.buf_set_lines(s:bufnr, getline('$') ==# '' ? 0 : -1 , -1, 0, a:data)
|
||||
endfunction
|
||||
function! s:on_stderr(id, data, event) abort
|
||||
for data in a:data
|
||||
call git#logger#info('git-log stderr:' . data)
|
||||
let s:NOTI.notify_max_width = strwidth(data) + 5
|
||||
let s:NOTI.timeout = 3000
|
||||
call s:NOTI.notify(data, 'WarningMsg')
|
||||
endfor
|
||||
endfunction
|
||||
function! s:on_exit(id, data, event) abort
|
||||
|
Loading…
Reference in New Issue
Block a user