* Adjust empty line count * Implement vim.api.nvim_create_autocmd (#844) * Implement vim.api.nvim_create_autocmd * Only use vim.api.nvim_create_autocmd on nighly * Cleanup * cleanup * Rename autos.lua to autocmds.lua * Fix forgot to rename autos to autocmds * Remove legacy autocmd * Add descriptions on autocmds * Update descriptions on autocmds * Update CmpStatus command to lua API (#922) Signed-off-by: Micah Halter <micah@balena.io> * Move highlights to nvim_set_hl lua API (#925) Signed-off-by: Micah Halter <micah@balena.io> * Add default to highlight * Refactor autocmds * fmt * Improve performance * Fix bug * Improve matching logic Fixes https://github.com/hrsh7th/nvim-cmp/discussions/954 * Fix format * Improve performance Fix #825 * Fix cmdline redraw bug * Fix event Co-authored-by: hrsh7th <> Co-authored-by: zer09 <zer09@users.noreply.github.com> Co-authored-by: Micah Halter <micah@mehalter.com>
57 lines
2.3 KiB
Lua
57 lines
2.3 KiB
Lua
if vim.g.loaded_cmp then
|
|
return
|
|
end
|
|
vim.g.loaded_cmp = true
|
|
|
|
local api = require('cmp.utils.api')
|
|
local types = require('cmp.types')
|
|
local highlight = require('cmp.utils.highlight')
|
|
local autocmd = require('cmp.utils.autocmd')
|
|
|
|
vim.api.nvim_set_hl(0, 'CmpItemAbbr', { link = 'CmpItemAbbrDefault', default = true })
|
|
vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { link = 'CmpItemAbbrDeprecatedDefault', default = true })
|
|
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { link = 'CmpItemAbbrMatchDefault', default = true })
|
|
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'CmpItemAbbrMatchFuzzyDefault', default = true })
|
|
vim.api.nvim_set_hl(0, 'CmpItemKind', { link = 'CmpItemKindDefault', default = true })
|
|
vim.api.nvim_set_hl(0, 'CmpItemMenu', { link = 'CmpItemMenuDefault', default = true })
|
|
for kind in pairs(types.lsp.CompletionItemKind) do
|
|
if type(kind) == 'string' then
|
|
local name = ('CmpItemKind%s'):format(kind)
|
|
vim.api.nvim_set_hl(0, name, { link = ('%sDefault'):format(name), default = true })
|
|
end
|
|
end
|
|
|
|
autocmd.subscribe('ColorScheme', function()
|
|
highlight.inherit('CmpItemAbbrDefault', 'Pmenu', { bg = 'NONE', default = true })
|
|
highlight.inherit('CmpItemAbbrDeprecatedDefault', 'Comment', { bg = 'NONE', default = true })
|
|
highlight.inherit('CmpItemAbbrMatchDefault', 'Pmenu', { bg = 'NONE', default = true })
|
|
highlight.inherit('CmpItemAbbrMatchFuzzyDefault', 'Pmenu', { bg = 'NONE', default = true })
|
|
highlight.inherit('CmpItemKindDefault', 'Special', { bg = 'NONE', default = true })
|
|
highlight.inherit('CmpItemMenuDefault', 'Pmenu', { bg = 'NONE', default = true })
|
|
for name in pairs(types.lsp.CompletionItemKind) do
|
|
if type(name) == 'string' then
|
|
vim.api.nvim_set_hl(0, ('CmpItemKind%sDefault'):format(name), { link = 'CmpItemKind', default = true })
|
|
end
|
|
end
|
|
end)
|
|
autocmd.emit('ColorScheme')
|
|
|
|
if vim.on_key then
|
|
vim.on_key(function(keys)
|
|
if keys == vim.api.nvim_replace_termcodes('<C-c>', true, true, true) then
|
|
vim.schedule(function()
|
|
if not api.is_suitable_mode() then
|
|
autocmd.emit('InsertLeave')
|
|
end
|
|
end)
|
|
end
|
|
end, vim.api.nvim_create_namespace('cmp.plugin'))
|
|
end
|
|
|
|
vim.api.nvim_create_user_command('CmpStatus', function()
|
|
require('cmp').status()
|
|
end, { desc = 'Check status of cmp sources' })
|
|
|
|
vim.cmd([[doautocmd <nomodeline> User CmpReady]])
|
|
|