summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--ale_linters/go/gotype.vim23
-rw-r--r--autoload/ale/debugging.vim25
-rw-r--r--autoload/ale/util.vim7
-rw-r--r--doc/ale.txt2
-rw-r--r--test/command_callback/test_gotype_command_callback.vader19
-rw-r--r--test/go_files/testfile2.go0
-rw-r--r--test/test_ale_info.vader54
8 files changed, 122 insertions, 10 deletions
diff --git a/README.md b/README.md
index c6bf76e4..55be933a 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), [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) |
| 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
new file mode 100644
index 00000000..731f4c92
--- /dev/null
+++ b/ale_linters/go/gotype.vim
@@ -0,0 +1,23 @@
+" Author: Jelte Fennema <github-public@jeltef.nl>
+" Description: gotype for Go files
+
+call ale#linter#Define('go', {
+\ 'name': 'gotype',
+\ 'output_stream': 'stderr',
+\ 'executable': 'gotype',
+\ 'command_callback': 'ale_linters#go#gotype#GetCommand',
+\ 'callback': 'ale#handlers#unix#HandleAsError',
+\})
+
+"\ '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/autoload/ale/debugging.vim b/autoload/ale/debugging.vim
index 9ce69ce8..9be1fbf6 100644
--- a/autoload/ale/debugging.vim
+++ b/autoload/ale/debugging.vim
@@ -2,30 +2,55 @@
" Description: This file implements debugging information for ALE
let s:global_variable_list = [
+\ 'ale_cache_executable_check_failures',
+\ 'ale_change_sign_column_color',
+\ 'ale_command_wrapper',
+\ 'ale_completion_delay',
+\ 'ale_completion_enabled',
+\ 'ale_completion_max_suggestions',
\ 'ale_echo_cursor',
\ 'ale_echo_msg_error_str',
\ 'ale_echo_msg_format',
+\ 'ale_echo_msg_info_str',
\ 'ale_echo_msg_warning_str',
\ 'ale_enabled',
\ 'ale_fix_on_save',
\ 'ale_fixers',
+\ 'ale_history_enabled',
+\ 'ale_history_log_output',
\ 'ale_keep_list_window_open',
\ 'ale_lint_delay',
\ 'ale_lint_on_enter',
+\ 'ale_lint_on_filetype_changed',
\ 'ale_lint_on_save',
\ 'ale_lint_on_text_changed',
+\ 'ale_lint_on_insert_leave',
\ 'ale_linter_aliases',
\ 'ale_linters',
+\ 'ale_linters_explicit',
+\ 'ale_list_window_size',
+\ 'ale_loclist_msg_format',
+\ 'ale_max_buffer_history_size',
+\ 'ale_max_signs',
+\ 'ale_maximum_file_size',
\ 'ale_open_list',
+\ 'ale_pattern_options',
+\ 'ale_pattern_options_enabled',
+\ 'ale_set_balloons',
\ 'ale_set_highlights',
\ 'ale_set_loclist',
\ 'ale_set_quickfix',
\ 'ale_set_signs',
\ 'ale_sign_column_always',
\ 'ale_sign_error',
+\ 'ale_sign_info',
\ 'ale_sign_offset',
+\ 'ale_sign_style_error',
+\ 'ale_sign_style_warning',
\ 'ale_sign_warning',
\ 'ale_statusline_format',
+\ 'ale_type_map',
+\ 'ale_warn_about_trailing_blank_lines',
\ 'ale_warn_about_trailing_whitespace',
\]
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 1f590adc..b94a11b7 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -236,6 +236,13 @@ function! ale#util#EscapePCRE(unsafe_string) abort
return substitute(a:unsafe_string, '\([\-\[\]{}()*+?.^$|]\)', '\\\1', 'g')
endfunction
+" Escape a string so that it can be used as a literal string inside an evaled
+" vim command.
+function! ale#util#EscapeVim(unsafe_string) abort
+ return "'" . substitute(a:unsafe_string, "'", "''", 'g') . "'"
+endfunction
+
+
" Given a String or a List of String values, try and decode the string(s)
" as a JSON value which can be decoded with json_decode. If the JSON string
" is invalid, the default argument value will be returned instead.
diff --git a/doc/ale.txt b/doc/ale.txt
index 53b19b3e..25c1abe0 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -309,7 +309,7 @@ Notes:
* FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint`
* GLSL: glslang, `glslls`
-* Go: `gofmt`, `goimports`, `go vet`, `golint`, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
+* Go: `gofmt`, `goimports`, `go vet`, `golint`, `gotype`, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
* GraphQL: `eslint`, `gqlint`
* 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
new file mode 100644
index 00000000..f95e8423
--- /dev/null
+++ b/test/command_callback/test_gotype_command_callback.vader
@@ -0,0 +1,19 @@
+Before:
+ runtime ale_linters/go/gotype.vim
+ call ale#test#SetFilename('../go_files/testfile2.go')
+
+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 gotype callback should ignore test files):
+ call ale#test#SetFilename('bla_test.go')
+ AssertEqual
+ \ 0,
+ \ ale_linters#go#gotype#GetCommand(bufnr(''))
diff --git a/test/go_files/testfile2.go b/test/go_files/testfile2.go
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/go_files/testfile2.go
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 2ca18341..e20125a3 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -1,14 +1,30 @@
Before:
- Save g:ale_warn_about_trailing_whitespace
- Save g:ale_linters
+ Save g:ale_buffer_info
+ Save g:ale_cache_executable_check_failures
+ Save g:ale_completion_enabled
Save g:ale_fixers
+ Save g:ale_history_log_output
+ Save g:ale_lint_on_insert_leave
Save g:ale_lint_on_text_changed
- Save g:ale_cache_executable_check_failures
+ Save g:ale_linters
+ Save g:ale_maximum_file_size
+ Save g:ale_pattern_options
+ Save g:ale_pattern_options_enabled
+ Save g:ale_set_balloons
+ Save g:ale_warn_about_trailing_whitespace
unlet! b:ale_history
- let g:ale_lint_on_text_changed = 'always'
+ let g:ale_buffer_info = {}
let g:ale_cache_executable_check_failures = 0
+ let g:ale_completion_enabled = 0
+ let g:ale_history_log_output = 1
+ let g:ale_lint_on_insert_leave = 0
+ let g:ale_lint_on_text_changed = 'always'
+ let g:ale_maximum_file_size = 0
+ let g:ale_pattern_options = {}
+ let g:ale_pattern_options_enabled = 0
+ let g:ale_set_balloons = 0
let g:ale_warn_about_trailing_whitespace = 1
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
@@ -23,30 +39,55 @@ Before:
let g:globals_lines = [
\ ' Global Variables:',
\ '',
+ \ 'let g:ale_cache_executable_check_failures = 0',
+ \ 'let g:ale_change_sign_column_color = 0',
+ \ 'let g:ale_command_wrapper = ''''',
+ \ 'let g:ale_completion_delay = 100',
+ \ 'let g:ale_completion_enabled = 0',
+ \ 'let g:ale_completion_max_suggestions = 50',
\ 'let g:ale_echo_cursor = 1',
\ 'let g:ale_echo_msg_error_str = ''Error''',
\ 'let g:ale_echo_msg_format = ''%code: %%s''',
+ \ 'let g:ale_echo_msg_info_str = ''Info''',
\ 'let g:ale_echo_msg_warning_str = ''Warning''',
\ 'let g:ale_enabled = 1',
\ 'let g:ale_fix_on_save = 0',
\ 'let g:ale_fixers = {}',
+ \ 'let g:ale_history_enabled = 1',
+ \ 'let g:ale_history_log_output = 1',
\ 'let g:ale_keep_list_window_open = 0',
\ 'let g:ale_lint_delay = 200',
\ 'let g:ale_lint_on_enter = 1',
+ \ 'let g:ale_lint_on_filetype_changed = 1',
\ 'let g:ale_lint_on_save = 1',
\ 'let g:ale_lint_on_text_changed = ''always''',
+ \ 'let g:ale_lint_on_insert_leave = 0',
\ 'let g:ale_linter_aliases = {}',
\ 'let g:ale_linters = {}',
+ \ 'let g:ale_linters_explicit = 0',
+ \ 'let g:ale_list_window_size = 10',
+ \ 'let g:ale_loclist_msg_format = ''%code: %%s''',
+ \ 'let g:ale_max_buffer_history_size = 20',
+ \ 'let g:ale_max_signs = -1',
+ \ 'let g:ale_maximum_file_size = 0',
\ 'let g:ale_open_list = 0',
+ \ 'let g:ale_pattern_options = {}',
+ \ 'let g:ale_pattern_options_enabled = 0',
+ \ 'let g:ale_set_balloons = 0',
\ 'let g:ale_set_highlights = 1',
\ 'let g:ale_set_loclist = 1',
\ 'let g:ale_set_quickfix = 0',
\ 'let g:ale_set_signs = 1',
\ 'let g:ale_sign_column_always = 0',
\ 'let g:ale_sign_error = ''>>''',
+ \ 'let g:ale_sign_info = ''--''',
\ 'let g:ale_sign_offset = 1000000',
+ \ 'let g:ale_sign_style_error = ''>>''',
+ \ 'let g:ale_sign_style_warning = ''--''',
\ 'let g:ale_sign_warning = ''--''',
\ 'let g:ale_statusline_format = [''%d error(s)'', ''%d warning(s)'', ''OK'']',
+ \ 'let g:ale_type_map = {}',
+ \ 'let g:ale_warn_about_trailing_blank_lines = 1',
\ 'let g:ale_warn_about_trailing_whitespace = 1',
\]
let g:command_header = [
@@ -66,8 +107,6 @@ Before:
After:
Restore
- let g:ale_buffer_info = {}
-
unlet! g:testlinter1
unlet! g:testlinter2
@@ -76,8 +115,6 @@ After:
unlet! g:output
unlet! g:globals_string
unlet! g:command_header
- let g:ale_buffer_info = {}
- let g:ale_history_log_output = 0
unlet! g:ale_testft_testlinter1_foo
unlet! g:ale_testft_testlinter1_bar
unlet! g:ale_testft2_testlinter2_foo
@@ -378,6 +415,7 @@ Execute (ALEInfo should include executable checks in the history):
Execute (The option for caching failing executable checks should work):
let g:ale_cache_executable_check_failures = 1
+ let g:globals_lines[2] = 'let g:ale_cache_executable_check_failures = 1'
call ale#linter#Define('testft', g:testlinter1)