@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55local M = {}
66
77--- @private
8- M .version = ' 8.0.14 '
8+ M .version = ' 8.0.15 '
99
1010function M .check ()
1111 M .start (' version' )
@@ -21,15 +21,15 @@ function M.check()
2121 vim .health .error (message )
2222 end
2323
24- local latex = state .get (0 ).latex
25- local latex_advice = ' Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }'
24+ local config = state .get (0 )
25+ local latex , latex_advice = config .latex , M .disable_advice (' latex' )
26+ local html , html_advice = config .html , M .disable_advice (' html' )
2627
2728 M .start (' treesitter' )
28- M .check_parser (' markdown' )
29- M .check_parser (' markdown_inline' )
30- if latex .enabled then
31- M .check_parser (' latex' , latex_advice )
32- end
29+ M .check_parser (' markdown' , true )
30+ M .check_parser (' markdown_inline' , true )
31+ M .check_parser (' latex' , latex .enabled , latex_advice )
32+ M .check_parser (' html' , html .enabled , html_advice )
3333 M .check_highlight (' markdown' )
3434
3535 M .start (' icons' )
@@ -41,14 +41,11 @@ function M.check()
4141 end
4242
4343 M .start (' executables' )
44- if latex .enabled then
45- M .check_executable (latex .converter , latex_advice )
46- else
47- vim .health .ok (' none to check' )
48- end
44+ M .check_executable (latex .converter , latex .enabled , latex_advice )
4945
5046 M .start (' conflicts' )
5147 M .check_plugin (' headlines' )
48+ M .check_plugin (' markview' )
5249 M .check_plugin (' obsidian' , function (obsidian )
5350 if obsidian .get_client ().opts .ui .enable == false then
5451 return nil
7976
8077--- @private
8178--- @param language string
82- --- @param advice ? string
83- function M .check_parser (language , advice )
79+ --- @return string[]
80+ function M .disable_advice (language )
81+ return {
82+ string.format (' Disable %s support to avoid this warning' , language ),
83+ string.format (' Set { %s = { enabled = false } }' , language ),
84+ }
85+ end
86+
87+ --- @private
88+ --- @param language string
89+ --- @param required boolean
90+ --- @param advice ? string[]
91+ function M .check_parser (language , required , advice )
8492 local has_parser = pcall (vim .treesitter .get_parser , 0 , language )
8593 if has_parser then
8694 vim .health .ok (language .. ' : parser installed' )
87- elseif advice == nil then
88- vim .health .error (language .. ' : parser not installed' )
8995 else
90- vim .health .warn (language .. ' : parser not installed' , advice )
96+ local message = language .. ' : parser not installed'
97+ if not required then
98+ vim .health .ok (message )
99+ elseif advice ~= nil then
100+ vim .health .warn (message , advice )
101+ else
102+ vim .health .error (message )
103+ end
91104 end
92105end
93106
@@ -109,14 +122,20 @@ end
109122
110123--- @private
111124--- @param name string
112- --- @param advice ? string
113- function M .check_executable (name , advice )
125+ --- @param required boolean
126+ --- @param advice ? string[]
127+ function M .check_executable (name , required , advice )
114128 if vim .fn .executable (name ) == 1 then
115129 vim .health .ok (name .. ' : installed' )
116- elseif advice == nil then
117- vim .health .error (name .. ' : not installed' )
118130 else
119- vim .health .warn (name .. ' : not installed' , advice )
131+ local message = name .. ' : not installed'
132+ if not required then
133+ vim .health .ok (message )
134+ elseif advice ~= nil then
135+ vim .health .warn (message , advice )
136+ else
137+ vim .health .error (message )
138+ end
120139 end
121140end
122141
0 commit comments