From 2837d62ac4203f7b095d79578e86695007a0f38a Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Sun, 29 Dec 2024 08:11:02 +0000 Subject: [PATCH] feat(health): add checkhealth section for tree-sitter-http --- lua/rest-nvim/health.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lua/rest-nvim/health.lua b/lua/rest-nvim/health.lua index 317d799..4dc9a87 100644 --- a/lua/rest-nvim/health.lua +++ b/lua/rest-nvim/health.lua @@ -73,9 +73,34 @@ local function formatter_health() vim.health.info("You can set formatter for each filetype via 'formatexpr' or 'formatprg' option") end +-- TODO: check if http parser exist (it may not exist in rtp but registered manually) +local function parser_health() + vim.health.start("tree-sitter parsers") + local parser = vim.api.nvim_get_runtime_file('parser/http.so', true)[1] + local parsername = vim.fn.fnamemodify(parser, ':t:r') + local is_loadable, err_or_nil = pcall(vim.treesitter.language.add, parsername) + + if not is_loadable then + vim.health.error( + string.format( + 'Parser "%s" failed to load (path: %s): %s', + parsername, + parser, + err_or_nil or '?' + ) + ) + else + local lang = vim.treesitter.language.inspect(parsername) + vim.health.ok( + string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser) + ) + end +end + function health.check() install_health() formatter_health() + parser_health() end return health