Skip to content

Commit 2c4db71

Browse files
committed
Merge pull request #35 from mgrundy/master
Issue #23 javascript support
2 parents ae2e48a + 6077eb8 commit 2c4db71

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

autoload/clang_format.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function! clang_format#format(line1, line2)
158158
else
159159
let args .= " -style=file "
160160
endif
161+
let args .= printf("-assume-filename=%s", shellescape(expand('%:p')))
161162
let args .= g:clang_format#extra_args
162163
let clang_format = printf("%s %s --", g:clang_format#command, args)
163164
return s:system(clang_format, join(getline(1, '$'), "\n"))

plugin/clang_format.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ command! -range=% -nargs=0 ClangFormatEchoFormattedCode echo clang_format#format
1414

1515
augroup plugin-clang-format-auto-format
1616
autocmd!
17-
autocmd BufWritePre * if &ft =~# '^\%(c\|cpp\|objc\)$' && g:clang_format#auto_format && !clang_format#is_invalid() | call clang_format#replace(1, line('$')) | endif
18-
autocmd FileType c,cpp,objc if g:clang_format#auto_format_on_insert_leave && !clang_format#is_invalid() | call clang_format#enable_format_on_insert() | endif
19-
autocmd FileType c,cpp,objc if g:clang_format#auto_formatexpr && !clang_format#is_invalid() | setlocal formatexpr=clang_format#replace(v:lnum,v:lnum+v:count-1) | endif
17+
autocmd BufWritePre * if &ft =~# '^\%(c\|cpp\|objc\|javascript\)$' && g:clang_format#auto_format && !clang_format#is_invalid() | call clang_format#replace(1, line('$')) | endif
18+
autocmd FileType c,cpp,objc,javascript if g:clang_format#auto_format_on_insert_leave && !clang_format#is_invalid() | call clang_format#enable_format_on_insert() | endif
19+
autocmd FileType c,cpp,objc,javascript if g:clang_format#auto_formatexpr && !clang_format#is_invalid() | setlocal formatexpr=clang_format#replace(v:lnum,v:lnum+v:count-1) | endif
2020
augroup END
2121

2222
command! ClangFormatAutoToggle call clang_format#toggle_auto_format()

0 commit comments

Comments
 (0)