mirror of
https://github.com/neovim/neovim.git
synced 2026-07-21 08:31:47 +00:00
fix(lsp): check filetype registry in health (#38885)
fix(health): misleading warnings re filetypes registered w/ vim.filetype.add() #38867
Problem:
`:checkhealth vim.lsp` validates configured filetypes against
`getcompletion('', 'filetype')`. This only reflects runtime support
files.
This causes false warnings in `:checkhealth vim.lsp` for configured
filetypes that are known to the Lua filetype registry, including
values added with `vim.filetype.add()` and built-in registry-only
filetypes.
Solution:
Build the healthcheck's known-filetype set from both
`getcompletion('', 'filetype')` and `vim.filetype.inspect()`.
(cherry picked from commit 20a3254ad4)
Co-authored-by: Barrett Ruth <62671086+barrettruth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c76bbd0a54
commit
df726644b8
@@ -212,10 +212,38 @@ local function check_position_encodings()
|
||||
end
|
||||
end
|
||||
|
||||
local function get_known_filetypes()
|
||||
local known = vim.fn.getcompletion('', 'filetype')
|
||||
local registry = vim.filetype.inspect()
|
||||
|
||||
local function add_filetype(value)
|
||||
local filetype = type(value) == 'table' and value[1] or value
|
||||
if type(filetype) == 'string' and not vim.list_contains(known, filetype) then
|
||||
known[#known + 1] = filetype
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairs(registry.extension) do
|
||||
add_filetype(value)
|
||||
end
|
||||
|
||||
for _, value in pairs(registry.filename) do
|
||||
add_filetype(value)
|
||||
end
|
||||
|
||||
for _, mappings in pairs(registry.pattern) do
|
||||
for _, value in pairs(mappings) do
|
||||
add_filetype(value)
|
||||
end
|
||||
end
|
||||
|
||||
return known
|
||||
end
|
||||
|
||||
local function check_enabled_configs()
|
||||
vim.health.start('vim.lsp: Enabled Configurations')
|
||||
|
||||
local valid_filetypes = vim.fn.getcompletion('', 'filetype')
|
||||
local known_filetypes = get_known_filetypes()
|
||||
|
||||
for name in vim.spairs(vim.lsp._enabled_configs) do
|
||||
local config = vim.lsp.config[name]
|
||||
@@ -248,7 +276,7 @@ local function check_enabled_configs()
|
||||
for _, filetype in
|
||||
ipairs(v --[[@as string[] ]])
|
||||
do
|
||||
if not vim.list_contains(valid_filetypes, filetype) then
|
||||
if not vim.list_contains(known_filetypes, filetype) then
|
||||
report_warn(
|
||||
("Unknown filetype '%s' (Hint: filename extension != filetype)."):format(filetype)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user