ats-vim/ftplugin/ats.vim

60 lines
1.2 KiB
VimL
Raw Normal View History

2017-12-23 15:28:24 -05:00
if exists('b:ats_ftplugin')
finish
endif
let b:ats_ftplugin = 1
2017-12-23 20:52:41 -05:00
if !exists('g:ats_use_ctags')
let g:ats_use_ctags = 0
endif
2017-12-23 16:28:28 -05:00
" set config values
2017-12-23 15:28:24 -05:00
if !exists('g:ats_autoformat')
2017-12-23 15:57:59 -05:00
if executable('atsfmt') == 1
let g:ats_autoformat = 1
else
let g:ats_autoformat = 0
endif
2017-12-23 15:28:24 -05:00
endif
2017-12-23 16:28:28 -05:00
" indentation rules
2017-12-23 15:28:24 -05:00
set smarttab
au BufNewFile,BufRead *.*ats
\ set shiftwidth=2
2017-12-23 16:28:28 -05:00
" set comment string to something prettier
2017-12-23 15:28:24 -05:00
setlocal commentstring=(*\ %s\ *)
2017-12-23 16:40:09 -05:00
" use patscc as a checker
let g:syntastic_ats_checkers = [ 'patscc' ]
2017-12-23 16:28:28 -05:00
" function to format our buffer
2017-12-23 15:28:24 -05:00
function! AtsFormat()
2017-12-23 15:54:08 -05:00
let cursor = getpos('.')
2017-12-23 15:28:24 -05:00
exec 'normal! gg'
exec 'silent !atsfmt -i ' . expand('%')
exec 'e'
2017-12-23 15:54:08 -05:00
call setpos('.', cursor)
2017-12-23 15:28:24 -05:00
endfunction
2017-12-23 20:52:41 -05:00
augroup ats
autocmd BufWritePost *.ats,*.dats,*.sats,*.cats silent !rm -f a.out
augroup END
if g:ats_use_ctags == 1
augroup ats
autocmd BufWritePost *.dats,*.cats,*.sats,*.hats silent !ctags -R .
augroup END
endif
2017-12-23 16:28:28 -05:00
" format on write
2017-12-23 15:28:24 -05:00
if g:ats_autoformat == 1
augroup ats
2017-12-23 20:52:41 -05:00
autocmd BufWritePost *.ats,*.dats,*.sats,*.cats call AtsFormat()
2017-12-23 15:28:24 -05:00
augroup END
endif
2017-12-23 16:28:28 -05:00
" commands
2017-12-23 15:50:03 -05:00
command -nargs=0 Format call AtsFormat()
2017-12-23 17:24:07 -05:00
map <Plug>Clear :SyntasticReset<CR>