diff options
author | Jerko Steiner <jerko.steiner@gmail.com> | 2019-01-05 19:12:55 +0000 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-01-05 19:12:55 +0000 |
commit | 5bbe77101db18968fde65210956e54750d7ff4f5 (patch) | |
tree | 4ed96d074f286b16c00df3712a7c7f243d47f9ab /ale_linters | |
parent | 4f3190daa88583523df89d4cb7add1584e0e9b7d (diff) | |
download | ale-5bbe77101db18968fde65210956e54750d7ff4f5.zip |
Add support for bingo (#2165)
* Add support for https://github.com/saibing/bingo
* Add docs for ale-go-bingo
* Use go.mod when found
* Add test for bingo FindProjectRoot
* Simplify ale_linters#go#bingo#GetCommand
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/go/bingo.vim | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ale_linters/go/bingo.vim b/ale_linters/go/bingo.vim new file mode 100644 index 00000000..ba80fbe8 --- /dev/null +++ b/ale_linters/go/bingo.vim @@ -0,0 +1,29 @@ +" Author: Jerko Steiner <https://github.com/jeremija> +" Description: https://github.com/saibing/bingo + +call ale#Set('go_bingo_executable', 'bingo') +call ale#Set('go_bingo_options', '--mode stdio') + +function! ale_linters#go#bingo#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options')) +endfunction + +function! ale_linters#go#bingo#FindProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'go.mod') + let l:mods = ':h' + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + let l:mods = ':h:h' + endif + + return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : '' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'bingo', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('go_bingo_executable'), +\ 'command_callback': 'ale_linters#go#bingo#GetCommand', +\ 'project_root_callback': 'ale_linters#go#bingo#FindProjectRoot', +\}) |