feat: Print warning when no providers found

This commit is contained in:
hedy
2023-11-08 22:24:45 +08:00
parent 451eca2b37
commit 09b51fa5d5
2 changed files with 9 additions and 2 deletions

View File

@@ -439,7 +439,12 @@ function M.open_outline(opts)
opts = { focus_outline = true } opts = { focus_outline = true }
end end
if not M.view:is_open() then if not M.view:is_open() then
providers.request_symbols(handler, opts) local found = providers.request_symbols(handler, opts)
if not found then
vim.notify("[symbols-outline]: No providers found for current buffer", vim.log.levels.WARN)
-- else
-- print("Using provider ".._G._symbols_outline_current_provider.name.."...")
end
end end
end end

View File

@@ -21,6 +21,7 @@ function M.has_provider()
end end
---@param on_symbols function ---@param on_symbols function
---@return boolean found_provider
function M.request_symbols(on_symbols, opts) function M.request_symbols(on_symbols, opts)
for _, value in ipairs(providers) do for _, value in ipairs(providers) do
local provider = require(value) local provider = require(value)
@@ -28,9 +29,10 @@ function M.request_symbols(on_symbols, opts)
_G._symbols_outline_current_provider = provider _G._symbols_outline_current_provider = provider
_G._symbols_outline_current_provider.name = value _G._symbols_outline_current_provider.name = value
provider.request_symbols(on_symbols, opts) provider.request_symbols(on_symbols, opts)
break return true
end end
end end
return false
end end
return M return M