summaryrefslogtreecommitdiff
path: root/plugin/vdebug.vim
diff options
context:
space:
mode:
authorDudemullet <elpaip@gmail.com>2015-12-13 01:10:38 -0600
committerDudemullet <elpaip@gmail.com>2015-12-13 01:10:38 -0600
commit4ec54eda078bef26f4ac68242e8648fc243b8514 (patch)
tree388d905b360e07a05a1639bbea842d23b49fc7ce /plugin/vdebug.vim
parent49552f52c3452747817d61f36625ed80c2a809e7 (diff)
downloadvdebug-4ec54eda078bef26f4ac68242e8648fc243b8514.zip
Extracts the get_options method from load_options
Diffstat (limited to 'plugin/vdebug.vim')
-rw-r--r--plugin/vdebug.vim27
1 files changed, 21 insertions, 6 deletions
diff --git a/plugin/vdebug.vim b/plugin/vdebug.vim
index 59d0ab4..5aea3a6 100644
--- a/plugin/vdebug.vim
+++ b/plugin/vdebug.vim
@@ -162,22 +162,37 @@ endfunction
" been loaded.
function! Vdebug_load_options(options)
" Merge options with defaults
+ let g:vdebug_options = extend(g:vdebug_options_defaults, a:options)
+
+ " Override with single defined params ie. g:vdebug_options_port
+ let single_defined_params = s:Vdebug_get_options()
+ let g:vdebug_options = extend(g:vdebug_options, single_defined_params)
+endfunction
+" Get options defined outside of the vdebug_options dictionary
+"
+" This helps for when users might want to define a single option by itself
+" without needing the ditionary ie. vdebug_options_port = 9000
+function! s:Vdebug_get_options()
let param_namespace = "g:vdebug_options_"
let param_namespace_len = strlen(param_namespace)
+
+ " Get the paramter names and concat the g:vdebug_options namespace
let parameters = map(keys(g:vdebug_options_defaults), 'param_namespace.v:val')
+
+ " Only use the defined parameters
let existing_params = filter(parameters, 'exists(v:val)')
- let final_params = {}
+ " put into a dictionary for use with extend()
+ let params = {}
for name in existing_params
let val = eval(name)
+
+ " Remove g:vdebug_options namespace from param
let name = strpart(name, param_namespace_len)
- let final_params[name] = val
+ let params[name] = val
endfor
-
- let g:vdebug_options = extend(g:vdebug_options_defaults, a:options)
-
- let g:vdebug_options = extend(g:vdebug_options, final_params)
+ return params
endfunction
" Assign keymappings, and merge with defaults.