Merge pull request #1950 from yejingchen/ccls

Add ccls support for C/C++/ObjC
This commit is contained in:
w0rp 2018-09-28 09:02:00 +01:00 committed by GitHub
commit a26b3319a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 287 additions and 6 deletions

View File

@ -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) |

14
ale_linters/c/ccls.vim Normal file
View File

@ -0,0 +1,14 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" 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'),
\})

14
ale_linters/cpp/ccls.vim Normal file
View File

@ -0,0 +1,14 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" 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'),
\})

14
ale_linters/objc/ccls.vim Normal file
View File

@ -0,0 +1,14 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" 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'),
\})

View File

@ -0,0 +1,17 @@
scriptencoding utf-8
" Author: Ye Jingchen <ye.jingchen@gmail.com>
" 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

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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`

View File

@ -0,0 +1,43 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>
" 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' }

View File

@ -0,0 +1,43 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>
" 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' }

View File

@ -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' }