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

Validate only used providers? #1015

Closed
2 tasks done
stevalkr opened this issue Jan 15, 2025 · 3 comments
Closed
2 tasks done

Validate only used providers? #1015

stevalkr opened this issue Jan 15, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@stevalkr
Copy link

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

While sources can be dynamically provided, providers are always determined and validated, regardless of whether they’re used or not. This could be improved by accepting a function or merging all the sources and validating only the ones that are actually used.

for id, provider in pairs(config.providers) do
sources.validate_provider(id, provider)
end

Relevant configuration

sources = {
  default = { 'lsp', 'path', 'snippets', 'buffer' },
  providers = { }
},

neovim version

NVIM v0.11.0-dev-1417+g487c48ec86-Homebrew Build type: Release LuaJIT 2.1.1734355927 Run "nvim -V1 -v" for more info

blink.cmp version

1cc3b1a

@stevalkr stevalkr added the bug Something isn't working label Jan 15, 2025
@Saghen
Copy link
Owner

Saghen commented Jan 15, 2025

I don't see the use case for this. You should always provide valid configurations, and we should fail early, rather than only failing when you try to load the source. Open to your thoughts on this but closing for now

@Saghen Saghen closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@stevalkr
Copy link
Author

stevalkr commented Jan 16, 2025

When I disable a plugin that provides a source (for example, render-markdown.nvim), the blink.cmp plugin completely breaks down. Even typing :wq would result in an error. However, I don’t want all the plugins to be loaded at all times, especially when I open Nvim to navigate terminal output, use it as a file explorer, and so on. Minimizing plugins is somehow important when working on a remote machine or container. In these cases only certain plugins are enabled, but I still want command-line and path completion to be functional.

@Saghen
Copy link
Owner

Saghen commented Feb 1, 2025

Ah it sounds like #973 would fix your case, since we'd only show that error once. Fyi with lazy.nvim, you can isolate the enabled source via dependencies. With the recommended opts_extend from the installation docs, you can extend the sources.default array via opts = { sources = { default = { 'your-source' } } }

{
  enabled = your_condition,
  'your-plugin',
  dependencies = {
    {
      'saghen/blink.cmp',
      opts = { ... }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants