diff options
author | Abouzar Parvan <[email protected]> | 2022-04-22 15:11:21 +0430 |
---|---|---|
committer | GitHub <[email protected]> | 2022-04-22 15:11:21 +0430 |
commit | 8fdd4b46e8b91f62c11efd90153623e299748723 (patch) | |
tree | a357cf23bce54bc0136824bb17bfc9484abe1ff4 /lua/lvim/lsp | |
parent | f42008ddde7ce9a7a03081a64155558eae99d25a (diff) |
feat(peek): make sure max width and height are customizable (#2492)
Diffstat (limited to 'lua/lvim/lsp')
-rw-r--r-- | lua/lvim/lsp/config.lua | 5 | ||||
-rw-r--r-- | lua/lvim/lsp/peek.lua | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 182f8fbf..eada4ce7 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -78,6 +78,11 @@ return { style = "minimal", border = "rounded", }, + peek = { + max_height = 15, + max_width = 30, + context = 10, + }, on_attach_callback = nil, on_init_callback = nil, automatic_servers_installation = true, diff --git a/lua/lvim/lsp/peek.lua b/lua/lvim/lsp/peek.lua index eb774a77..65c67e92 100644 --- a/lua/lvim/lsp/peek.lua +++ b/lua/lvim/lsp/peek.lua @@ -29,7 +29,10 @@ local function create_floating_file(location, opts) local contents = vim.api.nvim_buf_get_lines( bufnr, range.start.line, - math.min(range["end"].line + 1 + (opts.context or 10), range.start.line + (opts.max_height or 15)), -- Don't let the window be more that 15 lines long(height) + math.min( + range["end"].line + 1 + (opts.context or lvim.lsp.peek.max_height), + range.start.line + (opts.max_height or lvim.lsp.peek.max_height) + ), false ) if next(contents) == nil then @@ -38,7 +41,11 @@ local function create_floating_file(location, opts) end local width, height = vim.lsp.util._make_floating_popup_size(contents, opts) local if_nil = vim.F.if_nil - opts = vim.lsp.util.make_floating_popup_options(if_nil(width, 30), if_nil(height, 10), opts) + opts = vim.lsp.util.make_floating_popup_options( + if_nil(width, lvim.lsp.peek.max_width), + if_nil(height, lvim.lsp.peek.max_height), + opts + ) -- Don't make it minimal as it is meant to be fully featured opts["style"] = nil @@ -65,7 +72,7 @@ local function preview_location_callback(result) local opts = { border = "rounded", - context = 10, + context = lvim.lsp.peek.context, } if vim.tbl_islist(result) then |