|
|
@ -1,5 +1,7 @@
|
|
|
|
local lsp = vim.lsp
|
|
|
|
local lsp = vim.lsp
|
|
|
|
local util = lsp.util
|
|
|
|
local util = lsp.util
|
|
|
|
|
|
|
|
local nutils = require('navigator.util')
|
|
|
|
|
|
|
|
local log = nutils.log
|
|
|
|
local M = {}
|
|
|
|
local M = {}
|
|
|
|
function M.handler(_, result, ctx, config)
|
|
|
|
function M.handler(_, result, ctx, config)
|
|
|
|
config = config or {}
|
|
|
|
config = config or {}
|
|
|
@ -12,7 +14,7 @@ function M.handler(_, result, ctx, config)
|
|
|
|
local ft = vim.bo.ft
|
|
|
|
local ft = vim.bo.ft
|
|
|
|
-- require('navigator.util').log(result)
|
|
|
|
-- require('navigator.util').log(result)
|
|
|
|
local markdown_lines = util.convert_input_to_markdown_lines(result.contents)
|
|
|
|
local markdown_lines = util.convert_input_to_markdown_lines(result.contents)
|
|
|
|
markdown_lines = util.trim_empty_lines(markdown_lines)
|
|
|
|
markdown_lines = nutils.trim_empty_lines(markdown_lines)
|
|
|
|
if vim.tbl_isempty(markdown_lines) then
|
|
|
|
if vim.tbl_isempty(markdown_lines) then
|
|
|
|
vim.notify('No information available')
|
|
|
|
vim.notify('No information available')
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -22,11 +24,15 @@ function M.handler(_, result, ctx, config)
|
|
|
|
opts.wrap = true -- wrapping by default
|
|
|
|
opts.wrap = true -- wrapping by default
|
|
|
|
opts.stylize_markdown = true
|
|
|
|
opts.stylize_markdown = true
|
|
|
|
opts.focus = true
|
|
|
|
opts.focus = true
|
|
|
|
|
|
|
|
local contents = markdown_lines
|
|
|
|
local contents = lsp.util._trim(markdown_lines, opts)
|
|
|
|
if vim.fn.has('nvim-0.10') == 0 then
|
|
|
|
|
|
|
|
contents = util._trim(markdown_lines, opts) -- function removed in 0.10
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
contents = markdown_lines
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- applies the syntax and sets the lines to the buffer
|
|
|
|
-- applies the syntax and sets the lines to the buffer
|
|
|
|
local bufnr, winnr = util.open_floating_preview(markdown_lines, 'markdown', config)
|
|
|
|
local bufnr, winnr = util.open_floating_preview(contents, 'markdown', config)
|
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
|
|
|
contents = lsp.util.stylize_markdown(bufnr, contents, opts)
|
|
|
|
contents = lsp.util.stylize_markdown(bufnr, contents, opts)
|
|
|
|