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 "general settings
"------------------------------------------------------------------------------ "------------------------------------------------------------------------------
"load defaults if available
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim
endif
"encoding/format "encoding/format
set encoding=utf-8 set encoding=utf-8
set fileformats=unix,dos,mac set fileformats=unix,dos,mac
@ -319,60 +325,31 @@ if has("autocmd")
"------------ "------------
"## global ## "## global ##
"------------ "------------
augroup general
"set plugin settings on VimEnter
augroup set_plugin_settings
autocmd! autocmd!
"set plugin settings on VimEnter
autocmd VimEnter * call SetPluginSettings() autocmd VimEnter * call SetPluginSettings()
augroup END "keep equal proportions when windows resized
"keep equal proportions when windows resized
augroup auto_resize_windows
autocmd!
autocmd VimResized * wincmd = autocmd VimResized * wincmd =
"save cursor position in a file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
\ <= line("$") | exe "normal! g'\"" | endif
augroup END augroup END
"save cursor position in a file
au BufReadPost * if line("'\"") > 1 && line("'\"")
\ <= line("$") | exe "normal! g'\"" | endif
"-------------------------------- "--------------------------------
"## language/filetype specific ## "## language/filetype specific ##
"-------------------------------- "--------------------------------
augroup languages
"shell
augroup filetype_shell
autocmd! autocmd!
"shell
autocmd BufNewFile,BufRead *bash* set syntax=sh autocmd BufNewFile,BufRead *bash* set syntax=sh
augroup END "python
"python
augroup filetype_python
autocmd!
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR> autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
augroup END "go
autocmd FileType go set expandtab! "go uses real tabs
"go "html
augroup filetype_go
autocmd!
set expandtab! "go uses real tabs
augroup END
"html
augroup filetype_html
autocmd!
autocmd FileType html :syntax sync fromstart autocmd FileType html :syntax sync fromstart
augroup END "filestypes where tabs should = 2 spaces
"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 autocmd FileType html,javascript,css,json,yaml,sh
\ setlocal ts=2 sts=2 sw=2 expandtab \ setlocal ts=2 sts=2 sw=2 expandtab
augroup END 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 " ui
set number set number
set ruler set ruler
@ -35,18 +41,28 @@ set esckeys
set ttimeoutlen=20 set ttimeoutlen=20
set timeoutlen=1000 set timeoutlen=1000
" filetype autocmds " autocmds
"markdown augroup general
augroup filetype_md autocmd!
autocmd! "keep equal proportions when windows resized
autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab autocmd VimResized * wincmd =
"save cursor position in a file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
\ <= line("$") | exe "normal! g'\"" | endif
augroup END augroup END
"filestypes where tabs should = 2 spaces augroup languages
augroup half_tab autocmd!
autocmd! "shell
autocmd FileType html,javascript,css,json,yaml,sh autocmd BufNewFile,BufRead *bash* set syntax=sh
\ setlocal ts=2 sts=2 sw=2 expandtab "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 augroup END