From b2b336d3a09f024067f5e8e3ee4a6cc4fe7bc4de Mon Sep 17 00:00:00 2001 From: n3wborn Date: Sat, 14 Sep 2024 14:59:37 +0200 Subject: [PATCH] refactor(autocommand): remove class conceal --- lua/custom/autocommands.lua | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/lua/custom/autocommands.lua b/lua/custom/autocommands.lua index 7a39e91..ec25f90 100644 --- a/lua/custom/autocommands.lua +++ b/lua/custom/autocommands.lua @@ -133,41 +133,4 @@ vim.api.nvim_create_autocmd({ 'LspAttach' }, { end, }) -local conceal_ns = vim.api.nvim_create_namespace('class_conceal') -vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'TextChanged', 'InsertLeave' }, { - desc = 'Conceal HTML class attributes. Ideal for big TailwindCSS class lists', - group = vim.api.nvim_create_augroup('class_conceal', { clear = true }), - pattern = { '*.tsx' }, - callback = function(event) - local bufnr = event.buf or vim.api.nvim_get_current_buf() - - ---Ref: https://gist.github.com/mactep/430449fd4f6365474bfa15df5c02d27b - local language_tree = vim.treesitter.get_parser(bufnr, 'tsx') - local syntax_tree = language_tree:parse() - local root = syntax_tree[1]:root() - - local ok, query = pcall( - vim.treesitter.query.parse, - 'tsx', - [[ - ((jsx_attribute - (property_identifier) @att_name (#eq? @att_name "class") - (string (string_fragment) @class_value))) - ]] - ) - if not ok then - return - end - - for _, captures, metadata in query:iter_matches(root, bufnr, root:start(), root:end_(), {}) do - local start_row, start_col, end_row, end_col = captures[2]:range() - vim.api.nvim_buf_set_extmark(bufnr, conceal_ns, start_row, start_col + 3, { - end_line = end_row, - end_col = end_col, - conceal = '%', -- "…", - }) - end - end, -}) - vim.opt.updatetime = 100