diff --git a/README.md b/README.md index dbc8652c..bdde278f 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ formatting. | Awk | [gawk](https://www.gnu.org/software/gawk/)| | Bash | [language-server](https://github.com/mads-hartmann/bash-language-server), shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) | | Bourne Shell | shell [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) | -| C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [cquery](https://github.com/cquery-project/cquery), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/), [uncrustify](https://github.com/uncrustify/uncrustify) | -| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [clazy](https://github.com/KDE/clazy) !!, [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [cquery](https://github.com/cquery-project/cquery), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/), [uncrustify](https://github.com/uncrustify/uncrustify) | +| C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [cquery](https://github.com/cquery-project/cquery), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/), [uncrustify](https://github.com/uncrustify/uncrustify), [ccls](https://github.com/MaskRay/ccls) | +| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [clazy](https://github.com/KDE/clazy) !!, [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [cquery](https://github.com/cquery-project/cquery), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/), [uncrustify](https://github.com/uncrustify/uncrustify), [ccls](https://github.com/MaskRay/ccls) | | CUDA | [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) | | C# | [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details, [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) !! see:`help ale-cs-mcsc` for details and configuration, [uncrustify](https://github.com/uncrustify/uncrustify) | | Chef | [foodcritic](http://www.foodcritic.io/) | @@ -150,7 +150,7 @@ formatting. | Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! | | nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) | | nroff | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good)| -| Objective-C | [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [uncrustify](https://github.com/uncrustify/uncrustify) | +| Objective-C | [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [uncrustify](https://github.com/uncrustify/uncrustify), [ccls](https://github.com/MaskRay/ccls) | | Objective-C++ | [clang](http://clang.llvm.org/), [clangd](https://clang.llvm.org/extra/clangd.html), [uncrustify](https://github.com/uncrustify/uncrustify) | | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) | | Pawn | [uncrustify](https://github.com/uncrustify/uncrustify) | diff --git a/ale_linters/c/ccls.vim b/ale_linters/c/ccls.vim new file mode 100644 index 00000000..5dc2339f --- /dev/null +++ b/ale_linters/c/ccls.vim @@ -0,0 +1,14 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for C + +call ale#Set('c_ccls_executable', 'ccls') +call ale#Set('c_ccls_init_options', {}) + +call ale#linter#Define('c', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('c_ccls_executable'), +\ 'command': '%e', +\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', +\ 'initialization_options_callback':ale#VarFunc('c_ccls_init_options'), +\}) diff --git a/ale_linters/cpp/ccls.vim b/ale_linters/cpp/ccls.vim new file mode 100644 index 00000000..501fd685 --- /dev/null +++ b/ale_linters/cpp/ccls.vim @@ -0,0 +1,14 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for C++ + +call ale#Set('cpp_ccls_executable', 'ccls') +call ale#Set('cpp_ccls_init_options', {}) + +call ale#linter#Define('cpp', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('cpp_ccls_executable'), +\ 'command': '%e', +\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', +\ 'initialization_options_callback': ale#VarFunc('cpp_ccls_init_options'), +\}) diff --git a/ale_linters/objc/ccls.vim b/ale_linters/objc/ccls.vim new file mode 100644 index 00000000..0aa6a5e5 --- /dev/null +++ b/ale_linters/objc/ccls.vim @@ -0,0 +1,14 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for Objective-C + +call ale#Set('objc_ccls_executable', 'ccls') +call ale#Set('objc_ccls_init_options', {}) + +call ale#linter#Define('objc', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('objc_ccls_executable'), +\ 'command': '%e', +\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', +\ 'initialization_options_callback': ale#VarFunc('objc_ccls_init_options'), +\}) diff --git a/autoload/ale/handlers/ccls.vim b/autoload/ale/handlers/ccls.vim new file mode 100644 index 00000000..29dd6aed --- /dev/null +++ b/autoload/ale/handlers/ccls.vim @@ -0,0 +1,17 @@ +scriptencoding utf-8 +" Author: Ye Jingchen +" Description: Utilities for ccls + +function! ale#handlers#ccls#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls-root') + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + endif + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestFile(a:buffer, '.ccls') + endif + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction diff --git a/doc/ale-c.txt b/doc/ale-c.txt index c3820ba0..2a2a879e 100644 --- a/doc/ale-c.txt +++ b/doc/ale-c.txt @@ -281,5 +281,36 @@ g:ale_c_uncrustify_options *g:ale_c_uncrustify_options* This variable can be change to modify flags given to uncrustify. +=============================================================================== +ccls *ale-c-ccls* + +g:ale_c_ccls_executable *g:ale_c_ccls_executable* + *b:ale_c_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* + *b:ale_c_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-cpp.txt b/doc/ale-cpp.txt index 6c05c96d..47ba2c70 100644 --- a/doc/ale-cpp.txt +++ b/doc/ale-cpp.txt @@ -279,5 +279,36 @@ uncrustify *ale-cpp-uncrustify* See |ale-c-uncrustify| for information about the available options. +=============================================================================== +ccls *ale-cpp-ccls* + +g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* + *b:ale_cpp_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* + *b:ale_cpp_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-objc.txt b/doc/ale-objc.txt index 2d560267..0163175a 100644 --- a/doc/ale-objc.txt +++ b/doc/ale-objc.txt @@ -38,5 +38,36 @@ uncrustify *ale-objc-uncrustify* See |ale-c-uncrustify| for information about the available options. +=============================================================================== +ccls *ale-objc-ccls* + +g:ale_objc_ccls_executable *g:ale_objc_ccls_executable* + *b:ale_objc_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_objc_ccls_init_options *g:ale_objc_ccls_init_options* + *b:ale_objc_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 1cf2945f..ec44f3b8 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -34,6 +34,7 @@ CONTENTS *ale-contents* flawfinder..........................|ale-c-flawfinder| gcc.................................|ale-c-gcc| uncrustify..........................|ale-c-uncrustify| + ccls................................|ale-c-ccls| chef..................................|ale-chef-options| foodcritic..........................|ale-chef-foodcritic| clojure...............................|ale-clojure-options| @@ -55,6 +56,7 @@ CONTENTS *ale-contents* flawfinder..........................|ale-cpp-flawfinder| gcc.................................|ale-cpp-gcc| uncrustify..........................|ale-cpp-uncrustify| + ccls................................|ale-cpp-ccls| c#....................................|ale-cs-options| mcs.................................|ale-cs-mcs| mcsc................................|ale-cs-mcsc| @@ -185,6 +187,7 @@ CONTENTS *ale-contents* clang...............................|ale-objc-clang| clangd..............................|ale-objc-clangd| uncrustify..........................|ale-objc-uncrustify| + ccls................................|ale-objc-ccls| objcpp................................|ale-objcpp-options| clang...............................|ale-objcpp-clang| clangd..............................|ale-objcpp-clangd| @@ -376,8 +379,8 @@ Notes: * Awk: `gawk` * Bash: `language-server`, `shell` (-n flag), `shellcheck`, `shfmt` * Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` -* C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc`, `uncrustify` -* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc`, `uncrustify` +* C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` +* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` * CUDA: `nvcc`!! * C#: `mcs`, `mcsc`!!, `uncrustify` * Chef: `foodcritic` @@ -429,7 +432,7 @@ Notes: * Nim: `nim check`!! * nix: `nix-instantiate` * nroff: `alex`!!, `proselint`, `write-good` -* Objective-C: `clang`, `clangd`, `uncrustify` +* Objective-C: `clang`, `clangd`, `uncrustify`, `ccls` * Objective-C++: `clang`, `clangd`, `uncrustify` * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`, `ocamlformat` * Pawn: `uncrustify` diff --git a/test/command_callback/ccls_paths/with_ccls-root/.ccls-root b/test/command_callback/ccls_paths/with_ccls-root/.ccls-root new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/ccls_paths/with_ccls/.ccls b/test/command_callback/ccls_paths/with_ccls/.ccls new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json b/test/command_callback/ccls_paths/with_compile_commands_json/compile_commands.json new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/test_c_ccls_command_callbacks.vader b/test/command_callback/test_c_ccls_command_callbacks.vader new file mode 100644 index 00000000..b8f3ab5b --- /dev/null +++ b/test/command_callback/test_c_ccls_command_callbacks.vader @@ -0,0 +1,43 @@ +" Author: Ye Jingchen , Ben Falconer +" Description: A language server for C + +Before: + call ale#assert#SetUpLinterTest('c', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.c') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_c_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_c_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } diff --git a/test/command_callback/test_cpp_ccls_command_callbacks.vader b/test/command_callback/test_cpp_ccls_command_callbacks.vader new file mode 100644 index 00000000..38947acf --- /dev/null +++ b/test/command_callback/test_cpp_ccls_command_callbacks.vader @@ -0,0 +1,43 @@ +" Author: Ye Jingchen , Ben Falconer +" Description: A language server for C++ + +Before: + call ale#assert#SetUpLinterTest('cpp', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.cpp') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_cpp_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_cpp_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' } diff --git a/test/command_callback/test_objc_ccls_command_callbacks.vader b/test/command_callback/test_objc_ccls_command_callbacks.vader new file mode 100644 index 00000000..9d0c7690 --- /dev/null +++ b/test/command_callback/test_objc_ccls_command_callbacks.vader @@ -0,0 +1,40 @@ +Before: + call ale#assert#SetUpLinterTest('objc', 'ccls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The project root should be detected correctly using compile_commands.json file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_compile_commands_json/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_compile_commands_json') + +Execute(The project root should be detected correctly using .ccls file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls') + +Execute(The project root should be detected correctly using .ccls-root file): + AssertLSPProject '' + + call ale#test#SetFilename('ccls_paths/with_ccls-root/dummy.m') + + AssertLSPProject ale#path#Simplify(g:dir . '/ccls_paths/with_ccls-root') + +Execute(The executable should be configurable): + AssertLinter 'ccls', ale#Escape('ccls') + + let b:ale_objc_ccls_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + +Execute(The initialization options should be configurable): + AssertLSPOptions {} + + let b:ale_objc_ccls_init_options = { 'cacheDirectory': '/tmp/ccls' } + + AssertLSPOptions { 'cacheDirectory': '/tmp/ccls' }