Skip to content

Commit

Permalink
feat(lsp): added config.lsp.hover.silent. Fixes #412
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 16, 2023
1 parent d767be9 commit e2a53cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Check the [wiki](https://github.com/folke/noice.nvim/wiki/Configuration-Recipes)
},
hover = {
enabled = true,
silent = false, -- set to true to not show a message if hover is not available
view = nil, -- when nil, use defaults from documentation
---@type NoiceViewOptions
opts = {}, -- merged with defaults from documentation
Expand Down
1 change: 1 addition & 0 deletions lua/noice/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function M.defaults()
},
hover = {
enabled = true,
silent = false, -- set to true to not show a message if hover is not available
view = nil, -- when nil, use defaults from documentation
---@type NoiceViewOptions
opts = {}, -- merged with defaults from documentation
Expand Down
9 changes: 7 additions & 2 deletions lua/noice/lsp/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local require = require("noice.util.lazy")
local Format = require("noice.lsp.format")
local Util = require("noice.util")
local Docs = require("noice.lsp.docs")
local Config = require("noice.config")

local M = {}

Expand All @@ -12,7 +13,9 @@ end

function M.on_hover(_, result, ctx)
if not (result and result.contents) then
vim.notify("No information available")
if Config.options.lsp.hover.silent ~= true then
vim.notify("No information available")
end
return
end

Expand All @@ -21,7 +24,9 @@ function M.on_hover(_, result, ctx)
if not message:focus() then
Format.format(message, result.contents, { ft = vim.bo[ctx.bufnr].filetype })
if message:is_empty() then
vim.notify("No information available")
if Config.options.lsp.hover.silent ~= true then
vim.notify("No information available")
end
return
end
Docs.show(message)
Expand Down

0 comments on commit e2a53cf

Please sign in to comment.