aboutsummaryrefslogtreecommitdiff
path: root/test/functional/provider/provider_spec.lua
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2019-06-09 18:22:10 +0100
committerJustin M. Keyes <justinkz@gmail.com>2019-08-04 13:23:46 +0200
commit2cfe4748e57bd510b98ca81bd915f801f5a50bb5 (patch)
tree7fb2e4ce22b5c800a84c1408c5357e2035c4f296 /test/functional/provider/provider_spec.lua
parent2860453c4f9ad6abd7a967f9278401ae84a927e2 (diff)
downloadrneovim-2cfe4748e57bd510b98ca81bd915f801f5a50bb5.tar.gz
rneovim-2cfe4748e57bd510b98ca81bd915f801f5a50bb5.tar.bz2
rneovim-2cfe4748e57bd510b98ca81bd915f801f5a50bb5.zip
provider: let providers decide their status
Instead of deciding provider status in eval_has_provider, move the decision to the provider Vim scripts. Previously, provider loading worked as follows: 1. eval_has_provider() verified provider availability by searching for the provider#providername#Call function and cached this verificaion as a static variable for some providers 2. providers short-circuited on loading to prevent the definition of the Call function (with the exception of the node provider that did not) This commit changes the expected interface between nvim and its providers to facilitate provider reloading, by splitting the verification of the provider from the availability of the Call function. eval_has_provider() now checks for a provider#providername#enabled variable. It is up to the provider script to set this to 0 or 1 accordingly. eval_call_provider() remains unchanged. All providers hosting a Call function were updated to respect this. The clipboard provider now has a Reload function to reload the provider.
Diffstat (limited to 'test/functional/provider/provider_spec.lua')
-rw-r--r--test/functional/provider/provider_spec.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/functional/provider/provider_spec.lua b/test/functional/provider/provider_spec.lua
new file mode 100644
index 0000000000..6f414f36f4
--- /dev/null
+++ b/test/functional/provider/provider_spec.lua
@@ -0,0 +1,19 @@
+
+local helpers = require('test.functional.helpers')(after_each)
+local clear, eq, feed_command, eval = helpers.clear, helpers.eq, helpers.feed_command, helpers.eval
+
+describe('Providers', function()
+ before_each(function()
+ clear('--cmd', 'let &rtp = "test/functional/fixtures,".&rtp')
+ end)
+
+ it('must set the enabled variable or fail', function()
+ eq(42, eval("provider#brokenenabled#Call('dosomething', [])"))
+ feed_command("call has('brokenenabled')")
+ eq(0, eval("has('brokenenabled')"))
+ end)
+
+ it('without Call() are enabled', function()
+ eq(1, eval("has('brokencall')"))
+ end)
+end)