trouble.nvim icon indicating copy to clipboard operation
trouble.nvim copied to clipboard

Set refresh rate?

Open jamesob opened this issue 2 years ago • 4 comments

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?

jamesob avatar Oct 10 '21 14:10 jamesob

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.

johnf avatar Oct 12 '21 21:10 johnf

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?

b0o avatar Nov 01 '21 02:11 b0o

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.

b0o avatar Nov 15 '21 02:11 b0o

For those looking for an answer, I found that this plugin works really nicely with Trouble. I use timeout = 0.

kevingriffin avatar Jul 20 '22 12:07 kevingriffin

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

folke avatar Mar 29 '24 07:03 folke