Skip to content

Commit

Permalink
feat(conceal): add min_length option (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Apr 19, 2024
1 parent 2a23bc6 commit 1ac7b7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Here is the default configuration:
},
conceal = {
enabled = false, -- can be toggled by commands
min_length = nil, -- only conceal classes exceeding the provided length
symbol = "󱏿", -- only a single character is allowed
highlight = { -- extmark highlight options, see :h 'highlight'
fg = "#38BDF8",
Expand Down
18 changes: 11 additions & 7 deletions lua/tailwind-tools/conceal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ local function set_conceal(bufnr)
vim.api.nvim_buf_clear_namespace(bufnr, vim.g.tailwind_tools.color_ns, 0, -1)
table.insert(state.conceal.active_buffers, bufnr)

local opts = config.options.conceal

for _, node in pairs(class_nodes) do
local start_row, start_col, end_row, end_col = treesitter.get_class_range(node, bufnr)

vim.api.nvim_buf_set_extmark(bufnr, vim.g.tailwind_tools.conceal_ns, start_row, start_col, {
end_line = end_row,
end_col = end_col,
conceal = config.options.conceal.symbol,
hl_group = "TailwindConceal",
priority = 0, -- To ignore conceal hl_group when focused
})
if not opts.min_length or node:byte_length() >= opts.min_length then
vim.api.nvim_buf_set_extmark(bufnr, vim.g.tailwind_tools.conceal_ns, start_row, start_col, {
end_line = end_row,
end_col = end_col,
conceal = opts.symbol,
hl_group = "TailwindConceal",
priority = 0, -- To ignore conceal hl_group when focused
})
end
end
end

Expand Down
1 change: 1 addition & 0 deletions lua/tailwind-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ M.options = {
},
conceal = {
enabled = false,
min_length = nil,
symbol = "󱏿",
highlight = {
fg = "#38BDF8",
Expand Down

0 comments on commit 1ac7b7a

Please sign in to comment.