aboutsummaryrefslogtreecommitdiff
path: root/lua/config/lsp.lua
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2022-05-18 13:32:35 +0800
committerjdhao <jdhao@hotmail.com>2022-05-18 13:32:35 +0800
commit95b7ee5bc89171f4c72dd11a9f43965a84afa791 (patch)
treeb6556778eff22e2a3200423541919a26e90d3121 /lua/config/lsp.lua
parent4899a82b350dcaafc54623911788adc8afec7eec (diff)
lsp: only show diagnostic once for each line if cursor is not moved
This will help use to check signature help without it being overwritten by diagnostic popups.
Diffstat (limited to 'lua/config/lsp.lua')
-rw-r--r--lua/config/lsp.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index b5fab6a..6273231 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -31,7 +31,19 @@ local custom_attach = function(client, bufnr)
source = 'always', -- show source in diagnostic popup window
prefix = ' '
}
- vim.diagnostic.open_float(nil, opts)
+
+ if not vim.b.diagnostics_pos then
+ vim.b.diagnostics_pos = { nil, nil }
+ end
+
+ local cursor_pos = vim.api.nvim_win_get_cursor(0)
+ if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) and
+ #vim.diagnostic.get() > 0
+ then
+ vim.diagnostic.open_float(nil, opts)
+ end
+
+ vim.b.diagnostics_pos = cursor_pos
end
})