Skip to content

Commit fc12fa9

Browse files
authored
fix(render): not render two separator for doc window (#451)
* fix(render): not render two separator for doc window Some LSP servers like lua_ls would return `---` for function doc, so the manually added separator would make two separator in doc window. * doc: update default highlight group
1 parent 283a6af commit fc12fa9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,14 @@ MiniDeps.add({
679679
| `BlinkCmpScrollBarThumb` | PmenuThumb | The scrollbar thumb |
680680
| `BlinkCmpScrollBarGutter` | PmenuSbar | The scrollbar gutter |
681681
| `BlinkCmpLabel` | Pmenu | Label of the completion item |
682-
| `BlinkCmpLabelDeprecated` | Comment | Deprecated label of the completion item |
682+
| `BlinkCmpLabelDeprecated` | NonText | Deprecated label of the completion item |
683683
| `BlinkCmpLabelMatch` | Pmenu | (Currently unused) Label of the completion item when it matches the query |
684+
| `BlinkCmpLabelDetail` | NonText | Label description of the completion item |
685+
| `BlinkCmpLabelDescription` | NonText | Label description of the completion item |
684686
| `BlinkCmpKind` | Special | Kind icon/text of the completion item |
685687
| `BlinkCmpKind<kind>` | Special | Kind icon/text of the completion item |
686688
| `BlinkCmpSource` | NonText | Source of the completion item |
687-
| `BlinkCmpGhostText` | Comment | Preview item with ghost text |
689+
| `BlinkCmpGhostText` | NonText | Preview item with ghost text |
688690
| `BlinkCmpDoc` | NormalFloat | The documentation window |
689691
| `BlinkCmpDocBorder` | NormalFloat | The documentation window border |
690692
| `BlinkCmpDocSeparator` | NormalFloat | The documentation separator between doc and detail |

lua/blink/cmp/lib/window/docs.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ function docs.render_detail_and_documentation(bufnr, detail, documentation, max_
2424
detail_lines, doc_lines = docs.extract_detail_from_doc(detail_lines, doc_lines)
2525

2626
local combined_lines = vim.list_extend({}, detail_lines)
27+
2728
-- add a blank line for the --- separator
28-
if #detail_lines > 0 and #doc_lines > 0 then table.insert(combined_lines, '') end
29-
vim.list_extend(combined_lines, doc_lines)
29+
local doc_already_has_separator = #doc_lines > 1 and (doc_lines[1] == '---' or doc_lines[1] == '***')
30+
if #detail_lines > 0 and #doc_lines > 0 then table.insert(combined_lines, '') end
31+
-- skip original separator in doc_lines, so we can highlight it later
32+
vim.list_extend(combined_lines, doc_lines, doc_already_has_separator and 2 or 1)
3033

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

0 commit comments

Comments
 (0)