[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang

refactor(health): remove deprecations (#86)

authored by olexsmir.xyz and committed by GitHub c2f64db4 6016ca57

Changed files
+34 -48
lua
gopher
-33
lua/gopher/_utils/health_util.lua
··· 1 - local h = vim.health or require "health" 2 - local health = {} 3 - 4 - health.start = h.start or h.report_start 5 - health.ok = h.ok or h.report_ok 6 - health.warn = h.warn or h.report_warn 7 - health.error = h.error or h.report_error 8 - health.info = h.info or h.report_info 9 - 10 - ---@param module string 11 - ---@return boolean 12 - function health.is_lualib_found(module) 13 - local is_found, _ = pcall(require, module) 14 - return is_found 15 - end 16 - 17 - ---@param bin string 18 - ---@return boolean 19 - function health.is_binary_found(bin) 20 - if vim.fn.executable(bin) == 1 then 21 - return true 22 - end 23 - return false 24 - end 25 - 26 - ---@param ft string 27 - ---@return boolean 28 - function health.is_treesitter_parser_available(ft) 29 - local ok, parser = pcall(vim.treesitter.get_parser, 0, ft) 30 - return ok and parser ~= nil 31 - end 32 - 33 - return health
+34 -15
lua/gopher/health.lua
··· 1 1 local health = {} 2 2 local cmd = require("gopher.config").commands 3 - local u = require "gopher._utils.health_util" 4 3 5 4 local deps = { 6 5 plugin = { ··· 26 25 }, 27 26 } 28 27 28 + ---@param module string 29 + ---@return boolean 30 + local function is_lualib_found(module) 31 + local is_found, _ = pcall(require, module) 32 + return is_found 33 + end 34 + 35 + ---@param bin string 36 + ---@return boolean 37 + local function is_binary_found(bin) 38 + return vim.fn.executable(bin) == 1 39 + end 40 + 41 + ---@param ft string 42 + ---@return boolean 43 + local function is_treesitter_parser_available(ft) 44 + local ok, parser = pcall(vim.treesitter.get_parser, 0, ft) 45 + return ok and parser ~= nil 46 + end 47 + 29 48 function health.check() 30 - u.start "required plugins" 49 + vim.health.start "required plugins" 31 50 for _, plugin in ipairs(deps.plugin) do 32 - if u.is_lualib_found(plugin.lib) then 33 - u.ok(plugin.lib .. " installed") 51 + if is_lualib_found(plugin.lib) then 52 + vim.health.ok(plugin.lib .. " installed") 34 53 else 35 - u.error(plugin.lib .. " not found, " .. plugin.msg) 54 + vim.health.error(plugin.lib .. " not found, " .. plugin.msg) 36 55 end 37 56 end 38 57 39 - u.start "required binaries" 40 - u.info "all those binaries can be installed by `:GoInstallDeps`" 58 + vim.health.start "required binaries" 59 + vim.health.info "all those binaries can be installed by `:GoInstallDeps`" 41 60 for _, bin in ipairs(deps.bin) do 42 - if u.is_binary_found(bin.bin) then 43 - u.ok(bin.bin .. " installed") 61 + if is_binary_found(bin.bin) then 62 + vim.health.ok(bin.bin .. " installed") 44 63 else 45 64 if bin.optional then 46 - u.warn(bin.bin .. " not found, " .. bin.msg) 65 + vim.health.warn(bin.bin .. " not found, " .. bin.msg) 47 66 else 48 - u.error(bin.bin .. " not found, " .. bin.msg) 67 + vim.health.error(bin.bin .. " not found, " .. bin.msg) 49 68 end 50 69 end 51 70 end 52 71 53 - u.start "required treesitter parsers" 72 + vim.health.start "required treesitter parsers" 54 73 for _, parser in ipairs(deps.treesitter) do 55 - if u.is_treesitter_parser_available(parser.parser) then 56 - u.ok(parser.parser .. " parser installed") 74 + if is_treesitter_parser_available(parser.parser) then 75 + vim.health.ok(parser.parser .. " parser installed") 57 76 else 58 - u.error(parser.parser .. " parser not found, " .. parser.msg) 77 + vim.health.error(parser.parser .. " parser not found, " .. parser.msg) 59 78 end 60 79 end 61 80 end