Skip to content

Commit 1c14f8e

Browse files
committed
feat: option to disable treesitter highlighting
1 parent 8ba2069 commit 1c14f8e

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ MiniDeps.add({
506506
auto_show = false,
507507
auto_show_delay_ms = 500,
508508
update_delay_ms = 50,
509+
-- whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
510+
-- WARN: temporary, eventually blink will support regex highlighting
511+
treesitter_highlighting = true,
509512
},
510513
signature_help = {
511514
min_width = 1,
@@ -520,6 +523,9 @@ MiniDeps.add({
520523
-- which directions to show the window,
521524
-- falling back to the next direction when there's not enough space
522525
direction_priority = { 'n', 's' },
526+
-- whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
527+
-- WARN: temporary, eventually blink will support regex highlighting
528+
treesitter_highlighting = true,
523529
},
524530
ghost_text = {
525531
enabled = false,

lua/blink/cmp/config.lua

+8
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
--- @field auto_show? boolean
153153
--- @field auto_show_delay_ms? number Delay before showing the documentation window
154154
--- @field update_delay_ms? number Delay before updating the documentation window
155+
--- @field treesitter_highlighting? boolean Whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
155156

156157
--- @class blink.cmp.SignatureHelpConfig
157158
--- @field min_width? number
@@ -162,6 +163,7 @@
162163
--- @field winhighlight? string
163164
--- @field scrollbar? boolean
164165
--- @field direction_priority? ("n" | "s")[]
166+
--- @field treesitter_highlighting? boolean Whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
165167

166168
--- @class GhostTextConfig
167169
--- @field enabled? boolean
@@ -493,6 +495,9 @@ local config = {
493495
auto_show = false,
494496
auto_show_delay_ms = 500,
495497
update_delay_ms = 50,
498+
-- whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
499+
-- WARN: temporary, eventually blink will support regex highlighting
500+
treesitter_highlighting = true,
496501
},
497502
signature_help = {
498503
min_width = 1,
@@ -507,6 +512,9 @@ local config = {
507512
-- which directions to show the window,
508513
-- falling back to the next direction when there's not enough space
509514
direction_priority = { 'n', 's' },
515+
-- whether to use treesitter highlighting for the documentation window, disable if you run into performance issues
516+
-- WARN: temporary, eventually blink will support regex highlighting
517+
treesitter_highlighting = true,
510518
},
511519
ghost_text = {
512520
enabled = false,

lua/blink/cmp/windows/documentation.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ function docs.show_item(item)
6262
docs.win:get_buf(),
6363
item.detail,
6464
item.documentation,
65-
docs.win.config.max_width
65+
docs.win.config.max_width,
66+
config.treesitter_highlighting
6667
)
6768
end
6869
docs.shown_item = item

lua/blink/cmp/windows/lib/docs.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ local docs = {}
33
--- @param bufnr number
44
--- @param detail? string
55
--- @param documentation? lsp.MarkupContent | string
6-
function docs.render_detail_and_documentation(bufnr, detail, documentation, max_width)
6+
--- @param max_width number
7+
--- @param use_treesitter_highlighting boolean
8+
function docs.render_detail_and_documentation(bufnr, detail, documentation, max_width, use_treesitter_highlighting)
79
local detail_lines = {}
810
if detail and detail ~= '' then detail_lines = docs.split_lines(detail) end
911

@@ -30,7 +32,7 @@ function docs.render_detail_and_documentation(bufnr, detail, documentation, max_
3032
-- Highlight with treesitter
3133
vim.api.nvim_buf_clear_namespace(bufnr, require('blink.cmp.config').highlight.ns, 0, -1)
3234

33-
if #detail_lines > 0 then docs.highlight_with_treesitter(bufnr, vim.bo.filetype, 0, #detail_lines) end
35+
if #detail_lines > 0 and use_treesitter_highlighting then docs.highlight_with_treesitter(bufnr, vim.bo.filetype, 0, #detail_lines) end
3436

3537
-- Only add the separator if there are documentation lines (otherwise only display the detail)
3638
if #detail_lines > 0 and #doc_lines > 0 then
@@ -42,7 +44,7 @@ function docs.render_detail_and_documentation(bufnr, detail, documentation, max_
4244
})
4345
end
4446

45-
if #doc_lines > 0 then
47+
if #doc_lines > 0 and use_treesitter_highlighting then
4648
local start = #detail_lines + (#detail_lines > 0 and 1 or 0)
4749
docs.highlight_with_treesitter(bufnr, 'markdown', start, start + #doc_lines)
4850
end

lua/blink/cmp/windows/signature.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function signature.open_with_signature_help(context, signature_help)
5151
signature.win:get_buf(),
5252
active_signature.label,
5353
active_signature.documentation,
54-
config.max_width
54+
config.max_width,
55+
config.treesitter_highlighting
5556
)
5657
end
5758
signature.shown_signature = active_signature

0 commit comments

Comments
 (0)