From 86eab24e807ed2957d26ca43b2b76b92d0fbf8f4 Mon Sep 17 00:00:00 2001 From: McAuley Penney Date: Wed, 9 Aug 2023 13:59:55 -0700 Subject: [PATCH] !refactor: replace custom util with api fn This reverts commit 7fdda2828a315737bcef70709aa69043051bd3ea. --- lua/tidy/init.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lua/tidy/init.lua b/lua/tidy/init.lua index 46834ef..20290bf 100644 --- a/lua/tidy/init.lua +++ b/lua/tidy/init.lua @@ -12,9 +12,21 @@ function M.toggle() end end +local function list_to_set(list) + local set = {} + + for _, item in ipairs(list) do + set[item] = true + end + + return set +end + local function is_excluded_ft(opts) local ft = vim.api.nvim_buf_get_option(0, "filetype") - return vim.list_contains(opts.filetype_exclude, ft) + local ft_set = list_to_set(opts.filetype_exclude) + + return ft_set[ft] end local function reset_cursor_pos(pos) @@ -43,14 +55,6 @@ function M.setup(opts) opts = vim.tbl_extend("force", defaults, opts or {}) - if not vim.tbl_islist(opts.filetype_exclude) then - vim.notify( - "tidy.nvim: filetype_exclude option must be a list-like table...", - vim.log.levels.ERROR, - { title = "Tidy" } - ) - end - local tidy_grp = vim.api.nvim_create_augroup("tidy", { clear = true }) vim.api.nvim_create_autocmd("BufWritePre", {