summaryrefslogtreecommitdiff
path: root/lua/lsp/handlers.lua
diff options
context:
space:
mode:
authorWill Leinweber <[email protected]>2021-08-02 21:51:32 -0700
committerGitHub <[email protected]>2021-08-03 00:51:32 -0400
commitfc018cdc4735e3ba3e456a153ab672c8eb4df043 (patch)
treec4b37d97332024bca1bf9631b3541e155ff26768 /lua/lsp/handlers.lua
parent77e283bd9c33166937756250918b12e349caf050 (diff)
Fix lsp reporting when v.source is nil (#1209)
Diffstat (limited to 'lua/lsp/handlers.lua')
-rw-r--r--lua/lsp/handlers.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua
index 849d2a03..2322e76a 100644
--- a/lua/lsp/handlers.lua
+++ b/lua/lsp/handlers.lua
@@ -28,10 +28,14 @@ function M.setup()
for i, v in ipairs(diagnostics) do
local source = v.source
- if string.find(v.source, "/") then
- source = string.sub(v.source, string.find(v.source, "([%w-_]+)$"))
+ if source then
+ if string.find(source, "/") then
+ source = string.sub(v.source, string.find(v.source, "([%w-_]+)$"))
+ end
+ diagnostics[i].message = string.format("%s: %s", source, v.message)
+ else
+ diagnostics[i].message = string.format("%s", v.message)
end
- diagnostics[i].message = string.format("%s: %s", source, v.message)
if vim.tbl_contains(vim.tbl_keys(v), "code") then
diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code)