diff --git a/README.md b/README.md index c97e1b3..b40510a 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,18 @@ Here is the default configuration: }, }, custom_filetypes = {} -- see the extension section to learn how it works + supported_filetypes = { + "html", + "css", + "php", + "twig", + "vue", + "svelte", + "astro", + "htmldjango", + "javascriptreact", + "typescriptreact", + } ``` diff --git a/lua/tailwind-tools/conceal.lua b/lua/tailwind-tools/conceal.lua index ad69a5a..9cd76a4 100644 --- a/lua/tailwind-tools/conceal.lua +++ b/lua/tailwind-tools/conceal.lua @@ -36,11 +36,13 @@ end M.enable = function() vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, { group = vim.g.tailwind_tools.conceal_au, + pattern = config.options.supported_filetypes, callback = function(args) set_conceal(args.buf) end, }) -- Workaround to reset conceallevel per buffer vim.api.nvim_create_autocmd("BufEnter", { group = vim.g.tailwind_tools.conceal_au, + pattern = config.options.supported_filetypes, callback = function(args) vim.wo.conceallevel = vim.opt.conceallevel:get() if state.conceal.enabled then set_conceal(args.buf) end diff --git a/lua/tailwind-tools/config.lua b/lua/tailwind-tools/config.lua index 0b594e4..f2c80cf 100644 --- a/lua/tailwind-tools/config.lua +++ b/lua/tailwind-tools/config.lua @@ -20,6 +20,18 @@ M.options = { }, }, custom_filetypes = {}, + supported_filetypes = { + "html", + "css", + "php", + "twig", + "vue", + "svelte", + "astro", + "htmldjango", + "javascriptreact", + "typescriptreact", + }, } return M diff --git a/lua/tailwind-tools/init.lua b/lua/tailwind-tools/init.lua index 0bafeac..ed0403f 100644 --- a/lua/tailwind-tools/init.lua +++ b/lua/tailwind-tools/init.lua @@ -43,6 +43,7 @@ M.setup = function(options) vim.api.nvim_create_autocmd("LspAttach", { group = vim.g.tailwind_tools.conceal_au, + pattern = config.options.supported_filetypes, callback = lsp.on_attach, }) diff --git a/lua/tailwind-tools/treesitter.lua b/lua/tailwind-tools/treesitter.lua index 313f8f1..ab5484a 100644 --- a/lua/tailwind-tools/treesitter.lua +++ b/lua/tailwind-tools/treesitter.lua @@ -4,24 +4,12 @@ local log = require("tailwind-tools.log") local config = require("tailwind-tools.config") local parsers = require("nvim-treesitter.parsers") -local supported_filetypes = { - "html", - "css", - "php", - "twig", - "vue", - "svelte", - "astro", - "htmldjango", - "javascriptreact", - "typescriptreact", -} - ---@param bufnr number ---@param all boolean? M.get_class_nodes = function(bufnr, all) local ft = vim.bo[bufnr].ft - local filetypes = vim.tbl_extend("keep", config.options.custom_filetypes, supported_filetypes) + local filetypes = + vim.tbl_extend("keep", config.options.custom_filetypes, config.options.supported_filetypes) local results = {} if not vim.tbl_contains(filetypes, ft) then return end