class NvimConf::Generators::Settings::Code::Lua
Constants
- SETTING_NAMESPACES
- VIM_PREFIX
Public Class Methods
new(setting)
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 14 def initialize(setting) @setting = setting end
Public Instance Methods
generate()
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 18 def generate if %i[set unset].include?(@setting.operation) generate_set else generate_addition end end
Private Instance Methods
call_signature()
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 39 def call_signature [ VIM_PREFIX, SETTING_NAMESPACES[@setting.scope] || SETTING_NAMESPACES[:global], @setting.key ].join(".") end
fallback_to_truthy_on_nil(value)
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 66 def fallback_to_truthy_on_nil(value) return value unless value.nil? @setting.operation == :set end
format_value(value)
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 47 def format_value(value) case value when String [ '"', value, '"' ].join when Array [ "{", value.map { |inner_value| format_value(inner_value) }.join(", "), "}" ].join else fallback_to_truthy_on_nil(value) end end
generate_addition()
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 28 def generate_addition "#{call_signature}:append(#{format_value(@setting.value)})" end
generate_set()
click to toggle source
# File lib/nvim_conf/generators/code/settings/lua.rb, line 32 def generate_set [ call_signature, format_value(@setting.value) ].join(" = ") end