cmp.add_filetype_source()
call for an unset filetype should inherit default sources
#1217
Labels
feature
New feature or request
Feature Description
I think it would be more intuitive if a call to
cmp.add_filetype_source(<ft>, <source>)
, for a filetype that you haven't configured, would inherit the default sources instead of setting<source>
as the only one for that filetype. Since it's usually plugins that callcmp.add_filetype_source()
, a user may find it confusing that their default sources don't work on some filetypes.For example, the
codecompanion.nvim
plugin adds its own source for its chat buffers.With the current implementation, a user would need to duplicate their default sources to a per_filetype entry, e.g.
sources.per_filetype.codecompanion
in order to use them in codecompanion chat buffers.Instead, I propose that this should be inverted: default sources should be inherited by default, and the user could choose to not have them for specific filetypes by setting an empty table for the respective per_filetype entries. This would be consistent in the sense that any non-configured per-filetype filetypes would use the default sources.
blink.cmp/lua/blink/cmp/init.lua
Lines 312 to 316 in 507d0d7
I think initializing
config.sources.per_filetype
to a copy of the default sources rather than an empty table would be sufficient. The current implementation doesn't seem to check for duplicates, so I don't know if that should be added or not.Please let me know any thoughts on this. Thank you!
The text was updated successfully, but these errors were encountered: