Skip to content

Commit

Permalink
Merge pull request #670 from ghostbuster91/handle-on_attach
Browse files Browse the repository at this point in the history
Log and show error if user_on_attach fails
  • Loading branch information
ckipp01 authored May 2, 2024
2 parents 72f4733 + fcb43c9 commit c626855
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/metals/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ local function validate_config(config, bufnr)
else
local user_on_attach = config.on_attach
config.on_attach = function(client, _bufnr)
user_on_attach(client, _bufnr)
local ok, res = pcall(user_on_attach, client, _bufnr)
if not ok then
log.error_and_show(string.format("Unexpected error when evaluating user's on_attach callback: '%s'", res))
end
auto_commands()
end
end
Expand Down

0 comments on commit c626855

Please sign in to comment.