@@ -72,18 +72,19 @@ local debuginfo = function(opts)
72
72
return line
73
73
end
74
74
75
- local filetype_configured = function ()
76
- local effective_filetype = utils .get_effective_filetype ()
75
+ local get_filetype_config = function ()
76
+ local effective_filetypes = utils .get_effective_filetypes ()
77
77
78
- return vim . tbl_contains (
79
- vim . tbl_keys ( global_opts .filetypes ),
80
- effective_filetype
81
- )
82
- end
78
+ for _ , effective_filetype in ipairs ( effective_filetypes ) do
79
+ if global_opts .filetypes [ effective_filetype ] ~= nil then
80
+ return global_opts . filetypes [ effective_filetype ]
81
+ end
82
+ end
83
83
84
- local construct_debugprint_line = function ( opts , effective_filetype )
85
- local fileconfig = global_opts . filetypes [ effective_filetype ]
84
+ return nil
85
+ end
86
86
87
+ local construct_debugprint_line = function (opts , fileconfig )
87
88
local line_to_insert
88
89
89
90
if opts .variable_name then
@@ -120,16 +121,16 @@ local construct_error_line = function(errormsg)
120
121
end
121
122
122
123
local addline = function (opts )
123
- local effective_filetype = utils .get_effective_filetype ()
124
-
125
124
local line_to_insert
126
125
127
- if filetype_configured () then
128
- line_to_insert = construct_debugprint_line (opts , effective_filetype )
126
+ local fileconfig = get_filetype_config ()
127
+
128
+ if fileconfig ~= nil then
129
+ line_to_insert = construct_debugprint_line (opts , fileconfig )
129
130
else
130
131
line_to_insert = construct_error_line (
131
132
" No debugprint configuration for filetype "
132
- .. effective_filetype
133
+ .. utils . get_effective_filetypes ()[ 1 ]
133
134
.. " ; see https://github.com/andrewferrier/debugprint.nvim?tab=readme-ov-file#add-custom-filetypes"
134
135
)
135
136
end
@@ -163,7 +164,7 @@ local cache_request = nil
163
164
164
165
M .debugprint_cache = function (opts )
165
166
if opts and opts .prerepeat == true then
166
- if filetype_configured () and opts .variable == true then
167
+ if get_filetype_config () and opts .variable == true then
167
168
opts .variable_name = utils .get_variable_name (
168
169
global_opts .ignore_treesitter ,
169
170
opts .ignore_treesitter
0 commit comments