Add support for checking C code with GCC too.
This commit is contained in:
parent
9553c24fa0
commit
b66b6f925a
@ -27,6 +27,7 @@ name. That seems to be the fairest way to arrange this table.
|
|||||||
| -------- | ----- |
|
| -------- | ----- |
|
||||||
| Bash | [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) |
|
| Bash | [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) |
|
||||||
| Bourne Shell | [-n flag](http://linux.die.net/man/1/sh) |
|
| Bourne Shell | [-n flag](http://linux.die.net/man/1/sh) |
|
||||||
|
| C | [gcc](https://gcc.gnu.org/) |
|
||||||
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
||||||
| Fortran | [gcc](https://gcc.gnu.org/) |
|
| Fortran | [gcc](https://gcc.gnu.org/) |
|
||||||
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/) |
|
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/) |
|
||||||
|
49
ale_linters/c/gcc.vim
Normal file
49
ale_linters/c/gcc.vim
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
if exists('g:loaded_ale_linters_c_gcc')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:loaded_ale_linters_c_gcc = 1
|
||||||
|
|
||||||
|
" Set this option to change the GCC options for warnings for C.
|
||||||
|
if !exists('g:ale_c_gcc_options')
|
||||||
|
let g:ale_c_gcc_options = '-Wall'
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! ale_linters#c#gcc#Handle(buffer, lines)
|
||||||
|
" Look for lines like the following.
|
||||||
|
"
|
||||||
|
" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
|
||||||
|
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
|
||||||
|
let pattern = '^<stdin>:\(\d\+\):\(\d\+\): \(warning\|error\): \(.\+\)$'
|
||||||
|
let output = []
|
||||||
|
|
||||||
|
for line in a:lines
|
||||||
|
let l:match = matchlist(line, pattern)
|
||||||
|
|
||||||
|
if len(l:match) == 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(output, {
|
||||||
|
\ 'bufnr': a:buffer,
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'vcol': 0,
|
||||||
|
\ 'col': l:match[2] + 0,
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\ 'type': l:match[3] ==# 'warning' ? 'W' : 'E',
|
||||||
|
\ 'nr': -1,
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ALEAddLinter('c', {
|
||||||
|
\ 'name': 'gcc',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': 'gcc',
|
||||||
|
\ 'command': 'gcc -S -x c -fsyntax-only '
|
||||||
|
\ . g:ale_c_gcc_options
|
||||||
|
\ . ' -',
|
||||||
|
\ 'callback': 'ale_linters#c#gcc#Handle',
|
||||||
|
\})
|
Loading…
x
Reference in New Issue
Block a user