diff options
author | 李晓辉 <lixiaohui0812@gmail.com> | 2022-12-31 02:23:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-30 10:23:54 -0800 |
commit | 4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf (patch) | |
tree | b34ceac3245918ac605eaeaf238ecc90aec6756e /runtime/lua/vim/diagnostic.lua | |
parent | 849f544d6285c6f49718a74bcaff964aeffe3db4 (diff) | |
download | rneovim-4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf.tar.gz rneovim-4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf.tar.bz2 rneovim-4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf.zip |
feat(diagnostic): don't open quickfix/loclist if no diagnostics #21397
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 84a8701ac7..b9aee7eaf3 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -478,13 +478,17 @@ local function set_list(loclist, opts) -- numbers beyond the end of the buffer local diagnostics = get_diagnostics(bufnr, opts, false) local items = M.toqflist(diagnostics) + if next(items) == nil then + vim.notify('No diagnostics available') + return + end if loclist then vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items }) else vim.fn.setqflist({}, ' ', { title = title, items = items }) end if open then - api.nvim_command(loclist and 'lopen' or 'botright copen') + api.nvim_command(loclist and 'lwindow' or 'botright cwindow') end end |