From fe7a6f41e59654db6bbc9eb2d084decc54b295e4 Mon Sep 17 00:00:00 2001 From: Ranjith Hegde Date: Tue, 23 Aug 2022 16:03:20 +0200 Subject: feat!: 0.7 API update (#1984) * switch to lua api for autocommands * switch to nvim_create_user_command * move to lua plugin initialization NOTICE: Defining commands in server configurations will be deprecated in future releases. See `:help lspconfig.txt` to setup the same in an `on_attach` function. Co-authored-by: Michael Lingelbach --- test/lspconfig_spec.lua | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'test/lspconfig_spec.lua') diff --git a/test/lspconfig_spec.lua b/test/lspconfig_spec.lua index 89effd47..f98568c1 100644 --- a/test/lspconfig_spec.lua +++ b/test/lspconfig_spec.lua @@ -32,7 +32,7 @@ describe('lspconfig', function() ok(exec_lua [[ local lspconfig = require("lspconfig") - local not_exist_dir = vim.fn.getcwd().."/not/exsts" + local not_exist_dir = vim.fn.getcwd().."/not/exists" return lspconfig.util.path.exists(not_exist_dir) == false ]]) end) @@ -76,7 +76,7 @@ describe('lspconfig', function() ok(exec_lua [[ local lspconfig = require("lspconfig") - local not_exist_dir = vim.fn.getcwd().."/not/exsts" + local not_exist_dir = vim.fn.getcwd().."/not/exists" return not lspconfig.util.path.is_dir(not_exist_dir) ]]) end) @@ -213,7 +213,43 @@ describe('lspconfig', function() ]]) end) end) + + describe('user commands', function() + it('should translate command definition to nvim_create_user_command options', function() + eq( + { + nargs = '*', + complete = 'custom,v:lua.some_global', + }, + exec_lua [[ + local util = require("lspconfig.util") + return util._parse_user_command_options({ + function () end, + "-nargs=* -complete=custom,v:lua.some_global" + }) + ]] + ) + + eq( + { + desc = 'My awesome description.', + nargs = '*', + complete = 'custom,v:lua.another_global', + }, + exec_lua [[ + local util = require("lspconfig.util") + return util._parse_user_command_options({ + function () end, + ["-nargs"] = "*", + "-complete=custom,v:lua.another_global", + description = "My awesome description." + }) + ]] + ) + end) + end) end) + describe('config', function() it('normalizes user, server, and base default configs', function() eq( @@ -283,7 +319,7 @@ describe('lspconfig', function() local _ = lspconfig.sumneko_lua local _ = lspconfig.tsserver lspconfig.rust_analyzer.setup {} - return lspconfig.available_servers() + return require("lspconfig.util").available_servers() ]], { 'rust_analyzer' } ) -- cgit v1.2.3-70-g09d2