]> git.madduck.net Git - etc/vim.git/blob - ale_linters/eruby/erubi.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / eruby / erubi.vim
1 " Author: Eddie Lebow https://github.com/elebow
2 " Description: eruby checker using `erubi`
3
4 function! ale_linters#eruby#erubi#GetCommand(buffer, output, meta) abort
5     let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
6
7     if !empty(a:output)
8         " The empty command in CheckErubi returns nothing if erubi runs and
9         " emits an error if erubi is not present
10         return ''
11     endif
12
13     if empty(l:rails_root)
14         return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c'
15     endif
16
17     " Rails-flavored eRuby does not comply with the standard as understood by
18     " Erubi, so we'll have to do some substitution. This does not reduce the
19     " effectiveness of the linter---the translated code is still evaluated.
20     return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
21 endfunction
22
23 call ale#linter#Define('eruby', {
24 \   'name': 'erubi',
25 \   'executable': 'ruby',
26 \   'command': {buffer -> ale#command#Run(
27 \       buffer,
28 \       'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
29 \       function('ale_linters#eruby#erubi#GetCommand'),
30 \   )},
31 \   'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
32 \})