regroup autocmds and add default check

This commit is contained in:
James Dixon 2020-05-26 12:39:11 -04:00
parent 5fd4f8d7cb
commit 0eee969d73
2 changed files with 47 additions and 54 deletions

View File

@ -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 ##
"------------
augroup general
autocmd!
"set plugin settings on VimEnter
augroup set_plugin_settings
autocmd!
autocmd VimEnter * call SetPluginSettings()
augroup END
"keep equal proportions when windows resized
augroup auto_resize_windows
autocmd!
autocmd VimResized * wincmd =
augroup END
"save cursor position in a file
au BufReadPost * if line("'\"") > 1 && line("'\"")
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
\ <= line("$") | exe "normal! g'\"" | endif
augroup END
"--------------------------------
"## language/filetype specific ##
"--------------------------------
augroup languages
autocmd!
"shell
augroup filetype_shell
autocmd!
autocmd BufNewFile,BufRead *bash* set syntax=sh
augroup END
"python
augroup filetype_python
autocmd!
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
augroup END
"go
augroup filetype_go
autocmd!
set expandtab! "go uses real tabs
augroup END
autocmd FileType go set expandtab! "go uses real tabs
"html
augroup filetype_html
autocmd!
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!
autocmd FileType html,javascript,css,json,yaml,sh
\ setlocal ts=2 sts=2 sw=2 expandtab
augroup END

View File

@ -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
augroup general
autocmd!
autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab
"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
augroup languages
autocmd!
"shell
autocmd BufNewFile,BufRead *bash* set syntax=sh
"python
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
"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