ats-vim/ftplugin/ats.vim

57 lines
1.1 KiB
VimL
Raw Permalink 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
2018-07-23 22:52:44 -04:00
augroup ats
2018-08-23 00:41:32 -04:00
au BufNewFile,BufRead *.*ats setl shiftwidth=2
2018-07-23 22:52:44 -04:00
augroup END
2017-12-23 15:28:24 -05:00
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
if g:ats_use_ctags == 1
augroup ats
2018-08-23 00:41:32 -04:00
autocmd BufWritePost *.dats,*.cats,*.sats,*.hats silent !ctags -R .
2017-12-23 20:52:41 -05:00
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
2018-08-23 00:41:32 -04:00
autocmd BufWritePost *.dats,*.sats,*.hats call AtsFormat()
2017-12-23 15:28:24 -05:00
augroup END
endif
2017-12-23 16:28:28 -05:00
" commands
2018-08-23 00:41:32 -04:00
command! -nargs=0 Format call AtsFormat()
2017-12-23 17:24:07 -05:00
map <Plug>Clear :SyntasticReset<CR>