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: Niraj Thapaliya - https://github.com/nthapaliya
2 " Description: Lints fish files using fish -n
4 function! ale_linters#fish#fish#Handle(buffer, lines) abort
5 " Matches patterns such as:
7 " home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition
11 " OR, patterns such as:
13 " Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.
14 " /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY
17 " fish -n can return errors in either format.
18 let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$'
19 let l:column_pattern = '^ *\^'
21 let l:column_offset = 0
22 let l:last_line_with_message = ''
25 " Look for error lines first.
26 let l:match = matchlist(l:line, l:pattern)
29 if !empty(l:last_line_with_message)
30 let l:text = l:last_line_with_message
32 let l:text = l:match[3]
35 let l:column_offset = len(l:match[1])
37 let l:last_line_with_message = ''
40 \ 'lnum': str2nr(l:match[2]),
44 " Look for column markers like ' ^' second.
45 " The column index will be set according to how long the line is.
46 let l:column_match = matchstr(l:line, l:column_pattern)
48 if !empty(l:column_match) && !empty(l:output)
49 let l:output[-1].col = len(l:column_match) - l:column_offset
50 let l:last_line_with_message = ''
52 let l:last_line_with_message = l:line
53 let l:column_offset = 0
61 call ale#linter#Define('fish', {
63 \ 'output_stream': 'stderr',
64 \ 'executable': 'fish',
65 \ 'command': 'fish -n %t',
66 \ 'callback': 'ale_linters#fish#fish#Handle',