chore: formatting

This commit is contained in:
amrbashir
2022-05-15 10:55:24 +02:00
parent 66cb6a423f
commit 2321d1f1f7

View File

@@ -1,7 +1,7 @@
local M = {} local M = {}
local config = { local config = {
position = "right", position = "right",
width = vim.api.nvim_get_option("columns") / 3 width = vim.api.nvim_get_option("columns") / 3,
} }
M.setup = function(conf) M.setup = function(conf)
@@ -43,33 +43,33 @@ M.toggle = function()
vim.api.nvim_set_current_win(prev_win) vim.api.nvim_set_current_win(prev_win)
autocmd = vim.api.nvim_create_autocmd( autocmd = vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
{ "CursorHold", "CursorHoldI" }, pattern = "*",
{ pattern = "*", callback = function() callback = function()
if win and vim.api.nvim_win_is_valid(win) then if win and vim.api.nvim_win_is_valid(win) then
local l, c = unpack(vim.api.nvim_win_get_cursor(0)) local l, c = unpack(vim.api.nvim_win_get_cursor(0))
vim.lsp.buf_request(0, "textDocument/hover", { vim.lsp.buf_request(0, "textDocument/hover", {
textDocument = { uri = "file://" .. vim.api.nvim_buf_get_name(0) }, textDocument = { uri = "file://" .. vim.api.nvim_buf_get_name(0) },
position = { line = l - 1, character = c } position = { line = l - 1, character = c },
}, function(err, result, ctx, config) }, function(err, result, ctx, config)
if win and vim.api.nvim_win_is_valid(win) and result and result.contents then if win and vim.api.nvim_win_is_valid(win) and result and result.contents then
local md_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents) local md_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents)
md_lines = vim.lsp.util.trim_empty_lines(md_lines) md_lines = vim.lsp.util.trim_empty_lines(md_lines)
if vim.tbl_isempty(md_lines) then return end if vim.tbl_isempty(md_lines) then
return
end
vim.api.nvim_buf_set_option(buf, "modifiable", true) vim.api.nvim_buf_set_option(buf, "modifiable", true)
vim.lsp.util.stylize_markdown(buf, md_lines) vim.lsp.util.stylize_markdown(buf, md_lines)
vim.api.nvim_buf_set_option(buf, "modifiable", false) vim.api.nvim_buf_set_option(buf, "modifiable", false)
end end
end end)
)
else else
vim.api.nvim_del_autocmd(autocmd) vim.api.nvim_del_autocmd(autocmd)
buf, win, prev_win, autocmd = nil buf, win, prev_win, autocmd = nil
end end
end end,
} })
)
end end
end end