-- TODO: Create an augroup for Trouble settings local lspsaga_augroup = vim.api.nvim_create_augroup("LspsagaSettings", { clear = true }) -- Create an autocommand for the Trouble filetype vim.api.nvim_create_autocmd("BufWinEnter", { pattern = "sagaoutline", group = lspsaga_augroup, callback = function() vim.wo.relativenumber = true end, }) -- Function to check if a floating dialog exists and if not -- then check for diagnostics under the cursor function OpenDiagnosticIfNoFloat() for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do if vim.api.nvim_win_get_config(winid).zindex then return end end vim.diagnostic.open_float({ scope = "cursor", focusable = false, close_events = { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave", }, }) end -- Show diagnostics under the cursor when holding position vim.api.nvim_create_augroup("lsp_diagnostics_hold", { clear = true }) vim.api.nvim_create_autocmd({ "CursorHold" }, { pattern = "*", command = "lua OpenDiagnosticIfNoFloat()", group = "lsp_diagnostics_hold", })