Skip to content

Instantly share code, notes, and snippets.

@sblask
Created October 20, 2022 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sblask/97909fc0a6df643c7390276bbf497197 to your computer and use it in GitHub Desktop.
Save sblask/97909fc0a6df643c7390276bbf497197 to your computer and use it in GitHub Desktop.
Run this in on_attach to show diagnostics in a floating window
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
@sblask
Copy link
Author

sblask commented Oct 20, 2022

Fix for bad background:

vim.api.nvim_set_hl(0, 'Pmenu', { ctermbg = 0 })

Set delay for CursorHold:

set updatetime=500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment