Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ require('hover').config({
-- Whether the contents of a currently open hover window should be moved
-- to a :h preview-window when pressing the hover keymap.
preview_window = false,

-- Whether to show the hover window when a provider has no result.
show_no_result = false,

title = true,
mouse_providers = {
'hover.providers.lsp',
Expand Down
8 changes: 7 additions & 1 deletion lua/hover/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ local function run_provider(provider, providers, bufnr, popts)
local result = async.await(2, provider.execute, {
bufnr = bufnr,
pos = popts.pos or api.nvim_win_get_cursor(0),
}) or { lines = { 'No result' } }
})

if not config.show_no_result and not result then
return false
end

result = result or { lines = { 'No result' } }

async.scheduler()
show_hover(provider.id, providers, config, result, opts)
Expand Down
4 changes: 4 additions & 0 deletions lua/hover/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local default_config = {
border = 'single',
},
preview_window = false,
show_no_result = false,
title = true,
mouse_delay = 1000,
--- @type (string|Hover.Config.Provider)[]
Expand All @@ -32,6 +33,9 @@ local default_config = {
--- to a :h preview-window when pressing the hover keymap.
--- @field preview_window? boolean
---
--- Whether to show the hover window when a provider has no result.
--- @field show_no_result? boolean
---
--- @field title? boolean
---
--- List of modules names to load as providers.
Expand Down