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.
This commit is contained in:
Jakub Łuczyński 2021-10-09 02:36:35 +02:00 committed by GitHub
parent f620008e59
commit a36c6e5df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,21 +181,20 @@ function! s:get_healthcheck(plugin_names) abort
let health_list = s:get_healthcheck_list(a:plugin_names) let health_list = s:get_healthcheck_list(a:plugin_names)
let healthchecks = {} let healthchecks = {}
for c in health_list for c in health_list
let name = c[0] let normalized_name = substitute(c[0], '-', '_', 'g')
let existent = get(healthchecks, name, []) let existent = get(healthchecks, normalized_name, [])
" If an entry with the same name exists and is from vim, prefer Lua so " Prefer Lua over vim entries
" overwrite it. if existent != [] && existent[2] == 'l'
if existent != [] continue
if existent[1] == "v"
let healthchecks[name] = c[1:]
else
continue
endif
else else
let healthchecks[name] = c[1:] let healthchecks[normalized_name] = c
endif endif
endfor endfor
return healthchecks let output = {}
for v in values(healthchecks)
let output[v[0]] = v[1:]
endfor
return output
endfunction endfunction
" Returns list of lists [ [{name}, {func}, {type}] ] representing healthchecks " Returns list of lists [ [{name}, {func}, {type}] ] representing healthchecks