LazyVim.LazyVim/lua/lazyvim/config/autocmds.lua

36 lines
822 B
Lua
Raw Normal View History

2022-12-30 17:30:52 +01:00
-- Check if we need to reload the file when it changed
vim.api.nvim_create_autocmd("FocusGained", { command = "checktime" })
-- Highlight on yank
2022-12-30 18:21:25 +01:00
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
})
2022-12-30 17:30:52 +01:00
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
2022-12-30 17:30:52 +01:00
callback = function()
vim.cmd([[silent! normal! g`"]])
2022-12-30 17:30:52 +01:00
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = {
"qf",
"help",
"man",
"notify",
"lspinfo",
"spectre_panel",
"startuptime",
"tsplayground",
"PlenaryTestPopup",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})