Created
April 2, 2025 17:18
-
-
Save OneOfOne/318d24182182ccd6bc48d27b31998ebd to your computer and use it in GitHub Desktop.
Show diagnostics popup on CursorHold
This file contains hidden or 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 group = vim.api.nvim_create_augroup('OoO', {}) | |
local function au(typ, pattern, cmdOrFn) | |
if type(cmdOrFn) == 'function' then | |
vim.api.nvim_create_autocmd(typ, { pattern = pattern, callback = cmdOrFn, group = group }) | |
else | |
vim.api.nvim_create_autocmd(typ, { pattern = pattern, command = cmdOrFn, group = group }) | |
end | |
end | |
au({ 'CursorHold', 'InsertLeave' }, nil, function() | |
local opts = { | |
focusable = false, | |
scope = 'cursor', | |
close_events = { 'BufLeave', 'CursorMoved', 'InsertEnter' }, | |
} | |
vim.diagnostic.open_float(nil, opts) | |
end) | |
au('InsertEnter', nil, function() | |
vim.diagnostic.enable(false) | |
end) | |
au('InsertLeave', nil, function() | |
vim.diagnostic.enable(true) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment