nvim: fix autocmds

This commit is contained in:
tastytea 2022-08-10 17:52:25 +02:00
parent 1c2fe12d9e
commit 2590f905a7
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
5 changed files with 22 additions and 24 deletions

View File

@ -18,14 +18,18 @@ packer.use {
map('n', '<Leader>g', ':Neogit<cr>') map('n', '<Leader>g', ':Neogit<cr>')
} }
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_augroup('config_coding', { clear = true })
vim.api.nvim_create_autocmd(
{ 'FileType' },
{
group = 'config_coding',
pattern = { 'gitcommit', 'gitrebase' }, pattern = { 'gitcommit', 'gitrebase' },
callback = function() callback = function()
-- FIXME: why does the autocmd in settings.lua not set it? -- FIXME: why does the autocmd in settings.lua not set it?
vim.wo.colorcolumn = tostring(vim.o.textwidth) vim.wo.colorcolumn = tostring(vim.o.textwidth)
vim.cmd([[startinsert | 1]]) vim.cmd([[startinsert | 1]])
end end
}) })
packer.use { packer.use {
'https://github.com/gentoo/gentoo-syntax', 'https://github.com/gentoo/gentoo-syntax',

View File

@ -5,9 +5,11 @@ function my_remove_trailing_whitespace()
vim.api.nvim_win_set_cursor(0, curpos) vim.api.nvim_win_set_cursor(0, curpos)
end end
vim.api.nvim_create_augroup('config_functions', { clear = true })
vim.api.nvim_create_autocmd( vim.api.nvim_create_autocmd(
{ 'BufWritePre' }, { 'BufWritePre' },
{ {
group = 'config_functions',
pattern = { pattern = {
'*.lua', '*.cpp', '*.hpp' '*.lua', '*.cpp', '*.hpp'
}, },

View File

@ -56,21 +56,6 @@ packer.use {
callback = vim.lsp.buf.clear_references, callback = vim.lsp.buf.clear_references,
}) })
end end
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = 'rounded',
source = 'always',
prefix = ' ',
scope = 'cursor',
}
vim.diagnostic.open_float(nil, opts)
end
})
end end
-- setup servers -- setup servers

View File

@ -36,7 +36,12 @@ vim.api.nvim_create_autocmd(
callback = function() callback = function()
-- exclude plugins.lua, because that would re-init packer -- exclude plugins.lua, because that would re-init packer
if (not vim.api.nvim_buf_get_name(0):match('plugins.lua$')) then if (not vim.api.nvim_buf_get_name(0):match('plugins.lua$')) then
vim.cmd([[source <afile> | PackerInstall]]) vim.cmd([[
echo 'reloading config file…'
source <afile>
PackerInstall
redraw
]])
end end
end end
} }

View File

@ -28,9 +28,11 @@ packer.use {
packer.use 'https://github.com/editorconfig/editorconfig-vim' packer.use 'https://github.com/editorconfig/editorconfig-vim'
-- set colorcolumn to textwidth after buffer is displayed or option is changed -- set colorcolumn to textwidth after buffer is displayed or option is changed
vim.api.nvim_create_augroup('config_settings', { clear = true })
vim.api.nvim_create_autocmd( vim.api.nvim_create_autocmd(
{ 'BufWinEnter', 'OptionSet' }, { 'BufWinEnter', 'OptionSet' },
{ {
group = 'config_settings',
pattern = { 'textwidth' }, pattern = { 'textwidth' },
callback = function() callback = function()
if vim.o.textwidth > 0 then if vim.o.textwidth > 0 then