feat: configure spaces on Tab per language
This commit is contained in:
@@ -145,6 +145,8 @@ module Vamp
|
||||
@highlight_trailing_whitespace = false
|
||||
@whitespace_characters = {}
|
||||
@whitespace_scope = "all"
|
||||
@tab_spaces = nil
|
||||
@language_tab_spaces = {}
|
||||
@diff_context_lines = 10
|
||||
@diff_expand_lines = 15
|
||||
@diff_view_mode = "split"
|
||||
@@ -254,6 +256,25 @@ module Vamp
|
||||
@whitespace_scope = scope
|
||||
end
|
||||
|
||||
# @param spaces [Integer, nil] spaces per Tab, or nil for a literal tab
|
||||
# @return [Integer, nil]
|
||||
def tab_spaces=(spaces)
|
||||
@tab_spaces = tab_spaces!(spaces)
|
||||
end
|
||||
|
||||
# @param languages [Hash{String => Integer, nil}] syntax language names to Tab widths
|
||||
# @return [Hash{String => Integer, nil}]
|
||||
def language_tab_spaces=(languages)
|
||||
raise TypeError, "language_tab_spaces must be a Hash" unless languages.is_a?(Hash)
|
||||
|
||||
@language_tab_spaces = languages.to_h do |language, spaces|
|
||||
language = nonempty_string!(language, "Tab language")
|
||||
raise ArgumentError, "Tab language must not contain control characters" if language.match?(/[[:cntrl:]]/)
|
||||
|
||||
[language, tab_spaces!(spaces)]
|
||||
end
|
||||
end
|
||||
|
||||
# @param lines [Integer] nonnegative context lines around each diff change
|
||||
# @return [Integer]
|
||||
def diff_context_lines=(lines)
|
||||
@@ -329,6 +350,7 @@ module Vamp
|
||||
"highlight_trailing_whitespace" => @highlight_trailing_whitespace,
|
||||
"whitespace_characters" => @whitespace_characters,
|
||||
"whitespace_scope" => @whitespace_scope,
|
||||
"tab_spaces" => @tab_spaces, "language_tab_spaces" => @language_tab_spaces,
|
||||
"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,
|
||||
@@ -337,6 +359,16 @@ module Vamp
|
||||
end
|
||||
|
||||
private
|
||||
# @param spaces [Integer, nil]
|
||||
# @return [Integer, nil]
|
||||
def tab_spaces!(spaces)
|
||||
unless spaces.nil? || (spaces.is_a?(Integer) && spaces.between?(1, 255))
|
||||
raise ArgumentError, "tab_spaces must be nil or an Integer between 1 and 255"
|
||||
end
|
||||
|
||||
spaces
|
||||
end
|
||||
|
||||
# @param value [Integer]
|
||||
# @param label [String]
|
||||
# @param minimum [Integer]
|
||||
|
||||
Reference in New Issue
Block a user