trouble.nvim
trouble.nvim copied to clipboard
Set refresh rate?
By default it seems that trouble is continuously refreshing alerts and errors which can create an annoying editing experience. Is there some way to throttle a refresh of inline warnings to some interval, or (ideally) only upon mode-change or save?
Alternatively it would be great if there was an option to ignore errors when in insert mode. This is how LSP works by default. It would make auto_open work better.
it would be great if there was an option to ignore errors when in insert mode
I think this is the way. @folke would you accept a PR for this?
it would be great if there was an option to ignore errors when in insert mode
I accomplished this in my configuration with the following:
-- file: lua/user/trouble.lua
local M = {}
local state
function M.disableAutoOpenClose()
local troubleOpts = require('trouble.config').options
state = {
auto_open = troubleOpts.auto_open,
auto_close = troubleOpts.auto_close,
}
troubleOpts.auto_open = false
troubleOpts.auto_close = false
end
function M.restoreAutoOpenClose()
if state == nil then
return
end
local troubleOpts = require('trouble.config').options
troubleOpts.auto_open = state.auto_open
troubleOpts.auto_close = state.auto_close
state = nil
require('trouble').refresh { auto = true, provider = 'diagnostics' }
end
vim.cmd [[
augroup user_trouble
autocmd!
autocmd InsertEnter * lua require'user.trouble'.disableAutoOpenClose()
autocmd InsertLeave * lua require'user.trouble'.restoreAutoOpenClose()
augroup END
]]
return M
It doesn't inhibit diagnostics updates during insert mode but it does stop the Trouble window from opening/closing until insert mode is exited.
For those looking for an answer, I found that this plugin works really nicely with Trouble. I use timeout = 0
.
Development on the main branch is EOL.
Trouble has been rewritten and will be merged in main soon.
This issue/feature either no longer exists or has been implemented on dev.
For more info, see https://github.com/folke/trouble.nvim/tree/dev