nvim/lua/config/autocmd.lua

52 lines
1.3 KiB
Lua
Raw Normal View History

2023-01-19 16:58:02 +01:00
vim.api.nvim_set_hl(0, 'NormalFloat', { bg = '#282828' })
vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'NONE' })
vim.api.nvim_set_hl(0, 'Pmenu', { bg = 'NONE' })
2022-12-31 17:43:31 +01:00
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd({ 'FileType' }, {
pattern = { 'qf', 'help', 'man', 'lspinfo', 'spectre_panel', 'lir' },
callback = function()
vim.cmd [[
nnoremap <silent> <buffer> q :close<CR>
set nobuflisted
]]
end,
})
-- use 2 spaces for cpp
vim.api.nvim_create_autocmd({ 'FileType' }, {
pattern = { 'cpp', 'cc', 'hpp', 'hh', 'md', 'markdown' },
callback = function()
vim.opt.ts = 2
vim.opt.sw = 2
vim.opt.expandtab = true
end,
})
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,
})
vim.api.nvim_create_augroup('diagnostics', { clear = true })
vim.api.nvim_create_autocmd({ 'DiagnosticChanged' }, {
group = 'diagnostics',
callback = function()
vim.diagnostic.setloclist { open = false }
end,
})
2023-01-19 16:58:17 +01:00
vim.cmd [[autocmd BufWinEnter quickfix silent :lua ToggleTroubleAuto()]]