aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authorRaphael <glephunter@gmail.com>2023-12-12 19:06:22 +0800
committerGitHub <noreply@github.com>2023-12-12 19:06:22 +0800
commit1d4a5cd18537d054a564ff19b9361120597d9dd7 (patch)
tree7b094048bf64789ad11e89b141baadec222bcf79 /test/functional/lua/vim_spec.lua
parente69834744ba550100778890d0b4ecfc3c469af15 (diff)
downloadrneovim-1d4a5cd18537d054a564ff19b9361120597d9dd7.tar.gz
rneovim-1d4a5cd18537d054a564ff19b9361120597d9dd7.tar.bz2
rneovim-1d4a5cd18537d054a564ff19b9361120597d9dd7.zip
feat(eval): exists() function supports checking v:lua functions (#26485)
Problem: Vimscript function exists() can't check v:lua functions. Solution: Add support for v:lua functions to exists().
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 1ef214d611..403e9f6a12 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -3352,4 +3352,31 @@ describe('vim.keymap', function()
eq(1, exec_lua[[return GlobalCount]])
end)
+ it('exists() can check a lua function', function()
+ eq(true, exec_lua[[
+ _G.test = function() print("hello") end
+ return vim.fn.exists('v:lua.test') == 1
+ ]])
+
+ eq(true, exec_lua[[
+ return vim.fn.exists('v:lua.require("mpack").decode') == 1
+ ]])
+
+ eq(true, exec_lua[[
+ return vim.fn.exists("v:lua.require('vim.lsp').start") == 1
+ ]])
+
+ eq(true, exec_lua[[
+ return vim.fn.exists('v:lua.require"vim.lsp".start') == 1
+ ]])
+
+ eq(true, exec_lua[[
+ return vim.fn.exists("v:lua.require'vim.lsp'.start") == 1
+ ]])
+
+ eq(false, exec_lua[[
+ return vim.fn.exists("v:lua.require'vim.lsp'.unknown") == 1
+ ]])
+ end)
+
end)