feat: add configurable whitespace markers

This commit is contained in:
2026-10-13 22:53:40 +02:00
parent e2f33519d1
commit 2357b5be46
8 changed files with 210 additions and 7 deletions
+15
View File
@@ -143,6 +143,7 @@ module Vamp
@labels = {}
@scroll_distance = 0
@highlight_trailing_whitespace = false
@whitespace_characters = {}
@diff_context_lines = 10
@diff_expand_lines = 15
@diff_view_mode = "split"
@@ -230,6 +231,19 @@ module Vamp
@highlight_trailing_whitespace = enabled
end
# @param characters [Hash{String => String}] whitespace character to single-cell marker
# @return [Hash{String => String}]
def whitespace_characters=(characters)
raise TypeError, "whitespace_characters must be a Hash" unless characters.is_a?(Hash)
characters.each do |whitespace, marker|
unless [whitespace, marker].all? { |value| value.is_a?(String) && value.length == 1 }
raise TypeError, "whitespace_characters keys and values must be single-character Strings"
end
end
@whitespace_characters = characters.dup
end
# @param lines [Integer] nonnegative context lines around each diff change
# @return [Integer]
def diff_context_lines=(lines)
@@ -303,6 +317,7 @@ module Vamp
"git_gutter" => @git_gutter,
"scroll_distance" => @scroll_distance,
"highlight_trailing_whitespace" => @highlight_trailing_whitespace,
"whitespace_characters" => @whitespace_characters,
"top_bar" => @bar.top, "bottom_bar" => @bar.bottom, "labels" => @labels,
"popup" => { "command" => @popup.command, "search" => @popup.search },
"diff_context_lines" => @diff_context_lines, "diff_expand_lines" => @diff_expand_lines,