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

Disable source for certain filetypes #666

Closed
shinzui opened this issue Dec 24, 2021 · 2 comments
Closed

Disable source for certain filetypes #666

shinzui opened this issue Dec 24, 2021 · 2 comments

Comments

@shinzui
Copy link

shinzui commented Dec 24, 2021

Sorry if this has been answered elsewhere, but I couldn't find a way to disable a source for a particular file type. What's the API, in general, to dynamically configure sources? My use case is that I want to disable the emoji source in Haskell and PureScript since : is commonly used.

@dmitmel
Copy link
Collaborator

dmitmel commented Dec 24, 2021

What's the API, in general, to dynamically configure sources?

You can just call cmp.setup or its variants repeatedly. E.g.:

-- ftplugin/haskell.lua
cmp.setup.buffer({
  sources = { ... }
})

The problem is that cmp.setup doesn't perform any configuration merging, so a call to it or cmp.setup.buffer replaces the configuration entirely (or not, I think it is done per-section. So sources, completion, documentation etc, the top-level keys, are separate sections). I don't do this myself, but if I were you, I'd do something like this:

-- ftplugin/haskell.lua
local cmp = require('cmp')
local sources = cmp.get_config().sources
for i = #sources, 1, -1 do
  if sources[i].name == 'emoji' then
    table.remove(sources, i)
  end
end
cmp.setup.buffer({ sources = sources })

#632 would make this easier.

@shinzui
Copy link
Author

shinzui commented Dec 28, 2021

Thanks, @dmitmel. I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants