Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BlinkCmpStatus command #809

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/configuration/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ sources.providers.lsp = {

Blink can use `nvim-cmp` sources through a compatibility layer developed by [stefanboca](/~https://github.com/stefanboca): [blink.compat](/~https://github.com/Saghen/blink.compat). Please open any issues with `blink.compat` in that repo

## Checking status of sources providers

The command `:BlinkCmp status` can be used to view which sources providers are enabled or not enabled.

## Community sources

- [lazydev](/~https://github.com/folke/lazydev.nvim)
Expand Down
45 changes: 45 additions & 0 deletions lua/blink/cmp/commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
local commands = {}

function commands.status()
local sources = require('blink.cmp.sources.lib')
local all_providers = sources.get_all_providers()
local enabled_provider_ids = sources.get_enabled_provider_ids('default')

--- @type string[]
local not_enabled_provider_ids = {}
for provider_id, _ in pairs(all_providers) do
if not vim.list_contains(enabled_provider_ids, provider_id) then
table.insert(not_enabled_provider_ids, provider_id)
end
end

if #enabled_provider_ids > 0 then
vim.api.nvim_echo({ { '\n', 'Normal' } }, false, {})
vim.api.nvim_echo({ { '# enabled sources providers\n', 'Special' } }, false, {})

for _, provider_id in ipairs(enabled_provider_ids) do
vim.api.nvim_echo({ { ('- %s\n'):format(provider_id), 'Normal' } }, false, {})
end
end

if #not_enabled_provider_ids > 0 then
vim.api.nvim_echo({ { '\n', 'Normal' } }, false, {})
vim.api.nvim_echo({ { '# not enabled sources providers\n', 'Comment' } }, false, {})

for _, provider_id in pairs(not_enabled_provider_ids) do
vim.api.nvim_echo({ { ('- %s\n'):format(provider_id), 'Normal' } }, false, {})
end
end
end

function commands.setup()
vim.api.nvim_create_user_command('BlinkCmp', function(cmd)
if cmd.fargs[1] == 'status' then
commands.status()
else
vim.notify("[blink.cmp] invalid command '" .. cmd.args .. "'", vim.log.levels.ERROR)
end
end, { nargs = 1, complete = function() return { 'status' } end, desc = 'blink.cmp' })
end

return commands
3 changes: 2 additions & 1 deletion lua/blink/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ function cmp.setup(opts)
require('blink.cmp.fuzzy.download').ensure_downloaded(function(err)
if err then vim.notify(err, vim.log.levels.ERROR) end

-- setup highlights, keymap, completion and signature help
-- setup highlights, keymap, completion, commands and signature help
require('blink.cmp.highlights').setup()
require('blink.cmp.keymap').setup()
require('blink.cmp.completion').setup()
require("blink.cmp.commands").setup()
if config.signature.enabled then require('blink.cmp.signature').setup() end
end)
end
Expand Down
Loading