fix(lsp): use vim.notify for all message types #34489

Problem: Currently, vim.notify is only used to display messages when the
message type is Error.

Solution: Use vim.notify to display messages for all message types.
This commit is contained in:
someoneinjd
2025-06-16 20:02:59 +08:00
committed by GitHub
parent 6ad2a13054
commit 1d7823451e
2 changed files with 19 additions and 6 deletions

View File

@@ -25,6 +25,8 @@ local log = {}
local log_levels = vim.log.levels
local protocol = require('vim.lsp.protocol')
--- Log level dictionary with reverse lookup as well.
---
--- Can be used to lookup the number from the name or the name from the number.
@@ -218,4 +220,19 @@ function log.should_log(level)
return level >= current_log_level
end
--- Convert LSP MessageType to vim.log.levels
---
---@param message_type lsp.MessageType
function log._from_lsp_level(message_type)
if message_type == protocol.MessageType.Error then
return vim.log.levels.ERROR
elseif message_type == protocol.MessageType.Warning then
return vim.log.levels.WARN
elseif message_type == protocol.MessageType.Info or message_type == protocol.MessageType.Log then
return vim.log.levels.INFO
else
return vim.log.levels.DEBUG
end
end
return log