Mercurial > dotfiles
diff .chezmoitemplates/init.lua @ 489:1635e29e0ed4
Move autocmds to init.lua
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 14 Nov 2021 09:34:26 +0100 |
parents | 8edc5f86e9c3 |
children | 6d2e5337e8b2 |
line wrap: on
line diff
--- a/.chezmoitemplates/init.lua Sat Nov 13 15:22:08 2021 +0100 +++ b/.chezmoitemplates/init.lua Sun Nov 14 09:34:26 2021 +0100 @@ -612,6 +612,48 @@ [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) . ' (' . (v:foldend - v:foldstart + 1) . ' lines)']] opt.foldenable = false +local au = require 'au' + +-- Highlight yanked text +au.TextYankPost = function() + vim.highlight.on_yank { timeout = 120 } +end + +-- Automatic cursorline +au.group('cline', { + { + 'WinEnter', + '*', + function() + vim.opt_local.cursorline = true + end, + }, + { + 'WinLeave', + '*', + function() + vim.opt_local.cursorline = false + end, + }, +}) + +-- Save files on focus lost +au.FocusLost = function() + if not vim.o.readonly and vim.api.nvim_buf_get_name(0) ~= '' then + vim.cmd [[ wa ]] + end +end + +-- Equalize splits after resizing +au.VimResized = [[ exe "normal! \<c-w>=" ]] + +-- Reload diffs after editing +au.BufWritePost = function() + if vim.o.diff then + vim.cmd [[ diffupdate ]] + end +end + -- LSP config local lsp = require 'lspconfig' local null_ls = require 'null-ls' @@ -776,12 +818,6 @@ vim.cmd [[command! LspRename lua LspRename()]] -local au = require 'au' - -au.TextYankPost = function() - vim.highlight.on_yank { timeout = 120 } -end - vim.diagnostic.config { underline = true, update_in_insert = false,