From a36c6e5df959867ff4041405f4098b7833281517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=81uczy=C5=84ski?= Date: Sat, 9 Oct 2021 02:36:35 +0200 Subject: [PATCH] fix(checkhealth): duplicate checks if module name has "-" #15935 Problem: Some plugins have structure `lua/nvim-someplugin/..` Since `-` is not allowed in vim function names, healthcheck names in lua and in vim can not have the same name (typically vim will use `_` instead of `-`). Solution: Normalize the names before checking for duplicates. --- runtime/autoload/health.vim | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 579db62cb8..73c1459f86 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -181,21 +181,20 @@ function! s:get_healthcheck(plugin_names) abort let health_list = s:get_healthcheck_list(a:plugin_names) let healthchecks = {} for c in health_list - let name = c[0] - let existent = get(healthchecks, name, []) - " If an entry with the same name exists and is from vim, prefer Lua so - " overwrite it. - if existent != [] - if existent[1] == "v" - let healthchecks[name] = c[1:] - else - continue - endif + let normalized_name = substitute(c[0], '-', '_', 'g') + let existent = get(healthchecks, normalized_name, []) + " Prefer Lua over vim entries + if existent != [] && existent[2] == 'l' + continue else - let healthchecks[name] = c[1:] + let healthchecks[normalized_name] = c endif endfor - return healthchecks + let output = {} + for v in values(healthchecks) + let output[v[0]] = v[1:] + endfor + return output endfunction " Returns list of lists [ [{name}, {func}, {type}] ] representing healthchecks