diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-06-14 23:04:34 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-14 23:04:34 -0700 | 
| commit | 44fad0a7a30a7fb2af1ba912f402fe386f3e1170 (patch) | |
| tree | 5d3d6b7a12d08bc9e491b4ef487e55a9eb61acff /runtime/lua/vim/lsp/util.lua | |
| parent | b28d458f8716be6d682390ea25a481b7dbb6e24d (diff) | |
| parent | d7d1f40d2c1ec2b5e06221ffa463350bc568f3c0 (diff) | |
| download | rneovim-44fad0a7a30a7fb2af1ba912f402fe386f3e1170.tar.gz rneovim-44fad0a7a30a7fb2af1ba912f402fe386f3e1170.tar.bz2 rneovim-44fad0a7a30a7fb2af1ba912f402fe386f3e1170.zip | |
Merge pull request #14815 from folke/lsp_triples
fix(lsp): replace --- by a line in stylize_markdown
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
| -rw-r--r-- | runtime/lua/vim/lsp/util.lua | 23 | 
1 files changed, 17 insertions, 6 deletions
| diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index afe1ead9ee..326005dac4 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1166,8 +1166,13 @@ function M.stylize_markdown(bufnr, contents, opts)      return line:match(string.format("^%%s*%s%%s*$", pattern[3]))    end +  -- Clean up +  contents = M._trim(contents, opts) +    local stripped = {}    local highlights = {} +  -- keep track of lnums that contain markdown +  local markdown_lines = {}    do      local i = 1      while i <= #contents do @@ -1192,17 +1197,24 @@ function M.stylize_markdown(bufnr, contents, opts)          })        else          table.insert(stripped, line) +        markdown_lines[#stripped] = true          i = i + 1        end      end    end -  -- Clean up -  stripped = M._trim(stripped, opts)    -- Compute size of float needed to show (wrapped) lines    opts.wrap_at = opts.wrap_at or (vim.wo["wrap"] and api.nvim_win_get_width(0))    local width, height = M._make_floating_popup_size(stripped, opts) +  local sep_line = string.rep("─", math.min(width, opts.wrap_at or width)) + +  for l in pairs(markdown_lines) do +    if stripped[l]:match("^---+$") then +      stripped[l] = sep_line +    end +  end +    -- Insert blank line separator after code block    local insert_separator = opts.separator    if insert_separator == nil then insert_separator = true end @@ -1213,10 +1225,8 @@ function M.stylize_markdown(bufnr, contents, opts)        h.finish = h.finish + offset        -- check if a seperator already exists and use that one instead of creating a new one        if h.finish + 1 <= #stripped then -        if stripped[h.finish + 1]:match("^---+$") then -          stripped[h.finish + 1] = string.rep("─", math.min(width, opts.wrap_at or width)) -        else -          table.insert(stripped, h.finish + 1, string.rep("─", math.min(width, opts.wrap_at or width))) +        if stripped[h.finish + 1] ~= sep_line then +          table.insert(stripped, h.finish + 1, sep_line)            offset = offset + 1            height = height + 1          end @@ -1224,6 +1234,7 @@ function M.stylize_markdown(bufnr, contents, opts)      end    end +    vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, stripped)    local idx = 1 | 
