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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 `:BlinkCmpStatus` can be used to view which sources providers are enabled or not enabled.

## Community sources

- [lazydev](https://github.com/folke/lazydev.nvim)
Expand Down
38 changes: 38 additions & 0 deletions lua/blink/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,42 @@ function cmp.add_provider(id, provider_config)
config.sources.providers[id] = provider_config
end

function cmp.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

vim.api.nvim_create_user_command(
'BlinkCmpStatus',
function() cmp.status() end,
{ desc = 'Check status of blink.cmp sources providers' }
)

return cmp