|
@@ -1,9 +1,8 @@
|
|
|
-local a = require "plenary.async_lib.tests"
|
|
|
local utils = require "lvim.utils"
|
|
|
local helpers = require "tests.lvim.helpers"
|
|
|
local spy = require "luassert.spy"
|
|
|
|
|
|
-a.describe("lsp workflow", function()
|
|
|
+describe("lsp workflow", function()
|
|
|
before_each(function()
|
|
|
vim.cmd [[
|
|
|
let v:errmsg = ""
|
|
@@ -25,24 +24,26 @@ a.describe("lsp workflow", function()
|
|
|
local plugins = require "lvim.plugins"
|
|
|
require("lvim.plugin-loader").load { plugins, lvim.plugins }
|
|
|
|
|
|
- a.it("should be able to delete ftplugin templates", function()
|
|
|
+ it("should be able to delete ftplugin templates", function()
|
|
|
if utils.is_directory(lvim.lsp.templates_dir) then
|
|
|
assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0)
|
|
|
end
|
|
|
assert.False(utils.is_directory(lvim.lsp.templates_dir))
|
|
|
end)
|
|
|
|
|
|
- a.it("should be able to generate ftplugin templates", function()
|
|
|
+ it("should be able to generate ftplugin templates", function()
|
|
|
if utils.is_directory(lvim.lsp.templates_dir) then
|
|
|
assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0)
|
|
|
end
|
|
|
|
|
|
require("lvim.lsp").setup()
|
|
|
+ vim.wait(500)
|
|
|
|
|
|
- assert.True(#vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1) > 0)
|
|
|
+ local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)
|
|
|
+ assert.False(vim.tbl_isempty(template_files))
|
|
|
end)
|
|
|
|
|
|
- a.it("should not include blacklisted servers in the generated templates", function()
|
|
|
+ it("should not include blacklisted servers in the generated templates", function()
|
|
|
require("lvim.lsp").setup()
|
|
|
|
|
|
for _, server_name in ipairs(lvim.lsp.automatic_configuration.skipped_servers) do
|
|
@@ -52,11 +53,13 @@ a.describe("lsp workflow", function()
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
- a.it("should only include one server per generated template", function()
|
|
|
+ it("should only include one server per generated template", function()
|
|
|
require("lvim.lsp").setup()
|
|
|
+ vim.wait(500)
|
|
|
|
|
|
local allowed_dupes = { "tailwindcss" }
|
|
|
- for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do
|
|
|
+ local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)
|
|
|
+ for _, file in ipairs(template_files) do
|
|
|
local content = {}
|
|
|
for entry in io.lines(file) do
|
|
|
local server_name = entry:match [[.*setup%("(.*)"%)]]
|
|
@@ -76,7 +79,7 @@ a.describe("lsp workflow", function()
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
- a.it("should not attempt to re-generate ftplugin templates", function()
|
|
|
+ it("should not attempt to re-generate ftplugin templates", function()
|
|
|
local s = spy.on(require "lvim.lsp.templates", "generate_templates")
|
|
|
|
|
|
require("lvim.lsp").setup()
|