diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-06-06 03:22:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-06 03:22:10 -0700 |
commit | 4ce61742cf820e15bb17c1d25474d2f35904fd12 (patch) | |
tree | e8624ae7f5e4604a510cac8d9ee938437974eb5a /runtime/lua/vim/lsp/util.lua | |
parent | 37d5236f88810eb399732951ca32206dcc1915a3 (diff) | |
parent | 149efa9b2bb8c1b810946647e9f91501c8d0e045 (diff) | |
download | rneovim-4ce61742cf820e15bb17c1d25474d2f35904fd12.tar.gz rneovim-4ce61742cf820e15bb17c1d25474d2f35904fd12.tar.bz2 rneovim-4ce61742cf820e15bb17c1d25474d2f35904fd12.zip |
Merge pull request #14726 from folke/lsp_single_popup_per_buffer
fix(lsp): max 1 floating preview per buffer. Fixes #11508
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index e2cae2bed9..d421a10011 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1375,6 +1375,13 @@ function M.open_floating_preview(contents, syntax, opts) end end + -- check if another floating preview already exists for this buffer + -- and close it if needed + local existing_float = npcall(api.nvim_buf_get_var, bufnr, "lsp_floating_preview") + if existing_float and api.nvim_win_is_valid(existing_float) then + api.nvim_win_close(existing_float, true) + end + local floating_bufnr = api.nvim_create_buf(false, true) local do_stylize = syntax == "markdown" and opts.stylize_markdown @@ -1420,6 +1427,7 @@ function M.open_floating_preview(contents, syntax, opts) if opts.focus_id then api.nvim_win_set_var(floating_winnr, opts.focus_id, bufnr) end + api.nvim_buf_set_var(bufnr, "lsp_floating_preview", floating_winnr) return floating_bufnr, floating_winnr end |