From 5fff13e7c62638f4e020a601bd0655b8951fd50f Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 27 Jun 2015 21:15:33 +0200 Subject: [PATCH] Replace `vimfx.categories` with `vimfx.get('categories')` --- documentation/api.md | 12 ++++++++---- extension/lib/api.coffee | 3 +-- extension/test/test-api.coffee | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/documentation/api.md b/documentation/api.md index 87ff2cb..ce05bc8 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -51,11 +51,15 @@ Gets the value of the VimFx pref `pref`. You can see all prefs in [defaults.coffee]. +You might also want to read more about the special pref [categories]. + ```js vimfx.get('hint_chars') vimfx.get('modes.normal.follow') ``` +[categories]: vimfxgetcategories + ### `vimfx.set(pref)` Sets the value of the VimFx pref `pref`. @@ -86,7 +90,7 @@ to extend VimFx. They should add commands manually to `vimfx.modes` instead. value has to be one of the keys of `vimfx.modes`. - category: `String`. Defaults to `'misc'` for Normal mode and `''` (uncategorized) otherwise. The category to add the command to. The - value has to be one of the keys of `vimfx.categories`. + value has to be one of the keys of `vimfx.get('categories')`. - order: `Number`. Defaults to putting the command at the end of the category. The first of the default commands has the order `100` and then they increase by `100` per command. This allows to put new commands between two already @@ -292,7 +296,7 @@ A command is an object with the following properties: - description: `Function`. Returns a description of the command, shown in the help dialog and VimFx’s settings page in the Add-ons Manager. - category: `String`. The category to add the command to. The value has to be - one of the keys of `vimfx.categories`. + one of the keys of `vimfx.get('categories')`. - order: `Number`. The first of the default commands has the order `100` and then they increase by `100` per command. This allows to put new commands between two already existing ones. @@ -340,7 +344,7 @@ Have a look at [modes.coffee] and [commands.coffee] for more information. [modes.coffee]: ../extension/lib/modes.coffee [commands.coffee]: ../extension/lib/commands.coffee -### `vimfx.categories` +### `vimfx.get('categories')` An object whose keys are category names and whose values are categories. @@ -355,7 +359,7 @@ A category is an object with the follwing properties: This allows to put new categories between two already existing ones. ```js -let {categories} = vimfx +let categories = vimfx.get('categories') // Add new category. categories.custom = { diff --git a/extension/lib/api.coffee b/extension/lib/api.coffee index a8969ee..8cc77d8 100644 --- a/extension/lib/api.coffee +++ b/extension/lib/api.coffee @@ -26,7 +26,7 @@ counter = new utils.Counter({start: 10000, step: 100}) createAPI = (vimfx) -> get: (pref) -> switch when pref of defaults.parsed_options - vimfx.defaults.parsed_options[pref] + defaults.parsed_options[pref] when pref of defaults.all_prefs or pref?.startsWith('custom.') prefs.get(pref) else @@ -103,7 +103,6 @@ createAPI = (vimfx) -> on: vimfx.on.bind(vimfx) refresh: vimfx.createKeyTrees.bind(vimfx) modes: vimfx.modes - categories: vimfx.options.categories getOverrides = (rules, args...) -> for [match, overrides] in rules diff --git a/extension/test/test-api.coffee b/extension/test/test-api.coffee index fc1d05c..663e23c 100644 --- a/extension/test/test-api.coffee +++ b/extension/test/test-api.coffee @@ -35,7 +35,6 @@ exports['test exports'] = (assert, passed_vimfx) -> getAPI((vimfx) -> assert.equal(typeof vimfx.on, 'function', 'on') assert.equal(typeof vimfx.refresh, 'function', 'refresh') assert.equal(vimfx.modes, passed_vimfx.modes, 'modes') - assert.equal(vimfx.categories, passed_vimfx.options.categories, 'categories') ) exports['test get'] = (assert, passed_vimfx) -> getAPI((vimfx) -> @@ -65,7 +64,7 @@ exports['test customization'] = (assert, passed_vimfx) -> getAPI((vimfx) -> vimfx.set('custom.mode.normal.test_command', 'ö') # Add a slightly more complex command. - vimfx.categories['new_category'] = { + vimfx.get('categories')['new_category'] = { name: -> 'New category' order: -100 } -- 2.39.3