Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(render): not render two separator for doc window #451

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,14 @@ MiniDeps.add({
| `BlinkCmpScrollBarThumb` | PmenuThumb | The scrollbar thumb |
| `BlinkCmpScrollBarGutter` | PmenuSbar | The scrollbar gutter |
| `BlinkCmpLabel` | Pmenu | Label of the completion item |
| `BlinkCmpLabelDeprecated` | Comment | Deprecated label of the completion item |
| `BlinkCmpLabelDeprecated` | NonText | Deprecated label of the completion item |
| `BlinkCmpLabelMatch` | Pmenu | (Currently unused) Label of the completion item when it matches the query |
| `BlinkCmpLabelDetail` | NonText | Label description of the completion item |
| `BlinkCmpLabelDescription` | NonText | Label description of the completion item |
| `BlinkCmpKind` | Special | Kind icon/text of the completion item |
| `BlinkCmpKind<kind>` | Special | Kind icon/text of the completion item |
| `BlinkCmpSource` | NonText | Source of the completion item |
| `BlinkCmpGhostText` | Comment | Preview item with ghost text |
| `BlinkCmpGhostText` | NonText | Preview item with ghost text |
| `BlinkCmpDoc` | NormalFloat | The documentation window |
| `BlinkCmpDocBorder` | NormalFloat | The documentation window border |
| `BlinkCmpDocSeparator` | NormalFloat | The documentation separator between doc and detail |
Expand Down
7 changes: 5 additions & 2 deletions lua/blink/cmp/lib/window/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function docs.render_detail_and_documentation(bufnr, detail, documentation, max_
detail_lines, doc_lines = docs.extract_detail_from_doc(detail_lines, doc_lines)

local combined_lines = vim.list_extend({}, detail_lines)

-- add a blank line for the --- separator
if #detail_lines > 0 and #doc_lines > 0 then table.insert(combined_lines, '') end
vim.list_extend(combined_lines, doc_lines)
local doc_already_has_separator = #doc_lines > 1 and (doc_lines[1] == '---' or doc_lines[1] == '***')
if #detail_lines > 0 and #doc_lines > 0 then table.insert(combined_lines, '') end
-- skip original separator in doc_lines, so we can highlight it later
vim.list_extend(combined_lines, doc_lines, doc_already_has_separator and 2 or 1)

vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, combined_lines)
vim.api.nvim_set_option_value('modified', false, { buf = bufnr })
Expand Down