From 0eee969d73c963bf2aaf96accd730eb91e8db8ed Mon Sep 17 00:00:00 2001 From: James Dixon Date: Tue, 26 May 2020 12:39:11 -0400 Subject: [PATCH] regroup autocmds and add default check --- vim/vimrc | 61 ++++++++++++++++----------------------------------- vim/vimrc.min | 40 +++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 54 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index fc5e8a0..80e3aa9 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -7,6 +7,12 @@ "general settings "------------------------------------------------------------------------------ +"load defaults if available +if filereadable(expand('$VIMRUNTIME/defaults.vim')) + unlet! g:skip_defaults_vim + source $VIMRUNTIME/defaults.vim +endif + "encoding/format set encoding=utf-8 set fileformats=unix,dos,mac @@ -319,60 +325,31 @@ if has("autocmd") "------------ "## global ## "------------ - - "set plugin settings on VimEnter - augroup set_plugin_settings + augroup general autocmd! + "set plugin settings on VimEnter autocmd VimEnter * call SetPluginSettings() - augroup END - - "keep equal proportions when windows resized - augroup auto_resize_windows - autocmd! + "keep equal proportions when windows resized autocmd VimResized * wincmd = + "save cursor position in a file + autocmd BufReadPost * if line("'\"") > 1 && line("'\"") + \ <= line("$") | exe "normal! g'\"" | endif augroup END - "save cursor position in a file - au BufReadPost * if line("'\"") > 1 && line("'\"") - \ <= line("$") | exe "normal! g'\"" | endif - "-------------------------------- "## language/filetype specific ## "-------------------------------- - - "shell - augroup filetype_shell + augroup languages autocmd! + "shell autocmd BufNewFile,BufRead *bash* set syntax=sh - augroup END - - "python - augroup filetype_python - autocmd! + "python autocmd FileType python xnoremap r :'<,'>:w !python3 - augroup END - - "go - augroup filetype_go - autocmd! - set expandtab! "go uses real tabs - augroup END - - "html - augroup filetype_html - autocmd! + "go + autocmd FileType go set expandtab! "go uses real tabs + "html autocmd FileType html :syntax sync fromstart - augroup END - - "markdown - augroup filetype_md - autocmd! - autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab - augroup END - - "filestypes where tabs should = 2 spaces - augroup half_tab - autocmd! + "filestypes where tabs should = 2 spaces autocmd FileType html,javascript,css,json,yaml,sh \ setlocal ts=2 sts=2 sw=2 expandtab augroup END diff --git a/vim/vimrc.min b/vim/vimrc.min index 569a9aa..6a205d6 100644 --- a/vim/vimrc.min +++ b/vim/vimrc.min @@ -1,7 +1,13 @@ " -" minimal vimrc with no plugins +" minimal vimrc with no (extra) plugins " +"load defaults if available +if filereadable(expand('$VIMRUNTIME/defaults.vim')) + unlet! g:skip_defaults_vim + source $VIMRUNTIME/defaults.vim +endif + " ui set number set ruler @@ -35,18 +41,28 @@ set esckeys set ttimeoutlen=20 set timeoutlen=1000 -" filetype autocmds +" autocmds -"markdown -augroup filetype_md - autocmd! - autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab +augroup general + autocmd! + "keep equal proportions when windows resized + autocmd VimResized * wincmd = + "save cursor position in a file + autocmd BufReadPost * if line("'\"") > 1 && line("'\"") + \ <= line("$") | exe "normal! g'\"" | endif augroup END -"filestypes where tabs should = 2 spaces -augroup half_tab - autocmd! - autocmd FileType html,javascript,css,json,yaml,sh - \ setlocal ts=2 sts=2 sw=2 expandtab +augroup languages + autocmd! + "shell + autocmd BufNewFile,BufRead *bash* set syntax=sh + "python + autocmd FileType python xnoremap r :'<,'>:w !python3 + "go + autocmd FileType go set expandtab! "go uses real tabs + "html + autocmd FileType html :syntax sync fromstart + "filestypes where tabs should = 2 spaces + autocmd FileType html,javascript,css,json,yaml,sh + \ setlocal ts=2 sts=2 sw=2 expandtab augroup END -