fix: make FileOpened autocmd work with quickfix (#4040)

This commit is contained in:
LostNeophyte 2023-04-15 19:48:06 +02:00 committed by GitHub
parent 3b16c266d7
commit 70ce6b7ddc
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,13 +123,13 @@ function M.load_defaults()
"BufEnter", "BufEnter",
{ {
group = "_dir_opened", group = "_dir_opened",
once = true, nested = true,
callback = function(args) callback = function(args)
local bufname = vim.api.nvim_buf_get_name(args.buf) local bufname = vim.api.nvim_buf_get_name(args.buf)
if require("lvim.utils").is_directory(bufname) then if require("lvim.utils").is_directory(bufname) then
vim.api.nvim_del_augroup_by_name "_dir_opened" vim.api.nvim_del_augroup_by_name "_dir_opened"
vim.cmd "do User DirOpened" vim.cmd "do User DirOpened"
vim.api.nvim_exec_autocmds("BufEnter", {}) vim.api.nvim_exec_autocmds(args.event, { buffer = args.buf, data = args.data })
end end
end, end,
}, },
@ -138,10 +138,11 @@ function M.load_defaults()
{ "BufRead", "BufWinEnter", "BufNewFile" }, { "BufRead", "BufWinEnter", "BufNewFile" },
{ {
group = "_file_opened", group = "_file_opened",
once = true, nested = true,
callback = function(args) callback = function(args)
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.cmd "do User FileOpened" vim.cmd "do User FileOpened"
require("lvim.lsp").setup() require("lvim.lsp").setup()
end end