fix(tailwind): allow overriding filetypes. Fixes #1590
This commit is contained in:
@ -4,16 +4,30 @@ return {
|
|||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
tailwindcss = {
|
tailwindcss = {
|
||||||
|
-- exclude a filetype from the default_config
|
||||||
filetypes_exclude = { "markdown" },
|
filetypes_exclude = { "markdown" },
|
||||||
|
-- add additional filetypes to the default_config
|
||||||
|
filetypes_include = {},
|
||||||
|
-- to fully override the default_config, change the below
|
||||||
|
-- filetypes = {}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup = {
|
setup = {
|
||||||
tailwindcss = function(_, opts)
|
tailwindcss = function(_, opts)
|
||||||
local tw = require("lspconfig.server_configurations.tailwindcss")
|
local tw = require("lspconfig.server_configurations.tailwindcss")
|
||||||
|
opts.filetypes = opts.filetypes or {}
|
||||||
|
|
||||||
|
-- Add default filetypes
|
||||||
|
vim.list_extend(opts.filetypes, tw.default_config.filetypes)
|
||||||
|
|
||||||
|
-- Remove excluded filetypes
|
||||||
--- @param ft string
|
--- @param ft string
|
||||||
opts.filetypes = vim.tbl_filter(function(ft)
|
opts.filetypes = vim.tbl_filter(function(ft)
|
||||||
return not vim.tbl_contains(opts.filetypes_exclude or {}, ft)
|
return not vim.tbl_contains(opts.filetypes_exclude or {}, ft)
|
||||||
end, tw.default_config.filetypes)
|
end, opts.filetypes)
|
||||||
|
|
||||||
|
-- Add additional filetypes
|
||||||
|
vim.list_extend(opts.filetypes, opts.filetypes_include)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user