Skip to content

Commit

Permalink
healthcheck: treesitters
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Oct 9, 2024
1 parent 6b6f6a6 commit 0d09982
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions lua/go/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,45 @@ local function binary_check()
no_err = false
warn('curl is not installed, gocheat will not work.')
end
local required_parsers = {
'go',
}
local optional_parsers = {
'gowork',
'gomod',
'gosum',
'sql',
'gotmpl',
'json',
'comment',
}

local parser_path = vim.api.nvim_get_runtime_file('parser' .. sep .. 'go.so', false)[1]
if not parser_path then
warn('go treesitter parser not found, please Run `:TSInstallSync go`')
no_err = false
local checkparser = function(parsers, required)
local req = ' is required'
if not required then
req = ' is optional'
end
for _, parser in ipairs(parsers) do
local parser_path =
vim.api.nvim_get_runtime_file('parser' .. sep .. parser .. '.so', false)[1]
if not parser_path then
warn(
'treesitter parser '
.. parser
.. req
.. ' but it is not found, please Run `:TSInstallSync '
.. parser
.. '`'
.. ' to install or some features may not work'
)
no_err = false
else
info('treesitter parser ' .. parser .. ' found')
end
end
end
checkparser(required_parsers, true)
checkparser(optional_parsers, false)

if no_err then
ok('All binaries installed')
Expand Down

0 comments on commit 0d09982

Please sign in to comment.