From af6470c8d02067a1d6ec346ac6e277c86224b9e5 Mon Sep 17 00:00:00 2001 From: Qusic Date: Sat, 20 May 2017 00:41:57 +0800 Subject: [PATCH] add clang for objc and objcpp --- README.md | 2 ++ ale_linters/objc/clang.vim | 23 +++++++++++++++++++++++ ale_linters/objcpp/clang.vim | 23 +++++++++++++++++++++++ doc/ale-objc.txt | 17 +++++++++++++++++ doc/ale-objcpp.txt | 17 +++++++++++++++++ doc/ale.txt | 6 ++++++ 6 files changed, 88 insertions(+) create mode 100644 ale_linters/objc/clang.vim create mode 100644 ale_linters/objcpp/clang.vim create mode 100644 doc/ale-objc.txt create mode 100644 doc/ale-objcpp.txt diff --git a/README.md b/README.md index f0b382b..cc9671b 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ name. That seems to be the fairest way to arrange this table. | Nim | [nim](https://nim-lang.org/docs/nimc.html) | | nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) | | nroff | [proselint](http://proselint.com/)| +| Objective-C | [clang](http://clang.llvm.org/) | +| Objective-C++ | [clang](http://clang.llvm.org/) | | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-ocaml-merlin` for configuration instructions | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | | PHP | [hack](http://hacklang.org/), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org) | diff --git a/ale_linters/objc/clang.vim b/ale_linters/objc/clang.vim new file mode 100644 index 0000000..f4725a0 --- /dev/null +++ b/ale_linters/objc/clang.vim @@ -0,0 +1,23 @@ +" Author: Bang Lee +" Description: clang linter for objc files + +" Set this option to change the Clang options for warnings for ObjC. +if !exists('g:ale_objc_clang_options') + let g:ale_objc_clang_options = '-std=c11 -Wall' +endif + +function! ale_linters#objc#clang#GetCommand(buffer) abort + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + return 'clang -S -x objective-c -fsyntax-only ' + \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' ' . ale#Var(a:buffer, 'objc_clang_options') . ' -' +endfunction + +call ale#linter#Define('objc', { +\ 'name': 'clang', +\ 'output_stream': 'stderr', +\ 'executable': 'clang', +\ 'command_callback': 'ale_linters#objc#clang#GetCommand', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\}) diff --git a/ale_linters/objcpp/clang.vim b/ale_linters/objcpp/clang.vim new file mode 100644 index 0000000..0e9cefe --- /dev/null +++ b/ale_linters/objcpp/clang.vim @@ -0,0 +1,23 @@ +" Author: Bang Lee +" Description: clang linter for objcpp files + +" Set this option to change the Clang options for warnings for ObjCPP. +if !exists('g:ale_objcpp_clang_options') + let g:ale_objcpp_clang_options = '-std=c++14 -Wall' +endif + +function! ale_linters#objcpp#clang#GetCommand(buffer) abort + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + return 'clang++ -S -x objective-c++ -fsyntax-only ' + \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' ' . ale#Var(a:buffer, 'objcpp_clang_options') . ' -' +endfunction + +call ale#linter#Define('objcpp', { +\ 'name': 'clang', +\ 'output_stream': 'stderr', +\ 'executable': 'clang++', +\ 'command_callback': 'ale_linters#objcpp#clang#GetCommand', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\}) diff --git a/doc/ale-objc.txt b/doc/ale-objc.txt new file mode 100644 index 0000000..2e1c734 --- /dev/null +++ b/doc/ale-objc.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE Objective-C Integration *ale-objc-options* + + +------------------------------------------------------------------------------- +clang *ale-objc-clang* + +g:ale_objc_clang_options *g:ale_objc_clang_options* + *b:ale_objc_clang_options* + Type: |String| + Default: `'-std=c11 -Wall'` + + This variable can be changed to modify flags given to clang. + + +------------------------------------------------------------------------------- + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-objcpp.txt b/doc/ale-objcpp.txt new file mode 100644 index 0000000..3a2eb26 --- /dev/null +++ b/doc/ale-objcpp.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE Objective-C++ Integration *ale-objcpp-options* + + +------------------------------------------------------------------------------- +clang *ale-objcpp-clang* + +g:ale_objcpp_clang_options *g:ale_objcpp_clang_options* + *b:ale_objcpp_clang_options* + Type: |String| + Default: `'-std=c++14 -Wall'` + + This variable can be changed to modify flags given to clang. + + +------------------------------------------------------------------------------- + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 615fa27..74368c9 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -52,6 +52,10 @@ CONTENTS *ale-contents* kotlinc.............................|ale-kotlin-kotlinc| lua...................................|ale-lua-options| luacheck............................|ale-lua-luacheck| + objc..................................|ale-objc-options| + clang...............................|ale-objc-clang| + objcpp................................|ale-objcpp-options| + clang...............................|ale-objcpp-clang| ocaml.................................|ale-ocaml-options| merlin..............................|ale-ocaml-merlin| perl..................................|ale-perl-options| @@ -153,6 +157,8 @@ The following languages and tools are supported. * nim: 'nim check' * nix: 'nix-instantiate' * nroff: 'proselint' +* Objective-C: 'clang' +* Objective-C++: 'clang' * OCaml: 'merlin' (see |ale-linter-integration-ocaml-merlin|) * Perl: 'perl' (-c flag), 'perlcritic' * PHP: 'hack', 'php' (-l flag), 'phpcs', 'phpmd'