From 0a2d70412e134577639833e65ab5cb2e1a58f7d9 Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Wed, 23 Sep 2020 02:25:04 +0200 Subject: [PATCH] vim: Move autosource of config into ftplugin Instead of only sourcing the vim config when vimrc or $MYVIMRC (xdg.vim) is edited, reload always when saving a vim file. This is a test. But I think it makes sense since I never edit a vim file that is not sourced by my config in any way. Thus reloading should be always appropriate. --- .config/vim/ftplugin/vim.vim | 6 ++++++ .config/vim/vimrc | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .config/vim/ftplugin/vim.vim diff --git a/.config/vim/ftplugin/vim.vim b/.config/vim/ftplugin/vim.vim new file mode 100644 index 0000000..d767ace --- /dev/null +++ b/.config/vim/ftplugin/vim.vim @@ -0,0 +1,6 @@ +" Source config upon saving vim file. +" Group to avoid "exponential" reloading. See: +" https://stackoverflow.com/questions/2400264/is-it-possible-to-apply-vim-configurations-without-restarting +augroup vimrc_reload + autocmd! BufWritePost * source $MYVIMRC | echom "Reloaded" | redraw +augroup END diff --git a/.config/vim/vimrc b/.config/vim/vimrc index ca104d9..84c4224 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -159,10 +159,5 @@ else endif endif -" Source edited vim config upon saving. -augroup vimrc - autocmd! BufWritePost $MYVIMRC,vimrc source % | echom "Reloaded" | redraw -augroup END - " Load filetype plugins filetype plugin indent on