Skip to content

Commit 55e3065

Browse files
committed
Update CmpStatus command to lua API
Signed-off-by: Micah Halter <[email protected]>
1 parent 07132dc commit 55e3065

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

plugin/cmp.lua

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ if vim.g.loaded_cmp then
33
end
44
vim.g.loaded_cmp = true
55

6-
local api = require "cmp.utils.api"
6+
local api = require('cmp.utils.api')
77
local misc = require('cmp.utils.misc')
88
local types = require('cmp.types')
99
local config = require('cmp.config')
1010
local highlight = require('cmp.utils.highlight')
1111

1212
-- TODO: https://github.com/neovim/neovim/pull/14661
13-
vim.cmd [[
13+
vim.cmd([[
1414
augroup ___cmp___
1515
autocmd!
1616
autocmd InsertEnter * lua require'cmp.utils.autocmd'.emit('InsertEnter')
@@ -23,7 +23,7 @@ vim.cmd [[
2323
autocmd CmdlineEnter * call v:lua.cmp.plugin.cmdline.enter()
2424
autocmd CmdwinEnter * call v:lua.cmp.plugin.cmdline.leave() " for entering cmdwin with `<C-f>`
2525
augroup END
26-
]]
26+
]])
2727

2828
misc.set(_G, { 'cmp', 'plugin', 'cmdline', 'enter' }, function()
2929
if config.is_native_menu() then
@@ -32,13 +32,13 @@ misc.set(_G, { 'cmp', 'plugin', 'cmdline', 'enter' }, function()
3232
if vim.fn.expand('<afile>') ~= '=' then
3333
vim.schedule(function()
3434
if api.is_cmdline_mode() then
35-
vim.cmd [[
35+
vim.cmd([[
3636
augroup cmp-cmdline
3737
autocmd!
3838
autocmd CmdlineChanged * lua require'cmp.utils.autocmd'.emit('TextChanged')
3939
autocmd CmdlineLeave * call v:lua.cmp.plugin.cmdline.leave()
4040
augroup END
41-
]]
41+
]])
4242
require('cmp.utils.autocmd').emit('CmdlineEnter')
4343
end
4444
end)
@@ -47,11 +47,11 @@ end)
4747

4848
misc.set(_G, { 'cmp', 'plugin', 'cmdline', 'leave' }, function()
4949
if vim.fn.expand('<afile>') ~= '=' then
50-
vim.cmd [[
50+
vim.cmd([[
5151
augroup cmp-cmdline
5252
autocmd!
5353
augroup END
54-
]]
54+
]])
5555
require('cmp.utils.autocmd').emit('CmdlineLeave')
5656
end
5757
end)
@@ -92,14 +92,14 @@ misc.set(_G, { 'cmp', 'plugin', 'colorscheme' }, function()
9292
end)
9393
_G.cmp.plugin.colorscheme()
9494

95-
vim.cmd [[
95+
vim.cmd([[
9696
highlight default link CmpItemAbbr CmpItemAbbrDefault
9797
highlight default link CmpItemAbbrDeprecated CmpItemAbbrDeprecatedDefault
9898
highlight default link CmpItemAbbrMatch CmpItemAbbrMatchDefault
9999
highlight default link CmpItemAbbrMatchFuzzy CmpItemAbbrMatchFuzzyDefault
100100
highlight default link CmpItemKind CmpItemKindDefault
101101
highlight default link CmpItemMenu CmpItemMenuDefault
102-
]]
102+
]])
103103

104104
for name in pairs(types.lsp.CompletionItemKind) do
105105
if type(name) == 'string' then
@@ -122,7 +122,8 @@ if vim.on_key then
122122
end, vim.api.nvim_create_namespace('cmp.plugin'))
123123
end
124124

125-
vim.cmd [[command! CmpStatus lua require('cmp').status()]]
126-
127-
vim.cmd [[doautocmd <nomodeline> User CmpReady]]
125+
vim.api.nvim_create_user_command('CmpStatus', function()
126+
require('cmp').status()
127+
end, { desc = 'Check status of cmp sources' })
128128

129+
vim.cmd([[doautocmd <nomodeline> User CmpReady]])

0 commit comments

Comments
 (0)