Skip to content

Commit

Permalink
show error when executable not found on :CrystalFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 17, 2020
1 parent f87af4e commit 580627a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions autoload/crystal_lang.vim
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,17 @@ endfunction

" crystal_lang#format(option_str [, on_save])
function! crystal_lang#format(option_str, ...) abort
let on_save = a:0 > 0 ? a:1 : 0

if !executable(g:crystal_compiler_command)
" Finish command silently
return
if on_save
" Finish command silently on save
return
else
throw 'vim-crystal: Command for formatting is not executable: ' . g:crystal_compiler_command
endif
endif

let on_save = a:0 > 0 ? a:1 : 0

let before = join(getline(1, '$'), "\n")
let formatted = crystal_lang#format_string(before, a:option_str)
if !on_save
Expand Down

0 comments on commit 580627a

Please sign in to comment.