Skip to content

Commit 6bf1b4c

Browse files
committed
feat: custom blink.cmp kind name, highlight, and icon
require("crates").setup({ completion = { blink = { use_custom_kind = true, } }, })
1 parent 1803c8b commit 6bf1b4c

File tree

6 files changed

+265
-0
lines changed

6 files changed

+265
-0
lines changed

doc/crates.txt

+95
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ For more information about individual config options see |crates-config|.
232232
enabled = false,
233233
name = "crates.nvim",
234234
},
235+
blink = {
236+
use_custom_kind = true,
237+
kind_text = {
238+
version = "Version",
239+
feature = "Feature",
240+
},
241+
kind_highlight = {
242+
version = "BlinkCmpKindVersion",
243+
feature = "BlinkCmpKindFeature",
244+
},
245+
kind_icon = {
246+
version = "🅥 ",
247+
feature = "🅕 ",
248+
},
249+
},
235250
crates = {
236251
enabled = true,
237252
min_chars = 3,
@@ -1454,6 +1469,80 @@ completion.coq.name *crates-config-completion-coq-name*
14541469
The source name displayed by |coq_nvim|.
14551470

14561471

1472+
completion.blink *crates-config-completion-blink*
1473+
Section type: `BlinkConfig`
1474+
1475+
Configuration options for |blink-cmp|.
1476+
1477+
1478+
*crates-config-completion-blink-use_custom_kind*
1479+
completion.blink.use_custom_kind
1480+
Type: `boolean`, Default: `true`
1481+
1482+
Use custom a custom kind to display inside the |blink-cmp| completion menu.
1483+
1484+
1485+
completion.blink.kind_text *crates-config-completion-blink-kind_text*
1486+
Section type: `BlinkKindTextConfig`
1487+
1488+
The kind text shown in the |blink-cmp| completion menu.
1489+
1490+
1491+
*crates-config-completion-blink-kind_text-version*
1492+
completion.blink.kind_text.version
1493+
Type: `string`, Default: `"Version"`
1494+
1495+
The version kind text shown in the |blink-cmp| completion menu.
1496+
1497+
1498+
*crates-config-completion-blink-kind_text-feature*
1499+
completion.blink.kind_text.feature
1500+
Type: `string`, Default: `"Feature"`
1501+
1502+
The feature kind text shown in the |blink-cmp| completion menu.
1503+
1504+
1505+
*crates-config-completion-blink-kind_highlight*
1506+
completion.blink.kind_highlight
1507+
Section type: `BlinkKindHighlightConfig`
1508+
1509+
Highlight groups used for the kind text in the |blink-cmp| completion menu.
1510+
1511+
1512+
*crates-config-completion-blink-kind_highlight-version*
1513+
completion.blink.kind_highlight.version
1514+
Type: `string`, Default: `"BlinkCmpKindVersion"`
1515+
1516+
Highlight group used for the version kind text in the |blink-cmp| completion menu.
1517+
1518+
1519+
*crates-config-completion-blink-kind_highlight-feature*
1520+
completion.blink.kind_highlight.feature
1521+
Type: `string`, Default: `"BlinkCmpKindFeature"`
1522+
1523+
Highlight group used for the feature kind text in the |blink-cmp| completion menu.
1524+
1525+
1526+
completion.blink.kind_icon *crates-config-completion-blink-kind_icon*
1527+
Section type: `BlinkKindTextConfig`
1528+
1529+
The kind text shown in the |blink-cmp| completion menu.
1530+
1531+
1532+
*crates-config-completion-blink-kind_icon-version*
1533+
completion.blink.kind_icon.version
1534+
Type: `string`, Default: `"🅥 "`
1535+
1536+
The version kind icon shown in the |blink-cmp| completion menu.
1537+
1538+
1539+
*crates-config-completion-blink-kind_icon-feature*
1540+
completion.blink.kind_icon.feature
1541+
Type: `string`, Default: `"🅕 "`
1542+
1543+
The feature kind icon shown in the |blink-cmp| completion menu.
1544+
1545+
14571546
completion.crates *crates-config-completion-crates*
14581547
Section type: `CrateCompletionConfig`
14591548

@@ -1667,5 +1756,11 @@ CmpItemKindVersion *crates-hl-CmpItemKindVersion*
16671756
CmpItemKindFeature *crates-hl-CmpItemKindFeature*
16681757
Default: links to |Special|
16691758

1759+
BlinkCmpKindVersion *crates-hl-BlinkCmpKindVersion*
1760+
Default: links to |Special|
1761+
1762+
BlinkCmpKindFeature *crates-hl-BlinkCmpKindFeature*
1763+
Default: links to |Special|
1764+
16701765

16711766
vim:tw=78:ts=8:ft=help:norl:

docgen/wiki/Documentation-unstable.md

+15
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,21 @@ require("crates").setup {
389389
enabled = false,
390390
name = "crates.nvim",
391391
},
392+
blink = {
393+
use_custom_kind = true,
394+
kind_text = {
395+
version = "Version",
396+
feature = "Feature",
397+
},
398+
kind_highlight = {
399+
version = "BlinkCmpKindVersion",
400+
feature = "BlinkCmpKindFeature",
401+
},
402+
kind_icon = {
403+
version = "🅥 ",
404+
feature = "🅕 ",
405+
},
406+
},
392407
crates = {
393408
enabled = true,
394409
min_chars = 3,

lua/crates/completion/common.lua

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ local function complete_versions(crate, versions)
9898
kind_hl_group = state.cfg.completion.cmp.kind_highlight.version,
9999
}
100100
end
101+
if state.cfg.completion.blink.use_custom_kind then
102+
r.kind_name = state.cfg.completion.blink.kind_text.version
103+
r.kind_icon = state.cfg.completion.blink.kind_icon.version
104+
r.kind_hl = state.cfg.completion.blink.kind_highlight.version
105+
end
101106

102107
table.insert(items, r)
103108
end
@@ -159,6 +164,11 @@ local function complete_features(crate, cf, versions)
159164
kind_hl_group = state.cfg.completion.cmp.kind_highlight.feature,
160165
}
161166
end
167+
if state.cfg.completion.blink.use_custom_kind then
168+
r.kind_name = state.cfg.completion.blink.kind_text.feature
169+
r.kind_icon = state.cfg.completion.blink.kind_icon.feature
170+
r.kind_hl = state.cfg.completion.blink.kind_highlight.feature
171+
end
162172

