diff options
author | kylo252 <[email protected]> | 2022-03-24 15:48:33 +0100 |
---|---|---|
committer | kylo252 <[email protected]> | 2022-03-24 15:48:33 +0100 |
commit | f41edc6dfb0d2a4c9875da08bbbdab121e52048f (patch) | |
tree | c6541278c6314e58d991bc95e547e903ac58340a /lua/lvim/lsp/peek.lua | |
parent | 5ee460fdc751a91cdf7a4f4aab2ab784ebdb36fd (diff) | |
parent | 1ea836e3601b7ed0ed0496888dc14683bfbcce75 (diff) |
Merge remote-tracking branch 'origin/rolling'1.1.3
Diffstat (limited to 'lua/lvim/lsp/peek.lua')
-rw-r--r-- | lua/lvim/lsp/peek.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lua/lvim/lsp/peek.lua b/lua/lvim/lsp/peek.lua index f006f934..eb774a77 100644 --- a/lua/lvim/lsp/peek.lua +++ b/lua/lvim/lsp/peek.lua @@ -32,8 +32,13 @@ local function create_floating_file(location, opts) 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) false ) + if next(contents) == nil then + vim.notify("peek: Unable to get contents of the file!", vim.log.levels.WARN) + return + end local width, height = vim.lsp.util._make_floating_popup_size(contents, opts) - opts = vim.lsp.util.make_floating_popup_options(width, height, 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) -- Don't make it minimal as it is meant to be fully featured opts["style"] = nil @@ -81,7 +86,7 @@ function M.open_file() local filepath = vim.fn.expand "%:." if not filepath then - print "peek: Unable to open the file!" + vim.notify("peek: Unable to open the file!", vim.log.levels.ERROR) return end @@ -114,7 +119,7 @@ function M.Peek(what) if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then local success_1, _ = pcall(vim.api.nvim_set_current_win, M.floating_win) if not success_1 then - print "peek: You cannot edit the current file in a preview!" + vim.notify("peek: You cannot edit the current file in a preview!", vim.log.levels.ERROR) return end @@ -134,8 +139,9 @@ function M.Peek(what) local preview_callback = preview_location_callback_new_signature local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_callback) if not success then - print( - 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.' + vim.notify( + 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.', + vim.log.levels.ERROR ) end end |