@@ -120,40 +120,61 @@ end
120120--- `sign_getdefined` based wrapper with compatibility
121121--- @param severity string
122122--- @return vim.fn.sign_getdefined.ret.item
123- local function get_defined_sign (severity )
124- local defined
123+ local get_legacy_sign = function (severity )
124+ local sign = vim .fn .sign_getdefined (" DiagnosticSign" .. severity )
125+ if vim .tbl_isempty (sign ) then
126+ -- backwards compatibility...
127+ local old_severity = severity
128+ if severity == " Warning" then
129+ old_severity = " Warn"
130+ elseif severity == " Information" then
131+ old_severity = " Info"
132+ end
133+ sign = vim .fn .sign_getdefined (" LspDiagnosticsSign" .. old_severity )
134+ end
135+ return sign and sign [1 ]
136+ end
137+
138+ local nvim_0_10 = vim .fn .has (" nvim-0.10" ) > 0
139+ --- Returns the sign corresponding to the given severity
140+ --- @param severity string
141+ --- @return vim.fn.sign_getdefined.ret.item
142+ local function get_diagnostic_sign (severity )
143+ local sign
144+
145+ if nvim_0_10 then
146+ local signs = vim .diagnostic .config ().signs
147+
148+ if type (signs ) == " function" then
149+ -- TODO: Find a better way to get a namespace
150+ local namespaces = vim .diagnostic .get_namespaces ()
151+ if not vim .tbl_isempty (namespaces ) then
152+ local ns_id = next (namespaces )
153+ --- @cast ns_id - nil
154+ signs = signs (ns_id , 0 )
155+ end
156+ end
125157
126- if vim .fn .has (" nvim-0.10" ) > 0 then
127- local signs_config = vim .diagnostic .config ().signs
128- if type (signs_config ) == " table" then
158+ if type (signs ) == " table" then
129159 local identifier = severity :sub (1 , 1 )
130160 if identifier == " H" then
131161 identifier = " N"
132162 end
133- defined = {
134- text = (signs_config .text or {})[vim .diagnostic .severity [identifier ]],
163+ sign = {
164+ text = (signs .text or {})[vim .diagnostic .severity [identifier ]],
135165 texthl = " DiagnosticSign" .. severity ,
136166 }
167+ elseif signs == true then
168+ sign = get_legacy_sign (severity )
137169 end
138170 else -- before 0.10
139- defined = vim .fn .sign_getdefined (" DiagnosticSign" .. severity )
140- if vim .tbl_isempty (defined ) then
141- -- backwards compatibility...
142- local old_severity = severity
143- if severity == " Warning" then
144- old_severity = " Warn"
145- elseif severity == " Information" then
146- old_severity = " Info"
147- end
148- defined = vim .fn .sign_getdefined (" LspDiagnosticsSign" .. old_severity )
149- end
150- defined = defined and defined [1 ]
171+ sign = get_legacy_sign (severity )
151172 end
152173
153- if type (defined ) ~= " table" then
154- defined = {}
174+ if type (sign ) ~= " table" then
175+ sign = {}
155176 end
156- return defined
177+ return sign
157178end
158179
159180--- @class (exact ) neotree.Component.Common.Diagnostics : neotree.Component
@@ -178,23 +199,23 @@ M.diagnostics = function(config, node, state)
178199 end
179200 --- @type string
180201 local severity = diag_state .severity_string
181- local defined = get_defined_sign (severity )
202+ local sign = get_diagnostic_sign (severity )
182203
183204 -- check for overrides in the component config
184205 local severity_lower = severity :lower ()
185206 if config .symbols and config .symbols [severity_lower ] then
186- defined .texthl = defined .texthl or (" Diagnostic" .. severity )
187- defined .text = config .symbols [severity_lower ]
207+ sign .texthl = sign .texthl or (" Diagnostic" .. severity )
208+ sign .text = config .symbols [severity_lower ]
188209 end
189210 if config .highlights and config .highlights [severity_lower ] then
190- defined .text = defined .text or severity :sub (1 , 1 )
191- defined .texthl = config .highlights [severity_lower ]
211+ sign .text = sign .text or severity :sub (1 , 1 )
212+ sign .texthl = config .highlights [severity_lower ]
192213 end
193214
194- if defined .text and defined .texthl then
215+ if sign .text and sign .texthl then
195216 return {
196- text = make_two_char (defined .text ),
197- highlight = defined .texthl ,
217+ text = make_two_char (sign .text ),
218+ highlight = sign .texthl ,
198219 }
199220 else
200221 return {
0 commit comments