diff --git a/docs/configuration/sources.md b/docs/configuration/sources.md index 76dbbe40..65eb7c1f 100644 --- a/docs/configuration/sources.md +++ b/docs/configuration/sources.md @@ -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) diff --git a/lua/blink/cmp/init.lua b/lua/blink/cmp/init.lua index eb683aa4..80b45ebc 100644 --- a/lua/blink/cmp/init.lua +++ b/lua/blink/cmp/init.lua @@ -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