Trans.nvim/lua/Trans/health.lua

80 lines
1.9 KiB
Lua
Raw Normal View History

2023-03-07 21:52:29 +08:00
local M = {}
M.check = function()
local health = vim.health
local ok = health.report_ok
local warn = health.report_warn
local error = health.report_error
local has = vim.fn.has
local executable = vim.fn.executable
-- INFO :Check neovim version
if has('nvim-0.9') == 1 then
ok [[
2023-03-09 19:42:41 +08:00
you have Trans.nvim with full features in neovim-nightly
2023-03-07 21:52:29 +08:00
]]
else
warn [[
2023-03-09 19:42:41 +08:00
Trans Title requires Neovim 0.9 or newer
2023-03-07 21:52:29 +08:00
See neovim-nightly: https://github.com/neovim/neovim/releases/tag/nightly
]]
end
-- INFO :Check Sqlite
local has_sqlite = pcall(require, 'sqlite')
if has_sqlite then
ok [[
2023-03-09 19:42:41 +08:00
Dependency sqlite.lua is installed
2023-03-07 21:52:29 +08:00
]]
else
error [[
2023-03-09 19:42:41 +08:00
Dependency sqlite.lua can't work correctly
2023-03-07 21:52:29 +08:00
Please Read the doc in github carefully
]]
end
if executable('sqlite3') then
ok [[
2023-03-09 19:42:41 +08:00
Dependency sqlite3 found
2023-03-07 21:52:29 +08:00
]]
else
error [[
2023-03-09 19:42:41 +08:00
Dependency sqlite3 not found
2023-03-07 21:52:29 +08:00
]]
end
-- INFO :Check stardict
local db_path = vim.fn.expand(require('Trans').conf.db_path)
if vim.fn.filereadable(db_path) == 1 then
ok [[
2023-03-09 19:42:41 +08:00
Stardict database found
2023-03-07 21:52:29 +08:00
]]
else
error [[
2023-03-09 19:42:41 +08:00
Stardict database not found
Please check the doc in github: https://github.com/JuanZoran/Trans.nvim
]]
end
-- INFO :Check Engine configuration file
local path = vim.fn.expand("$HOME/.vim/dict/Trans.json")
local file = io.open(path, "r")
local valid = vim.json.decode(file:read("*a"))
if valid then
ok [[
Engine configuration file found and valid
]]
else
error [[
Engine configuration file not found or invalid
Please check the doc in github: https://github.com/JuanZoran/Trans.nvim
2023-03-07 21:52:29 +08:00
]]
end
end
return M