summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--ale_linters/go/bingo.vim29
-rw-r--r--doc/ale-go.txt18
-rw-r--r--doc/ale.txt3
-rw-r--r--test/command_callback/test_bingo_command_callback.vader31
-rw-r--r--test/test_bingo_find_project_root.vader21
6 files changed, 101 insertions, 3 deletions
diff --git a/README.md b/README.md
index 39d8f501..73217677 100644
--- a/README.md
+++ b/README.md
@@ -133,7 +133,7 @@ formatting.
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
| Git Commit Messages | [gitlint](https://github.com/jorisroovers/gitlint) |
| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
-| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go mod](https://golang.org/cmd/go/) !!, [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !!, [golangserver](https://github.com/sourcegraph/go-langserver), [golangci-lint](https://github.com/golangci/golangci-lint) !! |
+| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go mod](https://golang.org/cmd/go/) !!, [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !!, [golangserver](https://github.com/sourcegraph/go-langserver), [golangci-lint](https://github.com/golangci/golangci-lint) !!, [bingo](https://github.com/saibing/bingo) |
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) |
| Hack | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/hhvm/tree/master/hphp/hack/hackfmt), [hhast](https://github.com/hhvm/hhast) (disabled by default; see `:help ale-integration-hack`) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
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',
+\})
diff --git a/doc/ale-go.txt b/doc/ale-go.txt
index 43289bd5..3fbc6fb9 100644
--- a/doc/ale-go.txt
+++ b/doc/ale-go.txt
@@ -7,7 +7,7 @@ Integration Information
The `gometalinter` linter is disabled by default. ALE enables `gofmt`,
`golint` and `go vet` by default. It also supports `staticcheck`, `go
-build`, `gosimple`, and `golangserver`.
+build`, `gosimple`, `golangserver`.
To enable `gometalinter`, update |g:ale_linters| as appropriate:
>
@@ -196,4 +196,20 @@ g:ale_go_golangci_lint_package *g:ale_go_golangci_lint_package*
===============================================================================
+bingo *ale-go-bingo*
+
+g:ale_go_bingo_executable *g:ale_go_bingo_executable*
+ *b:ale_go_bingo_executable*
+ Type: |String|
+ Default: `'go-bingo'`
+
+ Location of the go-bingo binary file.
+
+g:ale_go_bingo_options *g:ale_go_bingo_options*
+ *b:ale_go_bingo_options*
+ Type: |String|
+ Default: `''`
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 0e658f3c..1cfa7898 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -118,6 +118,7 @@ CONTENTS *ale-contents*
staticcheck.........................|ale-go-staticcheck|
golangserver........................|ale-go-golangserver|
golangci-lint.......................|ale-go-golangci-lint|
+ bingo...............................|ale-go-bingo|
graphql...............................|ale-graphql-options|
eslint..............................|ale-graphql-eslint|
gqlint..............................|ale-graphql-gqlint|
@@ -438,7 +439,7 @@ Notes:
* FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint`
* GLSL: glslang, `glslls`
-* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!
+* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!, `bingo`
* GraphQL: `eslint`, `gqlint`, `prettier`
* Hack: `hack`, `hackfmt`, `hhast`
* Haml: `haml-lint`
diff --git a/test/command_callback/test_bingo_command_callback.vader b/test/command_callback/test_bingo_command_callback.vader
new file mode 100644
index 00000000..fa343bfe
--- /dev/null
+++ b/test/command_callback/test_bingo_command_callback.vader
@@ -0,0 +1,31 @@
+Before:
+ call ale#assert#SetUpLinterTest('go', 'bingo')
+
+After:
+ Restore
+
+ unlet! b:ale_completion_enabled
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(should set correct defaults):
+ AssertLinter 'bingo', ale#Escape('bingo') . ' --mode stdio'
+
+Execute(should configure bingo callback executable):
+ let b:ale_go_bingo_executable = 'boo'
+ let b:ale_go_bingo_options = ''
+
+ AssertLinter 'boo', ale#Escape('boo')
+
+Execute(should set bingo options):
+ call ale#test#SetFilename('go_paths/go1/prj1/file.go')
+ " let b:ale_completion_enabled = 1
+ let b:ale_go_bingo_options = ''
+
+ AssertLinter 'bingo',
+ \ ale#Escape('bingo') . ''
+
+ let b:ale_go_bingo_options = '--mode stdio --trace'
+
+ AssertLinter 'bingo',
+ \ ale#Escape('bingo') . ' --mode stdio --trace'
diff --git a/test/test_bingo_find_project_root.vader b/test/test_bingo_find_project_root.vader
new file mode 100644
index 00000000..540183d0
--- /dev/null
+++ b/test/test_bingo_find_project_root.vader
@@ -0,0 +1,21 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test')
+ runtime ale_linters/go/bingo.vim
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(Should return directory for 'go.mod' if found in parent directory):
+ call ale#test#SetFilename('go_files/test.go')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/go_files'),
+ \ ale_linters#go#bingo#FindProjectRoot(bufnr(''))
+
+Execute(Should return nearest directory with '.git' if found in parent directory):
+ call ale#test#SetFilename('test.go')
+
+ AssertEqual
+ \ fnamemodify(ale#path#Simplify('/testplugin'), ':p:h'),
+ \ ale_linters#go#bingo#FindProjectRoot(bufnr(''))