@@ -72,23 +72,34 @@ local internal_filetypes = {
7272 [" ." ] = false ,
7373}
7474
75+ --- @param filetype_enabled boolean | fun (): boolean
76+ local function resolve_filetype_enabled (filetype_enabled )
77+ if type (filetype_enabled ) == " function" then
78+ return filetype_enabled ()
79+ end
80+ return filetype_enabled
81+ end
82+
7583--- @param ft string
7684--- @param filetypes table<string , boolean>
7785--- @return boolean ft_disabled
7886--- @return string ? ft_disabled_reason
7987local function is_ft_disabled (ft , filetypes )
8088 if filetypes [ft ] ~= nil then
81- return not filetypes [ft ], string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , ft )
89+ return not resolve_filetype_enabled (filetypes [ft ]),
90+ string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , ft )
8291 end
8392
8493 local short_ft = string.gsub (ft , " %..*" , " " )
8594
8695 if filetypes [short_ft ] ~= nil then
87- return not filetypes [short_ft ], string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , short_ft )
96+ return not resolve_filetype_enabled (filetypes [short_ft ]),
97+ string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , short_ft )
8898 end
8999
90100 if filetypes [" *" ] ~= nil then
91- return not filetypes [" *" ], string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , " *" )
101+ return not resolve_filetype_enabled (filetypes [" *" ]),
102+ string.format (" 'filetype' %s rejected by config filetypes[%s]" , ft , " *" )
92103 end
93104
94105 if internal_filetypes [short_ft ] ~= nil then
0 commit comments