All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Sascha Grunert <mail@saschagrunert.de>
2 " Description: Adds support of golangci-lint
4 call ale#Set('go_golangci_lint_options', '')
5 call ale#Set('go_golangci_lint_executable', 'golangci-lint')
6 call ale#Set('go_golangci_lint_package', 1)
8 function! ale_linters#go#golangci_lint#GetExecutable(buffer) abort
9 let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable')
14 function! ale_linters#go#golangci_lint#GetCommand(buffer, version) abort
15 let l:filename = expand('#' . a:buffer . ':t')
16 let l:options = ale#Var(a:buffer, 'go_golangci_lint_options')
17 let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package')
19 if ale#semver#GTE(a:version, [2, 0, 0])
20 let l:options = l:options
21 \ . ' --output.json.path stdout'
22 \ . ' --output.text.path stderr'
25 let l:options = l:options
26 \ . ' --out-format=json'
31 return ale#go#EnvString(a:buffer)
36 return ale#go#EnvString(a:buffer)
38 \ . ale#Escape(l:filename)
42 function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort
43 let l:dir = expand('#' . a:buffer . ':p:h')
46 let l:matches = ale#util#FuzzyJSONDecode(a:lines, [])
52 for l:match in l:matches['Issues']
53 if l:match['FromLinter'] is# 'typecheck'
60 \ 'filename': ale#path#GetAbsPath(l:dir, fnamemodify(l:match['Pos']['Filename'], ':t')),
61 \ 'lnum': l:match['Pos']['Line'] + 0,
62 \ 'col': l:match['Pos']['Column'] + 0,
64 \ 'text': match['FromLinter'] . ' - ' . l:match['Text'],
71 call ale#linter#Define('go', {
72 \ 'name': 'golangci-lint',
73 \ 'executable': function('ale_linters#go#golangci_lint#GetExecutable'),
75 \ 'command': {buffer -> ale#semver#RunWithVersionCheck(
77 \ ale_linters#go#golangci_lint#GetExecutable(buffer),
79 \ function('ale_linters#go#golangci_lint#GetCommand'),
81 \ 'callback': 'ale_linters#go#golangci_lint#Handler',