nvim/lua/config/autocmd.lua
fiplox 11cba124b9 feat!: remove trouble, use nvim-bqf
trouble, after a :grep jumps to a first result. Did not find how to not
jump...
2023-06-20 19:01:48 +02:00

76 lines
1.9 KiB
Lua

-- 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' })
-- vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'NONE' })
local function augroup(name)
return vim.api.nvim_create_augroup('neo_' .. name, { clear = true })
end
-- 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', 'java' },
callback = function()
vim.opt.ts = 4
vim.opt.sw = 4
vim.opt.expandtab = true
end,
})
-- 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,
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd({ 'VimResized' }, {
group = augroup 'resize_splits',
callback = function()
vim.cmd 'tabdo wincmd ='
end,
})
-- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd('FileType', {
group = augroup 'wrap_spell',
pattern = { 'gitcommit', 'markdown' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
vim.opt_local.textwidth = 80
end,
})
vim.cmd [[
augroup change_cursor
au!
au ExitPre * :set guicursor=a:hor90
augroup END
]]