[cfe-commits] [PATCH] New clang-check vim integration script

Nico Weber thakis at chromium.org
Tue Sep 4 07:38:07 PDT 2012


On Tue, Sep 4, 2012 at 7:34 AM, Alexander Kornienko <
reviews at llvm-reviews.chandlerc.com> wrote:

>   Articles, articles. I want to write my articles...
>
> Hi klimek,
>
> http://llvm-reviews.chandlerc.com/D35
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D35?vs=93&id=94#toc
>
> Files:
>   tools/clang/docs/HowToSetupToolingForLLVM.html
>
> Index: tools/clang/docs/HowToSetupToolingForLLVM.html
> ===================================================================
> --- tools/clang/docs/HowToSetupToolingForLLVM.html
> +++ tools/clang/docs/HowToSetupToolingForLLVM.html
> @@ -77,12 +77,37 @@
>  <p>If you're using vim, it's convenient to have clang-check integrated.
> Put this
>  into your .vimrc:</p>
>  <pre>
> -  set makeprg=clang-check\ %
> -  map <F5> :make<CR><CR>
> -</pre>
> -
> -<p>When editing C++ code, hit F5 to reparse the current buffer. The
> output will
> -go into the error window, which you can enable with
> <code>:cope</code>.</p>
> +function! ClangCheckImpl(cmd)
> +  echo "Running " . a:cmd
>

Remove.


> +  let l:output = system(a:cmd)
> +  cexpr l:output
> +  cwindow
>
+  let w:quickfix_title = a:cmd
> +  if v:shell_error != 0
> +    cc
> +  endif
>

Replace all that with

  let l:oldmakepgr = &makeprg
  let &makeprg = a:cmd
  silent make | cwindow
  let &makeprg = l:oldmakepgr

(Gives you a warning when trying to compile a modified buffer too)

>

> +  let g:clang_check_last_cmd = a:cmd
> +endfunction
> +
> +function! ClangCheck()
> +  let l:filename = expand('%')
> +  if l:filename =~ '\.\(cpp\|cxx\|cc\|c\)$'
> +    call ClangCheckImpl("clang-check " . l:filename)
> +  elseif exists("g:clang_check_last_cmd")
> +    call ClangCheckImpl(g:clang_check_last_cmd)
> +  else
> +    echo "Can't detect file's compilation arguments and no previous
> clang-check invocation!"
> +  endif
> +endfunction
> +
> +nmap <silent> <F5> :call ClangCheck()<CR><CR>
> +</pre>
> +
> +<p>When editing a .cpp/.cxx/.cc/.c file, hit F5 to reparse the file. In
> case
> +the current file has a different extension (for example, .h), F5 will
> re-run
> +the last clang-check invocation made from this vim instance (if any). The
> +output will go into the error window, which is opened automatically when
> +clang-check finds errors, and can be re-opened with
> <code>:cope</code>.</p>
>
>  <p>Other <code>clang-check</code> options that can be useful when working
> with
>  clang AST:</p>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120904/6f1d2679/attachment.html>


More information about the cfe-commits mailing list