Skip to content

Commit

Permalink
enable health check on vim again
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Sep 5, 2024
1 parent 188da08 commit edc603d
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions autoload/health/gitmessenger.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
if has('nvim')
function! s:report_error(msg, ...) abort
if a:0 ==# 0
call v:lua.vim.health.error(a:msg)
else
call v:lua.vim.health.error(a:msg, a:1)
endif
endfunction
function! s:report_warn(msg, note) abort
call v:lua.vim.health.warn(a:msg, a:note)
endfunction
function! s:report_ok(msg) abort
call v:lua.vim.health.ok(a:msg)
endfunction
else
function! s:report_error(msg) abort
call health#report_error(a:msg)
endfunction
function! s:report_warn(msg, note) abort
call health#report_warn(a:msg, a:note)
endfunction
function! s:report_ok(msg) abort
call health#report_ok(a:msg)
endfunction
endif

function! s:check_job() abort
if !has('nvim') && !has('job')
call health#report_error('Not supported since +job feature is not enabled')
call s:report_error('Not supported since +job feature is not enabled')
else
call v:lua.vim.health.ok('+job is available to execute Git command')
call s:report_ok('+job is available to execute Git command')
endif
endfunction

Expand All @@ -12,7 +38,7 @@ function! s:check_floating_window() abort
endif

if !exists('*nvim_win_set_config')
call v:lua.vim.health.warn(
call s:report_warn(
\ 'Neovim 0.3.0 or earlier does not support floating window feature. Preview window is used instead',
\ 'Please install Neovim 0.4.0 or later')
return
Expand All @@ -29,7 +55,7 @@ function! s:check_floating_window() abort
\ })
noautocmd call nvim_win_close(win_id, v:true)
catch /^Vim\%((\a\+)\)\=:E118/
call v:lua.vim.health.error(
call s:report_error(
\ 'Your Neovim is too old',
\ [
\ 'Please update Neovim to 0.4.0 or later',
Expand All @@ -38,23 +64,23 @@ function! s:check_floating_window() abort
return
endtry

call v:lua.vim.health.ok('Floating window is available for popup window')
call s:report_ok('Floating window is available for popup window')
endfunction

function! s:check_git_binary() abort
let cmd = get(g:, 'git_messenger_git_command', 'git')
if !executable(cmd)
call v:lua.vim.health.error('`' . cmd . '` command is not found. Please set proper command to g:git_messenger_git_command')
call s:report_error('`' . cmd . '` command is not found. Please set proper command to g:git_messenger_git_command')
return
endif

let output = substitute(system(cmd . ' -C . --version'), '\r\=\n', '', 'g')
if v:shell_error
call v:lua.vim.health.error('Git command `' . cmd . '` is broken (v1.8.5 or later is required): ' . output)
call s:report_error('Git command `' . cmd . '` is broken (v1.8.5 or later is required): ' . output)
return
endif

call v:lua.vim.health.ok('Git command `' . cmd . '` is available: ' . output)
call s:report_ok('Git command `' . cmd . '` is available: ' . output)
endfunction

function! s:check_vim_version() abort
Expand All @@ -63,13 +89,13 @@ function! s:check_vim_version() abort
endif

if v:version < 800
call health#report_error(
call s:report_error(
\ 'Your Vim version is too old: ' . v:version,
\ 'Please install Vim 8.0 or later')
return
endif

call health#report_error('Vim version is fine: ' . v:version)
call s:report_error('Vim version is fine: ' . v:version)
endfunction

function! health#gitmessenger#check() abort
Expand Down

0 comments on commit edc603d

Please sign in to comment.