summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/peek.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-08-15 13:54:15 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-08-15 13:54:15 +0200
commit977990584331307dd5e71ebbbbd6b45b9c961996 (patch)
treea8b3d78e80f586da192a576dd678e2fbc8ac8e00 /.config/nvim/lua/lsp/peek.lua
parent99d00f47fe780dbb021149db2f93d202a2b8b025 (diff)
Updates to nvim lsp
Diffstat (limited to '.config/nvim/lua/lsp/peek.lua')
-rw-r--r--.config/nvim/lua/lsp/peek.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/.config/nvim/lua/lsp/peek.lua b/.config/nvim/lua/lsp/peek.lua
index cc8e57a..e4f4e1e 100644
--- a/.config/nvim/lua/lsp/peek.lua
+++ b/.config/nvim/lua/lsp/peek.lua
@@ -12,7 +12,8 @@ local function create_floating_file(location, opts)
-- Set some defaults
opts = opts or {}
- local close_events = opts.close_events or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
+ local close_events = opts.close_events
+ or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
-- location may be LocationLink or Location
local uri = location.targetUri or location.uri
@@ -29,7 +30,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 10),
+ range.start.line + (opts.max_height or 15)
+ ), -- Don't let the window be more that 15 lines long(height)
false
)
local width, height = vim.lsp.util._make_floating_popup_size(contents, opts)
@@ -46,7 +50,9 @@ local function create_floating_file(location, opts)
-- Set some autocmds to close the window
vim.api.nvim_command(
- "autocmd QuitPre <buffer> ++nested ++once lua pcall(vim.api.nvim_win_close, " .. winnr .. ", true)"
+ "autocmd QuitPre <buffer> ++nested ++once lua pcall(vim.api.nvim_win_close, "
+ .. winnr
+ .. ", true)"
)
vim.lsp.util.close_preview_autocmd(close_events, winnr)
@@ -128,10 +134,18 @@ function M.Peek(what)
else
-- Make a new request and then create the new window in the callback
local params = vim.lsp.util.make_position_params()
- local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_location_callback)
+ local success, _ = pcall(
+ vim.lsp.buf_request,
+ 0,
+ "textDocument/" .. what,
+ params,
+ preview_location_callback
+ )
if not success then
print(
- 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.'
+ 'peek: Error calling LSP method "textDocument/'
+ .. what
+ .. '". The current language lsp might not support it.'
)
end
end