refactor of public plugin's api (#37)

* refactor: move all plugin functionality to init.lua

* fix(commands): now it uses correct module paths

* refactor(config): change way how it handles options

* refactor(gotests): use correct config, change way how deps required, fix some typos

* fix(healthchecker): use correct config

* refactor(iferr): change api

* refactor(impl): change api

* refactor(installer): change api

* refactor(struct_tags): change way of importting deps

* refactor(struct_tags): rename M to struct_tags

* run stylua

* refactor(dap): make it all in one file, and make some refactoring

* refactor(_utils): change way how it organizes

* fix: use new _utils api

* refactor(_utils.health): reorganize module

* refactor(_utils.ts): some renameing, moving requires lines

* run stylua
This commit is contained in:
Smirnov Oleksandr 2023-07-19 23:38:23 +03:00 committed by GitHub
parent 94250bb08a
commit 26b41bf68c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 359 additions and 341 deletions

View file

@ -1,16 +1,7 @@
local health = {}
local cmd = require("gopher.config").config.commands
local cmd = require("gopher.config").commands
local u = require "gopher._utils.health"
local _h = vim.health or require "health"
local h = {
start = _h.start or _h.report_start,
ok = _h.ok or _h.report_ok,
warn = _h.warn or _h.report_warn,
error = _h.error or _h.report_error,
info = _h.info or _h.report_info,
}
local deps = {
plugin = {
{ lib = "dap", msg = "required for `gopher.dap`", optional = true },
@ -36,29 +27,29 @@ local deps = {
}
function health.check()
h.start "required plugins"
u.start "required plugins"
for _, plugin in ipairs(deps.plugin) do
if u.lualib_is_found(plugin.lib) then
h.ok(plugin.lib .. " installed")
if u.is_lualib_found(plugin.lib) then
u.ok(plugin.lib .. " installed")
else
if plugin.optional then
h.warn(plugin.lib .. " not found, " .. plugin.msg)
u.warn(plugin.lib .. " not found, " .. plugin.msg)
else
h.error(plugin.lib .. " not found, " .. plugin.msg)
u.error(plugin.lib .. " not found, " .. plugin.msg)
end
end
end
h.start "required binaries"
h.info "all those binaries can be installed by `:GoInstallDeps`"
u.start "required binaries"
u.info "all those binaries can be installed by `:GoInstallDeps`"
for _, bin in ipairs(deps.bin) do
if u.binary_is_found(bin.bin) then
h.ok(bin.bin .. " installed")
if u.is_lualib_found(bin.bin) then
u.ok(bin.bin .. " installed")
else
if bin.optional then
h.warn(bin.bin .. " not found, " .. bin.msg)
u.warn(bin.bin .. " not found, " .. bin.msg)
else
h.error(bin.bin .. " not found, " .. bin.msg)
u.error(bin.bin .. " not found, " .. bin.msg)
end
end
end