nvim/lua/config/autocmd.lua

85 lines
2.2 KiB
Lua
Raw Normal View History

2023-01-23 21:50:46 +01:00
-- vim.api.nvim_set_hl(0, 'NormalFloat', { bg = '#282828' })
2023-04-08 23:47:10 +02:00
-- vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'NONE' }) vim.api.nvim_set_hl(0, 'Pmenu', { bg = 'NONE' })
2023-01-23 21:50:46 +01:00
-- vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'NONE' })
2023-04-08 23:47:10 +02:00
local function augroup(name)
return vim.api.nvim_create_augroup('neo_' .. name, { clear = true })
end
2023-01-19 16:58:02 +01:00
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
2022-12-31 17:43:31 +01:00
]]
end,
})
-- use 2 spaces for cpp
vim.api.nvim_create_autocmd({ 'FileType' }, {
pattern = { 'cpp', 'cc', 'hpp', 'hh', 'md', 'markdown', 'java' },
2022-12-31 17:43:31 +01:00
callback = function()
vim.opt.ts = 4
vim.opt.sw = 4
2022-12-31 17:43:31 +01:00
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,
-- })
2023-01-19 16:58:17 +01:00
2023-04-08 23:47:10 +02:00
-- 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
2023-06-19 11:33:42 +02:00
vim.opt_local.textwidth = 80
2023-04-08 23:47:10 +02:00
end,
})
vim.cmd [[
augroup change_cursor
au!
au ExitPre * :set guicursor=a:hor90
augroup END
]]
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')