最近のC言語に関するVimシンタックスチェック状況

以下の記事で紹介したC言語シンタックスチェックの方法について、続報。

note103.hateblo.jp

その段階では、このように記述していたのだけど。

Plug 'rhysd/vim-clang-format'

let g:clang_format#code_style = 'WebKit'
let g:clang_format#style_options = {
            \ "AccessModifierOffset" : -4,
            \ "AllowShortIfStatementsOnASingleLine" : "true",
            \ "AlwaysBreakTemplateDeclarations" : "true",
            \ "Standard" : "C++11",
            \ "BreakBeforeBraces" : "Stroustrup",
            \ }

nnoremap <Leader>ct :ClangFormat<CR>

現在はこのような感じになっている。

Plug 'rhysd/vim-clang-format'

let g:clang_format#code_style = 'LLVM'
let g:clang_format#style_options = {
            \ "AccessModifierOffset" : -4,
            \ "AllowShortIfStatementsOnASingleLine" : "true",
            \ "AlwaysBreakTemplateDeclarations" : "true",
            \ "Standard" : "C++11",
            \ "BreakBeforeBraces" : "Stroustrup",
            \ }

nnoremap <Leader>ct :ClangFormatAutoToggle<CR>

差分。

-let g:clang_format#code_style = 'WebKit'
+let g:clang_format#code_style = 'LLVM'

-nnoremap <Leader>ct :ClangFormat<CR>
+nnoremap <Leader>ct :ClangFormatAutoToggle<CR>

どうやら今参考にしている本の書式は、WebKit の方ではなく LLVM というものが近いみたいだったので、それに変更。

それから、:ClangFormat というのはわざわざ打たなくても保存するたびに勝手に整形してくれるので&逆にそれがけっこう煩わしくなるケースもあって、一時的にチェックを解除できるようにオン・オフのトグルを使えるようにした。

これでまた一つ恒常的な学習を行える環境に近づけた。