diff options
author | Jeff Willette <jrwillette88@gmail.com> | 2017-11-10 18:37:23 +0900 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-11-10 09:37:23 +0000 |
commit | 27780cbb230fad55fbc07752febe5c21a69a18aa (patch) | |
tree | 3a88b32c4ba2d3b3c12efbfe10c61ed90e869c8b | |
parent | d425b8a18ab3c8155fdc7376192434f8878e954f (diff) | |
download | ale-27780cbb230fad55fbc07752febe5c21a69a18aa.zip |
Added support for linting of proto files (#1098)
* Added support for linting of proto files
* Added function to get the proper protoc command
-rw-r--r-- | ale_linters/proto/protoc_gen_lint.vim | 19 | ||||
-rw-r--r-- | doc/ale-proto.txt | 24 | ||||
-rw-r--r-- | doc/ale.txt | 2 | ||||
-rw-r--r-- | test/command_callback/test_proto_command_callback.vader | 16 |
4 files changed, 61 insertions, 0 deletions
diff --git a/ale_linters/proto/protoc_gen_lint.vim b/ale_linters/proto/protoc_gen_lint.vim new file mode 100644 index 00000000..9d5ceacc --- /dev/null +++ b/ale_linters/proto/protoc_gen_lint.vim @@ -0,0 +1,19 @@ +" Author: Jeff Willette <jrwillette88@gmail.com> +" Description: run the protoc-gen-lint plugin for the protoc binary + +function! ale_linters#proto#protoc_gen_lint#GetCommand(buffer) abort + let l:dirname = expand('#' . a:buffer . ':p:h') + + return 'protoc' + \ . ' -I ' . ale#Escape(l:dirname) + \ . ' --lint_out=. ' . '%s' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'protoc-gen-lint', +\ 'lint_file': 1, +\ 'output_stream': 'stderr', +\ 'executable': 'protoc', +\ 'command_callback': 'ale_linters#proto#protoc_gen_lint#GetCommand', +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) diff --git a/doc/ale-proto.txt b/doc/ale-proto.txt new file mode 100644 index 00000000..6a256380 --- /dev/null +++ b/doc/ale-proto.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Proto Integration *ale-proto-options* + + +=============================================================================== +Integration Information + +Linting of `.proto` files requires that the `protoc` binary is installed in the +system path and that the `protoc-gen-lint` plugin for the `protoc` binary is also +installed. + +To enable `.proto` file linting, update |g:ale_linters| as appropriate: +> + " Enable linter for .proto files + let g:ale_linters = {'proto': ['protoc-gen-lint']} +< +=============================================================================== +protoc-gen-lint *ale-proto-protoc-gen-lint* + + The linter is a plugin for the `protoc` binary. As long as the binary resides + in the system path, `protoc` will find it. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 2ee2c2d7..a0aa9c83 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -134,6 +134,8 @@ CONTENTS *ale-contents* phpstan.............................|ale-php-phpstan| pod...................................|ale-pod-options| write-good..........................|ale-pod-write-good| + proto.................................|ale-proto-options| + protoc-gen-lint.....................|ale-proto-protoc-gen-lint| pug...................................|ale-pug-options| puglint.............................|ale-pug-puglint| puppet................................|ale-puppet-options| diff --git a/test/command_callback/test_proto_command_callback.vader b/test/command_callback/test_proto_command_callback.vader new file mode 100644 index 00000000..2730bb84 --- /dev/null +++ b/test/command_callback/test_proto_command_callback.vader @@ -0,0 +1,16 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('test.proto') + +After: + Restore + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The default command should be correct): + + AssertEqual + \ 'protoc' . ' -I ' . ale#Escape(getcwd()) . ' --lint_out=. ' . '%s', + \ ale_linters#proto#protoc_gen_lint#GetCommand(bufnr('')) + |