diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-06-01 01:52:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 01:52:38 -0700 |
commit | 64bdaef327a587aaceff9cff1f204b9b93b7e3e8 (patch) | |
tree | d2bade9b9f0168c098a711a8979325e3213eb91d /runtime/lua/vim/lsp/util.lua | |
parent | 2faa1c361ba54b3c1f20771397f7b48ac4386cdc (diff) | |
parent | 0ece34cbb87ceabc14dec8aab8c92ad3c6e59142 (diff) | |
download | rneovim-64bdaef327a587aaceff9cff1f204b9b93b7e3e8.tar.gz rneovim-64bdaef327a587aaceff9cff1f204b9b93b7e3e8.tar.bz2 rneovim-64bdaef327a587aaceff9cff1f204b9b93b7e3e8.zip |
Merge pull request #14694 from folke/lsp_popup_border
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index e16b02fa6c..0fa6518c0b 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -44,10 +44,30 @@ local function get_border_size(opts) height = 2 width = 2 else - height = height + vim.fn.strdisplaywidth(border[2][1]) -- top - height = height + vim.fn.strdisplaywidth(border[6][1]) -- bottom - width = width + vim.fn.strdisplaywidth(border[4][1]) -- right - width = width + vim.fn.strdisplaywidth(border[8][1]) -- left + local function border_width(id) + if type(border[id]) == "table" then + -- border specified as a table of <character, highlight group> + return vim.fn.strdisplaywidth(border[id][1]) + elseif type(border[id]) == "string" then + -- border specified as a list of border characters + return vim.fn.strdisplaywidth(border[id]) + end + error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border)) + end + local function border_height(id) + if type(border[id]) == "table" then + -- border specified as a table of <character, highlight group> + return #border[id][1] > 0 and 1 or 0 + elseif type(border[id]) == "string" then + -- border specified as a list of border characters + return #border[id] > 0 and 1 or 0 + end + error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border)) + end + height = height + border_height(2) -- top + height = height + border_height(6) -- bottom + width = width + border_width(4) -- right + width = width + border_width(8) -- left end return { height = height, width = width } |