Created
October 20, 2022 03:16
-
-
Save sblask/97909fc0a6df643c7390276bbf497197 to your computer and use it in GitHub Desktop.
Run this in on_attach to show diagnostics in a floating window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local setup_show_diagnostics = function(buffer) | |
local opts = { | |
border = 'rounded', | |
close_events = { | |
'BufLeave', | |
'CursorMoved', | |
'DiagnosticChanged', | |
'FocusLost', | |
'InsertEnter', | |
}, | |
focussable = false, | |
} | |
local augroup_name = 'lsp-show-diagnostics' | |
vim.api.nvim_create_augroup(augroup_name, { clear = true }) | |
vim.api.nvim_create_autocmd('CursorHold', { | |
buffer = buffer, | |
callback = function() | |
vim.diagnostic.open_float(nil, opts) | |
end, | |
group = augroup_name, | |
}) | |
vim.api.nvim_create_autocmd('DiagnosticChanged', { | |
buffer = buffer, | |
callback = function(args) | |
vim.diagnostic.open_float(nil, opts) | |
end, | |
group = augroup_name, | |
}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fix for bad background:
Set delay for CursorHold: