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

Fix for neovim 0.10 #248

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from 1 commit
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
74 changes: 53 additions & 21 deletions autoload/health/denops.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,105 +21,137 @@ function! s:get_deno_version(deno) abort
endfunction

function! s:check_deno_executable() abort
call health#report_info(printf(
call s:report_info(printf(
\ 'Deno executable: `%s` (g:denops#deno)',
\ g:denops#deno,
\))
if !executable(g:denops#deno)
call health#report_error(printf(
call s:report_error(printf(
\ 'It seems `%s` is not executable. Please install deno and add to `$PATH`.',
\ g:denops#deno,
\))

if g:denops#deno !=# 'deno' && executable('deno')
call health#report_info(printf(
call s:report_info(printf(
\ 'It seems `deno` is executable but `%s` is specified to g:denops#deno by user.',
\ g:denops#deno,
\))
endif
return
endif
call health#report_ok('Deno executable check: passed')
call s:report_ok('Deno executable check: passed')
endfunction

function! s:check_deno_version() abort
let l:deno_version = s:get_deno_version(g:denops#deno)
call health#report_info(printf(
call s:report_info(printf(
\ 'Supported Deno version: `%s`',
\ s:deno_version,
\))
call health#report_info(printf(
call s:report_info(printf(
\ 'Detected Deno version: `%s`',
\ l:deno_version,
\))
if empty(l:deno_version)
call health#report_error('Unable to detect version of deno, make sure your deno runtime is correct.')
call s:report_error('Unable to detect version of deno, make sure your deno runtime is correct.')
return
elseif s:compare_version(l:deno_version, s:deno_version) < 0
call health#report_error(printf(
call s:report_error(printf(
\ 'Unsupported Deno version is detected. You need to upgrade it to `%s` or later.',
\ s:deno_version,
\))
return
endif
call health#report_ok('Deno version check: passed')
call s:report_ok('Deno version check: passed')
endfunction

function! s:check_vim_version() abort
call health#report_info(printf(
call s:report_info(printf(
\ 'Supported Vim version: `%s`',
\ s:vim_version,
\))
call health#report_info(printf(
call s:report_info(printf(
\ 'Detected Vim version: `%s`',
\ denops#_internal#meta#get().version,
\))
if !has(printf('patch-%s', s:vim_version))
call health#report_error(printf(
call s:report_error(printf(
\ 'Unsupported Vim version is detected. You need to upgrade it to `%s` or later.',
\ s:vim_version,
\))
return
endif
call health#report_ok('Vim version check: passed')
call s:report_ok('Vim version check: passed')
endfunction

function! s:check_neovim_version() abort
call health#report_info(printf(
call s:report_info(printf(
\ 'Supported Neovim version: `%s`',
\ s:neovim_version,
\))
call health#report_info(printf(
call s:report_info(printf(
\ 'Detected Neovim version: `%s`',
\ denops#_internal#meta#get().version,
\))
if !has(printf('nvim-%s', s:neovim_version))
call health#report_error(printf(
call s:report_error(printf(
\ 'Unsupported Neovim version is detected. You need to upgrade it to `%s` or later.',
\ s:neovim_version,
\))
return
endif
call health#report_ok('Neovim version check: passed')
call s:report_ok('Neovim version check: passed')
endfunction

function! s:check_denops() abort
if get(g:, 'denops#debug', 0)
call health#report_warn('Denops is running with debug mode (g:denops#debug)')
call s:report_warn('Denops is running with debug mode (g:denops#debug)')
endif
endfunction

function! s:check_denops_status() abort
let l:server_status = denops#server#status()
call health#report_info(printf(
call s:report_info(printf(
\ 'Denops status: `%s`',
\ l:server_status,
\))
if l:server_status ==# 'stopped'
call health#report_error('Denops is stopped. Execute `:message` command to find reasons.')
call s:report_error('Denops is stopped. Execute `:message` command to find reasons.')
return
endif
call health#report_ok('Denops status check: passed')
call s:report_ok('Denops status check: passed')
endfunction

function! s:report_ok(report) abort
if has('nvim-0.10')
call v:lua.vim.health.ok(a:report)
else
call health#report_ok(a:report)
endif
endfunction

function! s:report_info(report) abort
if has('nvim-0.10')
call v:lua.vim.health.info(a:report)
else
call health#report_info(a:report)
endif
endfunction

function! s:report_warn(report) abort
if has('nvim-0.10')
call v:lua.vim.health.warn(a:report)
else
call health#report_warn(a:report)
endif
endfunction

function! s:report_error(report) abort
if has('nvim-0.10')
call v:lua.vim.health.error(a:report)
else
call health#report_error(a:report)
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite it like

if has('nvim-0.10')
  function! s:report_ok(report) abort
    call v:lua.vim.health.ok(a:report)
  endfunction

  " ...etc
else
  function s:report_ok(report) abort
    call healtp#report_ok(a:report)
  endfunction

  " ...etc
endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

endfunction

function! health#denops#check() abort
Expand Down
Loading