163173
table.insert(items, r)
164174

lua/crates/config/init.lua

+104
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,110 @@ entry(schema_completion_coq, {
14911491
]],
14921492
})
14931493

1494+
local schema_completion_blink = section_entry(schema_completion, {
1495+
name = "blink",
1496+
type = {
1497+
config_type = "section",
1498+
emmylua_annotation = "BlinkConfig",
1499+
},
1500+
description = [[
1501+
Configuration options for |blink-cmp|.
1502+
]],
1503+
fields = {},
1504+
})
1505+
entry(schema_completion_blink, {
1506+
name = "use_custom_kind",
1507+
type = BOOLEAN_TYPE,
1508+
default = true,
1509+
description = [[
1510+
Use custom a custom kind to display inside the |blink-cmp| completion menu.
1511+
]],
1512+
})
1513+
1514+
local schema_completion_blink_kind_text = section_entry(schema_completion_blink, {
1515+
name = "kind_text",
1516+
type = {
1517+
config_type = "section",
1518+
emmylua_annotation = "BlinkKindTextConfig",
1519+
},
1520+
description = [[
1521+
The kind text shown in the |blink-cmp| completion menu.
1522+
]],
1523+
fields = {},
1524+
})
1525+
entry(schema_completion_blink_kind_text, {
1526+
name = "version",
1527+
type = STRING_TYPE,
1528+
default = "Version",
1529+
description = [[
1530+
The version kind text shown in the |blink-cmp| completion menu.
1531+
]],
1532+
})
1533+
entry(schema_completion_blink_kind_text, {
1534+
name = "feature",
1535+
type = STRING_TYPE,
1536+
default = "Feature",
1537+
description = [[
1538+
The feature kind text shown in the |blink-cmp| completion menu.
1539+
]],
1540+
})
1541+
1542+
local schema_completion_blink_kind_hl = section_entry(schema_completion_blink, {
1543+
name = "kind_highlight",
1544+
type = {
1545+
config_type = "section",
1546+
emmylua_annotation = "BlinkKindHighlightConfig",
1547+
},
1548+
description = [[
1549+
Highlight groups used for the kind text in the |blink-cmp| completion menu.
1550+
]],
1551+
fields = {},
1552+
})
1553+
entry(schema_completion_blink_kind_hl, {
1554+
name = "version",
1555+
type = STRING_TYPE,
1556+
default = "BlinkCmpKindVersion",
1557+
description = [[
1558+
Highlight group used for the version kind text in the |blink-cmp| completion menu.
1559+
]],
1560+
})
1561+
entry(schema_completion_blink_kind_hl, {
1562+
name = "feature",
1563+
type = STRING_TYPE,
1564+
default = "BlinkCmpKindFeature",
1565+
description = [[
1566+
Highlight group used for the feature kind text in the |blink-cmp| completion menu.
1567+
]],
1568+
})
1569+
1570+
local schema_completion_blink_kind_icon = section_entry(schema_completion_blink, {
1571+
name = "kind_icon",
1572+
type = {
1573+
config_type = "section",
1574+
emmylua_annotation = "BlinkKindTextConfig",
1575+
},
1576+
description = [[
1577+
The kind text shown in the |blink-cmp| completion menu.
1578+
]],
1579+
fields = {},
1580+
})
1581+
entry(schema_completion_blink_kind_icon, {
1582+
name = "version",
1583+
type = STRING_TYPE,
1584+
default = "🅥 ",
1585+
description = [[
1586+
The version kind icon shown in the |blink-cmp| completion menu.
1587+
]],
1588+
})
1589+
entry(schema_completion_blink_kind_icon, {
1590+
name = "feature",
1591+
type = STRING_TYPE,
1592+
default = "🅕 ",
1593+
description = [[
1594+
The feature kind icon shown in the |blink-cmp| completion menu.
1595+
]],
1596+
})
1597+
14941598
local schema_completion_crates = section_entry(schema_completion, {
14951599
name = "crates",
14961600
type = {

lua/crates/config/types.lua

+38
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
---@field text CompletionTextConfig
177177
---@field cmp CmpConfig
178178
---@field coq CoqConfig
179+
---@field blink BlinkConfig
179180
---@field crates CrateCompletionConfig
180181

181182
---@class CompletionTextConfig
@@ -200,6 +201,24 @@
200201
---@field enabled boolean
201202
---@field name string
202203

204+
---@class BlinkConfig
205+
---@field use_custom_kind boolean
206+
---@field kind_text BlinkKindTextConfig
207+
---@field kind_highlight BlinkKindHighlightConfig
208+
---@field kind_icon BlinkKindTextConfig
209+
210+
---@class BlinkKindTextConfig
211+
---@field version string
212+
---@field feature string
213+
214+
---@class BlinkKindHighlightConfig
215+
---@field version string
216+
---@field feature string
217+
218+
---@class BlinkKindTextConfig
219+
---@field version string
220+
---@field feature string
221+
203222
---@class CrateCompletionConfig
204223
---@field enabled boolean
205224
---@field min_chars integer
@@ -373,6 +392,7 @@
373392
---@field public text? crates.UserCompletionTextConfig
374393
---@field public cmp? crates.UserCmpConfig
375394
---@field public coq? crates.UserCoqConfig
395+
---@field public blink? crates.UserBlinkConfig
376396
---@field public crates? crates.UserCrateCompletionConfig
377397

378398
---@class crates.UserCompletionTextConfig
@@ -397,6 +417,24 @@
397417
---@field public enabled? boolean
398418
---@field public name? string
399419

420+
---@class crates.UserBlinkConfig
421+
---@field public use_custom_kind? boolean
422+
---@field public kind_text? crates.UserBlinkKindTextConfig
423+
---@field public kind_highlight? crates.UserBlinkKindHighlightConfig
424+
---@field public kind_icon? crates.UserBlinkKindTextConfig
425+
426+
---@class crates.UserBlinkKindTextConfig
427+
---@field public version? string
428+
---@field public feature? string
429+
430+
---@class crates.UserBlinkKindHighlightConfig
431+
---@field public version? string
432+
---@field public feature? string
433+
434+
---@class crates.UserBlinkKindTextConfig
435+
---@field public version? string
436+
---@field public feature? string
437+
400438
---@class crates.UserCrateCompletionConfig
401439
---@field public enabled? boolean
402440
---@field public min_chars? integer

lua/crates/highlight.lua

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ M.highlights = {
3535

3636
{ "CmpItemKindVersion", { default = true, link = "Special" } },
3737
{ "CmpItemKindFeature", { default = true, link = "Special" } },
38+
39+
{ "BlinkCmpKindVersion", { default = true, link = "Special" } },
40+
{ "BlinkCmpKindFeature", { default = true, link = "Special" } },
3841
}
3942

4043
function M.define()

0 commit comments

Comments
 (0)