From 7e473b99d3f977703f56591ccd4a7f8d197e1d61 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Sat, 12 Feb 2022 21:05:17 +0900 Subject: [PATCH] Support multiple filetypes Fix #786 --- doc/cmp.txt | 2 +- lua/cmp/config.lua | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/cmp.txt b/doc/cmp.txt index d1430bb..7680a02 100644 --- a/doc/cmp.txt +++ b/doc/cmp.txt @@ -603,7 +603,7 @@ How to setup on the specific buffer?~ You can setup buffer specific configuration like this. > - cmp.setup.filetype('markdown', { + cmp.setup.filetype({ 'markdown', 'help' }, { sources = { { name = 'path' }, { name = 'buffer' }, diff --git a/lua/cmp/config.lua b/lua/cmp/config.lua index 7fc53e8..6db2fa6 100644 --- a/lua/cmp/config.lua +++ b/lua/cmp/config.lua @@ -45,11 +45,13 @@ end ---Set configuration for filetype ---@param c cmp.ConfigSchema ----@param filetype string -config.set_filetype = function(c, filetype) - local revision = (config.filetypes[filetype] or {}).revision or 1 - config.filetypes[filetype] = c or {} - config.filetypes[filetype].revision = revision + 1 +---@param filetypes string[]|string +config.set_filetype = function(c, filetypes) + for _, filetype in ipairs(type(filetypes) == 'table' and filetypes or { filetypes }) do + local revision = (config.filetypes[filetype] or {}).revision or 1 + config.filetypes[filetype] = c or {} + config.filetypes[filetype].revision = revision + 1 + end end ---Set configuration for cmdline