mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 23:05:41 +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
@@ -107,6 +107,39 @@ describe(':checkhealth', function()
|
||||
command('checkhealth vim.provider')
|
||||
eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
|
||||
end)
|
||||
|
||||
it('vim.lsp warns about unknown filetypes', function()
|
||||
clear()
|
||||
exec_lua(function()
|
||||
vim.filetype.add({ extension = { mdx = 'mdx' } })
|
||||
vim.lsp.config('builtin_registry_ft', {
|
||||
cmd = { 'true' },
|
||||
filetypes = { 'beancount' },
|
||||
})
|
||||
vim.lsp.config('custom_ft', {
|
||||
cmd = { 'true' },
|
||||
filetypes = { 'mdx' },
|
||||
})
|
||||
vim.lsp.config('bad_ft', {
|
||||
cmd = { 'true' },
|
||||
filetypes = { 'hbs' },
|
||||
})
|
||||
vim.lsp.enable('builtin_registry_ft')
|
||||
vim.lsp.enable('custom_ft')
|
||||
vim.lsp.enable('bad_ft')
|
||||
end)
|
||||
command('checkhealth vim.lsp')
|
||||
local report = curbuf_contents()
|
||||
eq(nil, report:find("Unknown filetype 'beancount'", 1, true))
|
||||
eq(nil, report:find("Unknown filetype 'mdx'", 1, true))
|
||||
eq(
|
||||
true,
|
||||
report:find("Unknown filetype 'hbs' (Hint: filename extension != filetype).", 1, true) ~= nil
|
||||
)
|
||||
eq(true, report:find('- builtin_registry_ft:', 1, true) ~= nil)
|
||||
eq(true, report:find('- custom_ft:', 1, true) ~= nil)
|
||||
eq(true, report:find('- bad_ft:', 1, true) ~= nil)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.health', function()
|
||||
|
||||
Reference in New Issue
Block a user