Support multiple filetypes

Fix #786
This commit is contained in:
hrsh7th
2022-02-12 21:05:17 +09:00
parent 20152c6afd
commit 7e473b99d3
2 changed files with 8 additions and 6 deletions

View File

@@ -603,7 +603,7 @@ How to setup on the specific buffer?~
You can setup buffer specific configuration like this. You can setup buffer specific configuration like this.
> >
cmp.setup.filetype('markdown', { cmp.setup.filetype({ 'markdown', 'help' }, {
sources = { sources = {
{ name = 'path' }, { name = 'path' },
{ name = 'buffer' }, { name = 'buffer' },

View File

@@ -45,11 +45,13 @@ end
---Set configuration for filetype ---Set configuration for filetype
---@param c cmp.ConfigSchema ---@param c cmp.ConfigSchema
---@param filetype string ---@param filetypes string[]|string
config.set_filetype = function(c, filetype) config.set_filetype = function(c, filetypes)
local revision = (config.filetypes[filetype] or {}).revision or 1 for _, filetype in ipairs(type(filetypes) == 'table' and filetypes or { filetypes }) do
config.filetypes[filetype] = c or {} local revision = (config.filetypes[filetype] or {}).revision or 1
config.filetypes[filetype].revision = revision + 1 config.filetypes[filetype] = c or {}
config.filetypes[filetype].revision = revision + 1
end
end end
---Set configuration for cmdline ---Set configuration for cmdline