You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
I'm trying to show LSP diagnostics on cursor hold, but I also want to (trail) throttle it. This is what I'm doing:
functionThrottledOpenDiagnostic()
localfn, timer=require("throttle-debounce").throttle_trailing(OpenDiagnostic, 1000)
fn()
end-- Show diagnostics under the cursor when holding positionvim.api.nvim_create_augroup("lsp_diagnostics_hold", { clear=true })
vim.api.nvim_create_autocmd({ "CursorHold" }, {
pattern="*",
command="lua ThrottledOpenDiagnostic()",
group="lsp_diagnostics_hold",
})
This works, but I'm not calling timer:close anywhere. If I call it immediately after fn(), this will obviously won't work. Could you help me understand what's the right way to use it? Thanks!
The text was updated successfully, but these errors were encountered:
Honestly, I'd do it the same way, i.e. just call it right after the call to fn(). Your ticket made me think, however, that maybe I ought to close the timer right there in the throttle_trailing() function instead of exposing it to the user. Unfortunately it's been a while since I touched this code, so I won't be able to fix this right away I'm afraid.
Hi, thanks a lot for writing and sharing this.
I'm trying to show LSP diagnostics on cursor hold, but I also want to (trail) throttle it. This is what I'm doing:
This works, but I'm not calling
timer:close
anywhere. If I call it immediately afterfn()
, this will obviously won't work. Could you help me understand what's the right way to use it? Thanks!The text was updated successfully, but these errors were encountered: