fixed diagnostic float window

This commit is contained in:
Oliver Hartmann 2024-02-18 14:08:29 +01:00
parent 768807cbfe
commit 4582fd0c9a
2 changed files with 24 additions and 3 deletions

View File

@ -11,4 +11,5 @@ return {
}
vim.diagnostic.config(diagnostics)
end,
enabled = false
}

View File

@ -332,9 +332,29 @@ return {
capabilities = capabilities,
})
vim.diagnostic.config({ virtual_text = true })
-- vim.diagnostic.config({ virtual_text = false, virtual_lines = false })
-- vim.diagnostic.config({ virtual_text = false, virtual_lines = { only_current_line = true } })
vim.diagnostic.config({
virtual_text = false,
signs = true,
float = {
border = 'single',
format = function(diagnostic)
return string.format(
'%s (%s) [%s]',
diagnostic.message,
diagnostic.source,
diagnostic.code or diagnostic.user_data.lsp.code
)
end,
},
})
local diag_group = vim.api.nvim_create_augroup('lsp_diagnostic_float', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold' }, {
callback = function()
vim.diagnostic.open_float({scope = 'line'}, { focus = false })
end,
group = diag_group,
desc = 'Document Highlight',
})
end,
event = 'VeryLazy'
}