Implement kind highlights (#584)
* Implement kind highlights * Fix link
This commit is contained in:
16
README.md
16
README.md
@@ -264,6 +264,10 @@ The source customization options. It is defined by each source.
|
||||
The priority of the source. If you don't specify it, the source priority will
|
||||
be determined by the default algorithm (see `sorting.priority_weight`).
|
||||
|
||||
#### sources[number].trigger_characters (type: string[])
|
||||
|
||||
The source specific triggerCharacters for override.
|
||||
|
||||
#### sources[number].keyword_pattern (type: string)
|
||||
|
||||
The source specific keyword_pattern for override.
|
||||
@@ -473,6 +477,18 @@ The fuzzy matched characters highlight.
|
||||
|
||||
The kind field.
|
||||
|
||||
#### `CmpItemKind%KIND_NAME%`
|
||||
|
||||
The specific kind highlights.
|
||||
You can see the name on [lsp.lua#L108](./lua/cmp/types/lsp.lua#L108).
|
||||
|
||||
For example, You can change the highlight like this if you want to override only the `Method` kind.
|
||||
|
||||
```
|
||||
highlight! CmpItemKindMethod guibg=NONE guifg=LightYellow
|
||||
```
|
||||
|
||||
|
||||
#### `CmpItemMenu`
|
||||
|
||||
The menu field.
|
||||
|
||||
@@ -212,7 +212,7 @@ entry.get_view = function(self, suggest_offset)
|
||||
view.kind.text = item.kind or ''
|
||||
view.kind.bytes = #view.kind.text
|
||||
view.kind.width = vim.str_utfindex(view.kind.text)
|
||||
view.kind.hl_group = 'CmpItemKind'
|
||||
view.kind.hl_group = 'CmpItemKind' .. types.lsp.CompletionItemKind[self:get_kind()]
|
||||
view.menu = {}
|
||||
view.menu.text = item.menu or ''
|
||||
view.menu.bytes = #view.menu.text
|
||||
|
||||
@@ -5,6 +5,7 @@ vim.g.loaded_cmp = true
|
||||
|
||||
local api = require "cmp.utils.api"
|
||||
local misc = require('cmp.utils.misc')
|
||||
local types = require('cmp.types')
|
||||
local config = require('cmp.config')
|
||||
local highlight = require('cmp.utils.highlight')
|
||||
|
||||
@@ -78,6 +79,11 @@ misc.set(_G, { 'cmp', 'plugin', 'colorscheme' }, function()
|
||||
guibg = 'NONE',
|
||||
ctermbg = 'NONE',
|
||||
})
|
||||
for name in pairs(types.lsp.CompletionItemKind) do
|
||||
if type(name) == 'string' then
|
||||
vim.cmd(([[highlight! default link CmpItemKind%sDefault CmpItemKindDefault]]):format(name))
|
||||
end
|
||||
end
|
||||
highlight.inherit('CmpItemMenuDefault', 'Pmenu', {
|
||||
guibg = 'NONE',
|
||||
ctermbg = 'NONE',
|
||||
@@ -104,6 +110,14 @@ end
|
||||
if vim.fn.hlexists('CmpItemKind') ~= 1 then
|
||||
vim.cmd [[highlight! default link CmpItemKind CmpItemKindDefault]]
|
||||
end
|
||||
for name in pairs(types.lsp.CompletionItemKind) do
|
||||
if type(name) == 'string' then
|
||||
local hi = ('CmpItemKind%s'):format(name)
|
||||
if vim.fn.hlexists(hi) ~= 1 then
|
||||
vim.cmd(([[highlight! default link %s %sDefault]]):format(hi, hi))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if vim.fn.hlexists('CmpItemMenu') ~= 1 then
|
||||
vim.cmd [[highlight! default link CmpItemMenu CmpItemMenuDefault]]
|
||||
|
||||
Reference in New Issue
Block a user