Avoid jumping cursor when publishing diagnostics to quickfix or location list?

I am using vim.lsp.diagnostic.set_qflist() to populate the quickfix list when new diagnostics are published. However, I don’t want to jump the cursor to the list. How can I achieve this?

Ideally after calling it you use wincmd p or Ctrl-w p which takes you to the previous window. So something like:

:execute "lua vim.lsp.diagnostic.set_qflist()" | wincmd p

This is an ex command, or command line “command” :grinning_face_with_smiling_eyes:

2 Likes