소스 검색

test: trigger loading event manually for mason (#4343)

kylo252 1 년 전
부모
커밋
2f45be36de
2개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      lua/lvim/core/autocmds.lua
  2. 3 0
      tests/specs/lsp_spec.lua

+ 1 - 1
lua/lvim/core/autocmds.lua

@@ -143,7 +143,7 @@ function M.load_defaults()
           local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf })
           local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf })
           if not (vim.fn.expand "%" == "" or buftype == "nofile") then
           if not (vim.fn.expand "%" == "" or buftype == "nofile") then
             vim.api.nvim_del_augroup_by_name "_file_opened"
             vim.api.nvim_del_augroup_by_name "_file_opened"
-            vim.cmd "do User FileOpened"
+            vim.api.nvim_exec_autocmds("User", { pattern = "FileOpened" })
             require("lvim.lsp").setup()
             require("lvim.lsp").setup()
           end
           end
         end,
         end,

+ 3 - 0
tests/specs/lsp_spec.lua

@@ -24,6 +24,9 @@ describe("lsp workflow", function()
   local plugins = require "lvim.plugins"
   local plugins = require "lvim.plugins"
   require("lvim.plugin-loader").load { plugins, lvim.plugins }
   require("lvim.plugin-loader").load { plugins, lvim.plugins }
 
 
+  -- trigger loading event manually for mason
+  vim.api.nvim_exec_autocmds("User", { pattern = "FileOpened" })
+
   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
     if utils.is_directory(lvim.lsp.templates_dir) then
       assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0)
       assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0)