[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang
at main 1.8 kB view raw
1local c = require("gopher.config").commands 2local health = {} 3 4local deps = { 5 vim_version = "nvim-0.10", 6 bin = { 7 { 8 bin = c.go, 9 msg = "required for `:GoGet`, `:GoMod`, `:GoGenerate`, `:GoWork`, `:GoInstallDeps`, `:GoInstallDepsSync`", 10 }, 11 { bin = c.gomodifytags, msg = "required for `:GoTagAdd`, `:GoTagRm`" }, 12 { bin = c.impl, msg = "required for `:GoImpl`" }, 13 { bin = c.iferr, msg = "required for `:GoIfErr`" }, 14 { bin = c.gotests, msg = "required for `:GoTestAdd`, `:GoTestsAll`, `:GoTestsExp`" }, 15 }, 16 treesitter = { 17 { parser = "go", msg = "required for most of the parts of `gopher.nvim`" }, 18 }, 19} 20 21---@param bin {bin:string, msg:string, optional:boolean} 22local function check_binary(bin) 23 if vim.fn.executable(bin.bin) == 1 then 24 vim.health.ok(bin.bin .. " is found oh PATH: `" .. vim.fn.exepath(bin.bin) .. "`") 25 else 26 vim.health.error(bin.bin .. " not found on PATH, " .. bin.msg) 27 end 28end 29 30---@param ts {parser:string, msg:string} 31local function check_treesitter(ts) 32 local ok, parser = pcall(vim.treesitter.get_parser, 0, ts.parser) 33 if ok and parser ~= nil then 34 vim.health.ok("`" .. ts.parser .. "` parser is installed") 35 else 36 vim.health.error("`" .. ts.parser .. "` parser not found") 37 end 38end 39 40function health.check() 41 vim.health.start "Neovim version" 42 if vim.fn.has(deps.vim_version) == 1 then 43 vim.health.ok "Neovim version is compatible" 44 else 45 vim.health.error(deps.vim_version .. " or newer is required") 46 end 47 48 vim.health.start "Required binaries (those can be installed with `:GoInstallDeps`)" 49 for _, bin in ipairs(deps.bin) do 50 check_binary(bin) 51 end 52 53 vim.health.start "Treesitter" 54 for _, parser in ipairs(deps.treesitter) do 55 check_treesitter(parser) 56 end 57end 58 59return health