From 16d98a918c2ef5d3c7b1484ec7378022e16ac462 Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 16 Sep 2024 13:48:59 -0400 Subject: [PATCH] feat: add customizable tab, indent, and scope characters --- lua/config/options.lua | 16 ++++++++ lua/data/types.lua | 88 +++++++++++++++++++++++++---------------- lua/plugins/mini.lua | 3 +- lua/utils/highlight.lua | 21 +++++++++- 4 files changed, 91 insertions(+), 37 deletions(-) diff --git a/lua/config/options.lua b/lua/config/options.lua index 1aa6a1e..44f0424 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -127,6 +127,22 @@ vim.g.disable_transparency = true ---@type boolean Options: -- Set colorcolumn vim.opt.colorcolumn = "120" ---@type string|table Options: [column] +-- ━━━━━━━━━━━━━━━━━━━━━━━━━ Tabs and Indentation ━━━━━━━━━━━━━━━━━━━━━━━━ +-- Define a character to be used in the whitespace to represent tabs/indents. +-- Tab character +-- vim.g.tab_char = "󰌒" ---@type string Options: [tab char] +-- -- Indent character +-- vim.g.indent_char = "¶" ---@type string Options: [indent char] +-- Scope character +-- vim.g.scope_char = "|" ---@type string Options: [scope char] +-- Alternatively, specify a character/table from the presets +-- Tab characters +vim.g.tab_char_name = "fancy" ---@type string Options: [tab char] +-- Indent characters +vim.g.indent_char_name = "fancy" ---@type string Options: [indent char] +-- Scope characters +vim.g.scope_char_name = "scope" ---@type string Options: [scope char] + -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Completion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Cmp Window Border vim.g.completion_borders = "rounded" ---@type string Options: [round|sharp|flat] diff --git a/lua/data/types.lua b/lua/data/types.lua index 900f3e9..2dc9b78 100644 --- a/lua/data/types.lua +++ b/lua/data/types.lua @@ -723,7 +723,44 @@ M.highlights = { --- Indent characters M.ibl = { - indent_char = { + char = { + none = { " " }, + light_vert = { "" }, + scope = { "│" }, + fancy_vert = { "‖" }, + strong_vert = { "⦀" }, + zigzag = { "⦚" }, + basic = { "" }, + simple = { "" }, + arrow = { "" }, + tab = { "󰌒" }, + mini = { "" }, + light_arrow = { "⤑" }, + block = { "█" }, + block_75 = { "▓" }, + block_50 = { "▒" }, + block_25 = { "░" }, + block_0 = { " " }, + baric = { "󰇘" }, + fish = { "⤕" }, + dot = { "⋅" }, + dots = { "⋯" }, + circle = { "" }, + dot_circle = { "󱥸" }, + dot_square = { "󱗽" }, + dot_hex = { "󱗿" }, + dot_tri = { "󱗾" }, + dot_grid = { "󱗼" }, + solid = { + "▏", + "▎", + "▍", + "▌", + "▋", + "▊", + "▉", + "█", + }, fancy = { "󰎤", "󰎧", @@ -736,31 +773,7 @@ M.ibl = { "󰎼", "󰽽", }, - solid = { - "▏", - "▎", - "▍", - "▌", - "▋", - "▊", - "▉", - "█", - }, - none = { " " }, - baric = { "󰇘" }, - }, - scope_char = { - light = { "" }, - hard = { "│" }, - none = { " " }, - fancy = { "‖" }, - strong = { "⦀" }, - basic = { "" }, - arrow = { "" }, - tab = { "󰌒" }, - }, - tab_char = { - fancy = { + funky = { "󰌒", "󰌓", "󰌔", @@ -772,19 +785,26 @@ M.ibl = { "󰌚", "󰌛", }, - none = { " " }, - basic = { "" }, - simple = { "" }, - arrow = { "" }, - tab = { "󰌒" }, - mini = { "" }, }, } --- Mini.Indentscope configuration options M.miniindentscope = { - symbol = M.ibl.scope_char.hard[1], - options = { try_as_border = true, border = "both" }, + opts = { + options = { try_as_border = true, border = "both" }, + }, + init = function() + -- Set default scope char + local scope_char + if vim.g.scope_char then + scope_char = vim.g.scope_char + elseif vim.g.scope_char_name then + scope_char = M.ibl.char[vim.g.scope_char_name][1] + else + scope_char = M.ibl.char.scope[1] + end + M.miniindentscope.opts.symbol = scope_char + end, } --- Navic Icons diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 7e1ab09..67a87d2 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -17,7 +17,8 @@ return { }, { -- Mini Indentscope "echasnovski/mini.indentscope", - opts = data.types.miniindentscope, + opts = data.types.miniindentscope.opts, + init = data.types.miniindentscope.init, }, { -- mini.align "echasnovski/mini.align", diff --git a/lua/utils/highlight.lua b/lua/utils/highlight.lua index cec4520..228e3dc 100644 --- a/lua/utils/highlight.lua +++ b/lua/utils/highlight.lua @@ -70,11 +70,28 @@ function M.setup_indent_highlight() end) end + -- Define characters for indent-blankline + local tab_char, indent_char + if vim.g.tab_char then + tab_char = vim.g.tab_char + elseif vim.g.tab_char_name then + tab_char = data.types.ibl.char[vim.g.tab_char_name] + else + tab_char = data.types.ibl.char.none + end + if vim.g.indent_char then + indent_char = vim.g.indent_char + elseif vim.g.indent_char_name then + indent_char = data.types.ibl.char[vim.g.indent_char_name] + else + indent_char = data.types.ibl.char.none + end + -- Configure the indent-blankline plugin require("ibl").setup({ indent = { - char = vim.g.indent_char or data.types.ibl.indent_char.none, - tab_char = vim.g.tab_char or data.types.ibl.tab_char.simple, + char = indent_char, + tab_char = tab_char, highlight = { "IndentBlanklineIndent", },