if has_key(g:polyglot_is_disabled, 'crystal') finish endif if exists('b:did_ftplugin') finish endif let b:did_ftplugin = 1 setlocal comments=:# setlocal commentstring=#\ %s setlocal suffixesadd=.cr " Set format for quickfix window setlocal errorformat= \%ESyntax\ error\ in\ line\ %l:\ %m, \%ESyntax\ error\ in\ %f:%l:\ %m, \%EError\ in\ %f:%l:\ %m, \%C%p^, \%-C%.%# let g:crystal_compiler_command = get(g:, 'crystal_compiler_command', 'crystal') let g:crystal_auto_format = get(g:, 'crystal_auto_format', 0) command! -buffer -nargs=* CrystalImpl echo crystal_lang#impl(expand('%'), getpos('.'), ).output command! -buffer -nargs=0 CrystalDef call crystal_lang#jump_to_definition(expand('%'), getpos('.')) command! -buffer -nargs=* CrystalContext echo crystal_lang#context(expand('%'), getpos('.'), ).output command! -buffer -nargs=* CrystalHierarchy echo crystal_lang#type_hierarchy(expand('%'), ) command! -buffer -nargs=? CrystalSpecSwitch call crystal_lang#switch_spec_file() command! -buffer -nargs=? CrystalSpecRunAll call crystal_lang#run_all_spec() command! -buffer -nargs=? CrystalSpecRunCurrent call crystal_lang#run_current_spec() command! -buffer -nargs=* -bar CrystalFormat call crystal_lang#format(, 0) command! -buffer -nargs=* CrystalExpand echo crystal_lang#expand(expand('%'), getpos('.'), ).output nnoremap (crystal-jump-to-definition) :CrystalDef nnoremap (crystal-show-context) :CrystalContext nnoremap (crystal-spec-switch) :CrystalSpecSwitch nnoremap (crystal-spec-run-all) :CrystalSpecRunAll nnoremap (crystal-spec-run-current) :CrystalSpecRunCurrent nnoremap (crystal-format) :CrystalFormat " autocmd is setup per buffer. Please do not use :autocmd!. It refreshes " augroup hence removes autocmds for other buffers (#105) augroup plugin-ft-crystal autocmd BufWritePre if g:crystal_auto_format && &filetype ==# 'crystal' | call crystal_lang#format('', 1) | endif augroup END if get(g:, 'crystal_define_mappings', 1) nmap gd (crystal-jump-to-definition) nmap gc (crystal-show-context) nmap gss (crystal-spec-switch) nmap gsa (crystal-spec-run-all) nmap gsc (crystal-spec-run-current) endif if &l:ofu ==# '' setlocal omnifunc=crystal_lang#complete endif " Options for vim-matchit if exists('g:loaded_matchit') && !exists('b:match_words') let b:match_ignorecase = 0 let b:match_words = \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|struct\|lib\|macro\|ifdef\|def\|begin\|enum\|annotation\)\>=\@!' . \ ':' . \ '\<\%(else\|elsif\|ensure\|when\|in\|rescue\|break\|next\)\>' . \ ':' . \ '\' . \ ',{:},\[:\],(:)' let b:match_skip = \ 'synIDattr(synID(line("."), col("."), 0), "name") =~# ''' . \ '\''' endif " Options for jiangmiao/auto-pairs if exists('g:AutoPairsLoaded') let b:AutoPairs = { '{%': '%}' } call extend(b:AutoPairs, g:AutoPairs, 'force') endif " vim: sw=2 sts=2 et: