@@ -21,24 +21,19 @@ function M.check()
21
21
vim .health .error (message )
22
22
end
23
23
24
+ M .start (' treesitter' )
25
+ M .check_parser (' markdown' )
26
+ M .check_parser (' markdown_inline' )
27
+
24
28
local latex = state .get (0 ).latex
25
29
local latex_advice = ' Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }'
26
30
27
- M .start (' nvim-treesitter' )
28
- local has_treesitter = pcall (require , ' nvim-treesitter' )
29
- if has_treesitter then
30
- vim .health .ok (' installed' )
31
- for _ , language in ipairs ({ ' markdown' , ' markdown_inline' }) do
32
- M .check_parser (language )
33
- M .check_highlight (language )
34
- end
35
- if latex .enabled then
36
- M .check_parser (' latex' , latex_advice )
37
- end
38
- else
39
- vim .health .error (' not installed' )
31
+ if latex .enabled then
32
+ M .check_parser (' latex' , latex_advice )
40
33
end
41
34
35
+ M .check_highlight (' markdown' )
36
+
42
37
M .start (' icons' )
43
38
local provider = Icons .provider ()
44
39
if provider ~= nil then
88
83
--- @param language string
89
84
--- @param advice ? string
90
85
function M .check_parser (language , advice )
91
- local parsers = require (' nvim-treesitter.parsers' )
92
- if parsers .has_parser (language ) then
86
+ local has_parser , _ = pcall (vim .treesitter .get_parser , 0 , language , { error = false })
87
+
88
+ if has_parser then
93
89
vim .health .ok (language .. ' : parser installed' )
94
90
elseif advice == nil then
95
91
vim .health .error (language .. ' : parser not installed' )
101
97
--- @private
102
98
--- @param language string
103
99
function M .check_highlight (language )
104
- local configs = require (' nvim-treesitter.configs' )
105
- if configs .is_enabled (' highlight' , language , 0 ) then
100
+ --
101
+ -- As the markdown parser is part of Neovim, and nvim-treesitter no longer provides
102
+ -- .is_enabled() for the main branch, create a markdown buffer and check the state.
103
+ --
104
+ -- See: https://github.com/MeanderingProgrammer/render-markdown.nvim/pull/322#discussion_r1947393569
105
+ local bufnr = vim .api .nvim_create_buf (false , true )
106
+
107
+ vim .bo [bufnr ].filetype = language
108
+
109
+ local has_highlighter = vim .treesitter .highlighter .active [bufnr ] ~= nil
110
+
111
+ vim .api .nvim_buf_delete (bufnr , { force = true })
112
+
113
+ if has_highlighter then
106
114
vim .health .ok (language .. ' : highlight enabled' )
107
115
else
108
116
vim .health .error (language .. ' : highlight not enabled' )
0 commit comments