Class: CommandT::Settings
- Inherits:
-
Object
- Object
- CommandT::Settings
- Defined in:
- lib/command-t/settings.rb
Overview
Convenience class for saving and restoring global settings.
Constant Summary collapse
- GLOBAL_SETTINGS =
Settings which apply globally and so must be manually saved and restored
%w[ equalalways hlsearch insertmode report showcmd scrolloff sidescroll sidescrolloff timeout timeoutlen updatetime ]
- LOCAL_SETTINGS =
Settings which can be made locally to the Command-T buffer or window
%w[ bufhidden buflisted buftype colorcolumn concealcursor conceallevel cursorline filetype foldcolumn foldlevel list modifiable number readonly relativenumber spell swapfile synmaxcol textwidth wrap ]
- KNOWN_SETTINGS =
GLOBAL_SETTINGS + LOCAL_SETTINGS
Instance Method Summary collapse
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #restore ⇒ Object
- #set(setting, value) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
48 49 50 |
# File 'lib/command-t/settings.rb', line 48 def initialize @settings = [] end |
Instance Method Details
#restore ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/command-t/settings.rb', line 68 def restore @settings.each do |setting, value| case value when TrueClass, FalseClass set_bool setting, value when Numeric set_number setting, value when String set_string setting, value end end end |
#set(setting, value) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/command-t/settings.rb', line 52 def set(setting, value) raise "Unknown setting #{setting}" unless KNOWN_SETTINGS.include?(setting) case value when TrueClass, FalseClass @settings.push([setting, VIM::get_bool("&#{setting}")]) if global?(setting) set_bool setting, value when Numeric @settings.push([setting, VIM::get_number("&#{setting}")]) if global?(setting) set_number setting, value when String @settings.push([setting, VIM::get_string("&#{setting}")]) if global?(setting) set_string setting, value end end |