1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-07-04 16:20:28 +00:00
dotfiles/.config/nvim/lua/user/autocommands.lua

35 lines
872 B
Lua
Raw Normal View History

2022-10-01 11:46:18 +00:00
vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif")
-- Fixes Autocomment
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
callback = function()
vim.cmd("set formatoptions-=cro")
end,
})
-- Highlight Yanked Text
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
end,
})
2022-10-02 15:38:01 +00:00
-- Set expandtab=true in several file types
2022-10-01 11:46:18 +00:00
vim.api.nvim_create_autocmd({ "FileType" }, {
2022-10-14 18:40:51 +00:00
pattern = { "*.go", "makefile", "*.lua" },
2022-10-01 11:46:18 +00:00
callback = function()
vim.opt_local.expandtab = false
end,
})
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd({ "FileType" }, {
2022-10-14 18:40:51 +00:00
pattern = { "qf", "help", "man", "lspinfo" },
2022-10-01 11:46:18 +00:00
callback = function()
vim.cmd([[
nnoremap <silent> <buffer> q :close<CR>
set nobuflisted
]])
end,
})