Skip to content

Commit

Permalink
fix(health): add lua health report with updated methods
Browse files Browse the repository at this point in the history
Fix #422
  • Loading branch information
asbjornhaland authored and voldikss committed Feb 6, 2024
1 parent 3f01a62 commit 97c085b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions lua/floaterm/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- vim:sw=2:
-- ============================================================================
-- FileName: floaterm.vim
-- Author: voldikss <dyzplus@gmail.com>
-- GitHub: https://github.com/voldikss
-- ============================================================================

local M = {}

local get_nvim_info = function()
return vim.fn.split(vim.fn.execute('version'), "\n")[1]
end

local get_plugin_info = function()
local home = vim.fn.fnamemodify(vim.fn.resolve(vim.fn.expand('<sfile>:p')), ':h:h:h')
local save_cwd = vim.fn.getcwd()
vim.fn.execute('cd ' .. home, 'silent!')
local result = vim.fn.system('git rev-parse --short HEAD')
vim.fn.execute('cd ' .. save_cwd, 'silent!')
return result
end

local check_common = function()
vim.health.start('common')
vim.health.info('Platform: ' .. vim.uv.os_uname().sysname)

This comment has been minimized.

Copy link
@jalevin

jalevin Feb 20, 2024

I'm getting an error specifically on this line.
:checkhealth


==============================================================================
floaterm: require("floaterm.health").check()

- ERROR Failed to run healthcheck for "floaterm" plugin. Exception:
  function health#check, line 25
  Vim(eval):E5108: Error executing lua ...s/jeff/.vim/plugged/vim-floaterm/lua/floaterm/health.lua:25: attempt to index field 'uv' (a nil value)
  stack traceback:
  ...s/jeff/.vim/plugged/vim-floaterm/lua/floaterm/health.lua:25: in function 'check_common'
  ...s/jeff/.vim/plugged/vim-floaterm/lua/floaterm/health.lua:55: in function 'check'
  [string "luaeval()"]:1: in main chunk

It doesn't appear that the vim table has a uv index.

version:

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377

What version of vim/neovim did this work on?

This comment has been minimized.

Copy link
@voldikss

voldikss Feb 20, 2024

Owner

Hi @asbjornhaland , do you have some solutions to this problem? However I'm not familar with nvim lua interface 😞

This comment has been minimized.

Copy link
@asbjornhaland

asbjornhaland Feb 20, 2024

Author Contributor

Hi. I run NVIM v0.10.0. I see in the news help page (:help news):

==============================================================================
DEPRECATIONS                                                *news-deprecations*

....

β€’ Checkhealth functions:
  - |health#report_error|, |vim.health.report_error()|	Use |vim.health.error()| instead.
  - |health#report_info|, |vim.health.report_info()|	Use |vim.health.info()| instead.
  - |health#report_ok|, |vim.health.report_ok()|	Use |vim.health.ok()| instead.
  - |health#report_start|, |vim.health.report_start()|	Use |vim.health.start()| instead.
  - |health#report_warn|, |vim.health.report_warn()|	Use |vim.health.warn()| instead.

....

β€’ `vim.loop` has been renamed to |vim.uv|.

This comment has been minimized.

Copy link
@voldikss

voldikss Feb 29, 2024

Owner

#429 has fixed this issue ❀️

vim.health.info('Nvim: ' .. get_nvim_info())
vim.health.info('Plugin: ' .. get_plugin_info())
end

local check_terminal = function()
vim.health.start('terminal')
if vim.fn.exists(':terminal') then
vim.health.ok('Terminal emulator is available')
else
vim.health.error(
'Terminal emulator is missing',
{'Install the latest version of neovim'}
)
end
end

local check_floating = function()
vim.health.start('floating')
if vim.fn.exists('*nvim_win_set_config') then
vim.health.ok('Floating window is available')
else
vim.health.warn(
'Floating window is missing, will fallback to use normal window',
{'Install the latest version neovim'}
)
end
end

M.check = function()
check_common()
check_terminal()
check_floating()
end

return M

0 comments on commit 97c085b

Please sign in to comment.