ats-vim/ftplugin/ats.vim

35 lines
677 B
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
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
set smarttab
au BufNewFile,BufRead *.*ats
\ set shiftwidth=2
setlocal commentstring=(*\ %s\ *)
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
if g:ats_autoformat == 1
augroup ats
autocmd BufWritePost *.ats,*.dats,*.sats,*.cats call AtsFormat()
augroup END
endif
2017-12-23 15:50:03 -05:00
command -nargs=0 Format call AtsFormat()