X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/chef/foodcritic.vim diff --git a/.vim/bundle/ale/ale_linters/chef/foodcritic.vim b/.vim/bundle/ale/ale_linters/chef/foodcritic.vim new file mode 100644 index 00000000..48beba75 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/chef/foodcritic.vim @@ -0,0 +1,41 @@ +" Author: Edward Larkey +" Author: Jose Junior +" Author: w0rp +" Description: This file adds the foodcritic linter for Chef files. + +call ale#Set('chef_foodcritic_executable', 'foodcritic') +call ale#Set('chef_foodcritic_options', '') + +function! ale_linters#chef#foodcritic#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'chef_foodcritic_options') + + return '%e' . ale#Pad(escape(l:options, '~')) . ' %s' +endfunction + +function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " FC002: Avoid string interpolation where not required: httpd.rb:13 + let l:pattern = '\v([^:]+): (.+): ([a-zA-Z]?:?[^:]+):(\d+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'code': l:match[1], + \ 'text': l:match[2], + \ 'filename': l:match[3], + \ 'lnum': l:match[4] + 0, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('chef', { +\ 'name': 'foodcritic', +\ 'executable': {b -> ale#Var(b, 'chef_foodcritic_executable')}, +\ 'command': function('ale_linters#chef#foodcritic#GetCommand'), +\ 'callback': 'ale_linters#chef#foodcritic#Handle', +\ 'lint_file': 1, +\})