diff --git a/README.md b/README.md index 1e5a725..69e4f43 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,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 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) !! | +| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [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) !! | | GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) | | Haml | [haml-lint](https://github.com/brigade/haml-lint) | | Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) | diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim index 731f4c9..13055a8 100644 --- a/ale_linters/go/gotype.vim +++ b/ale_linters/go/gotype.vim @@ -1,23 +1,19 @@ " Author: Jelte Fennema " Description: gotype for Go files +function! ale_linters#go#gotype#GetCommand(buffer) abort + if expand('#' . a:buffer . ':p') =~# '_test\.go$' + return + endif + + return 'gotype %s' +endfunction + call ale#linter#Define('go', { \ 'name': 'gotype', \ 'output_stream': 'stderr', \ 'executable': 'gotype', \ 'command_callback': 'ale_linters#go#gotype#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsError', +\ 'lint_file': 1, \}) - -"\ 'command': -function! ale_linters#go#gotype#GetCommand(buffer) abort - let l:cur_file = expand('#' . a:buffer . ':p') - if l:cur_file =~# '_test\.go$' - return - endif - - let l:module_files = globpath(expand('#' . a:buffer . ':p:h'), '*.go', 0, 1) - let l:other_module_files = filter(l:module_files, 'v:val isnot# ' . ale#util#EscapeVim(l:cur_file) . ' && v:val !~# "_test\.go$"') - return 'gotype %t ' . join(map(l:other_module_files, 'ale#Escape(v:val)')) - -endfunction diff --git a/doc/ale.txt b/doc/ale.txt index b16528f..b9ac087 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -327,7 +327,7 @@ Notes: * FusionScript: `fusion-lint` * Git Commit Messages: `gitlint` * GLSL: glslang, `glslls` -* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!! +* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!! * GraphQL: `eslint`, `gqlint`, `prettier` * Haml: `haml-lint` * Handlebars: `ember-template-lint` diff --git a/test/command_callback/test_gotype_command_callback.vader b/test/command_callback/test_gotype_command_callback.vader index f95e842..ec98627 100644 --- a/test/command_callback/test_gotype_command_callback.vader +++ b/test/command_callback/test_gotype_command_callback.vader @@ -5,15 +5,9 @@ Before: After: call ale#linter#Reset() - -Execute(The gotype callback should include other files from the directory but exclude the file itself): - let dir = expand('#' . bufnr('') . ':p:h') - AssertEqual - \ "gotype %t ". ale#Escape(ale#path#Simplify(dir . "/testfile.go")), - \ ale_linters#go#gotype#GetCommand(bufnr('')) +Execute(The default gotype command should be correct): + AssertEqual 'gotype %s', ale_linters#go#gotype#GetCommand(bufnr('')) Execute(The gotype callback should ignore test files): call ale#test#SetFilename('bla_test.go') - AssertEqual - \ 0, - \ ale_linters#go#gotype#GetCommand(bufnr('')) + AssertEqual 0, ale_linters#go#gotype#GetCommand(bufnr(''))