Skip to content

Commit c1d9edc

Browse files
Add health check on treesitter highlights being enabled
1 parent 9dde93a commit c1d9edc

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

lua/render-markdown/health.lua

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
---@param name string
2-
local function parser_installed(name)
3-
local ok = pcall(vim.treesitter.query.parse, name, '')
4-
if ok then
5-
vim.health.ok(name .. ' parser installed')
6-
else
7-
vim.health.error(name .. ' parser not found')
8-
end
9-
end
10-
111
local M = {}
122

133
function M.check()
14-
vim.health.start('Checking required treesitter parsers')
15-
parser_installed('markdown')
16-
parser_installed('markdown_inline')
4+
vim.health.start('Checking required treesitter parsers & settings')
5+
local ok, ts = pcall(require, 'nvim-treesitter.parsers')
6+
if not ok then
7+
vim.health.error('treesitter is not installed')
8+
return
9+
end
10+
vim.health.ok('treesitter is installed')
11+
12+
for _, name in ipairs({ 'markdown', 'markdown_inline' }) do
13+
if ts.has_parser(name) then
14+
vim.health.ok(name .. ' parser installed')
15+
else
16+
vim.health.error(name .. ' parser not installed')
17+
end
18+
end
19+
20+
local highlight = require('nvim-treesitter.configs').get_module('highlight')
21+
if highlight.enable then
22+
vim.health.ok('treesitter highlights enabled')
23+
else
24+
vim.health.error('treesitter highlights not enabled')
25+
end
1726
end
1827

1928
return M

0 commit comments

Comments
 (0)