Fix some naming conventions and use abort for all Rust functions, and disable the rust linters for now, re #256

This commit is contained in:
w0rp 2017-01-13 09:23:03 +00:00
parent 3b486d3475
commit f412b4f96f
4 changed files with 13 additions and 12 deletions

View File

@ -77,7 +77,6 @@ name. That seems to be the fairest way to arrange this table.
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
| Python | [flake8](http://flake8.pycqa.org/en/latest/), [pylint](https://www.pylint.org/) | | Python | [flake8](http://flake8.pycqa.org/en/latest/), [pylint](https://www.pylint.org/) |
| Ruby | [rubocop](https://github.com/bbatsov/rubocop) | | Ruby | [rubocop](https://github.com/bbatsov/rubocop) |
| Rust | [rustc](https://www.rust-lang.org/), cargo (see `:help ale-integration-rust` for configuration instructions) |
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) | | SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) | | SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
| Scala | [scalac](http://scala-lang.org) | | Scala | [scalac](http://scala-lang.org) |

View File

@ -2,7 +2,7 @@
" Description: rustc invoked by cargo for rust files " Description: rustc invoked by cargo for rust files
function! ale_linters#rust#cargo#cargo_or_not_cargo(bufnr) function! ale_linters#rust#cargo#GetCargoExecutable(bufnr)
if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# '' if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
return 'cargo' return 'cargo'
else else
@ -14,8 +14,8 @@ endfunction
call ale#linter#Define('rust', { call ale#linter#Define('rust', {
\ 'name': 'cargo', \ 'name': 'cargo',
\ 'executable_callback': 'ale_linters#rust#cargo#cargo_or_not_cargo', \ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
\ 'command': 'cargo rustc -- --error-format=json -Z no-trans', \ 'command': 'cargo rustc -- --error-format=json -Z no-trans',
\ 'callback': 'ale_linters#rust#rustc#handle_rustc_errors', \ 'callback': 'ale_linters#rust#rustc#HandleRustcErrors',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\}) \})

View File

@ -6,7 +6,10 @@ if !exists('g:ale_rust_ignore_error_codes')
endif endif
function! ale_linters#rust#rustc#handle_rustc_errors(buffer_number, errorlines) function! ale_linters#rust#rustc#HandleRustcErrors(buffer_number, errorlines) abort
" FIXME: Fix this linter
return []
let l:file_name = fnamemodify(bufname(a:buffer_number), ':t') let l:file_name = fnamemodify(bufname(a:buffer_number), ':t')
let l:output = [] let l:output = []
@ -37,7 +40,7 @@ function! ale_linters#rust#rustc#handle_rustc_errors(buffer_number, errorlines)
else else
" when the error is caused in the expansion of a macro, we have " when the error is caused in the expansion of a macro, we have
" to bury deeper " to bury deeper
let l:root_cause = s:find_error_in_expansion(l:span, l:file_name) let l:root_cause = s:FindErrorInExpansion(l:span, l:file_name)
if !empty(l:root_cause) if !empty(l:root_cause)
call add(l:output, { call add(l:output, {
@ -59,20 +62,20 @@ endfunction
" returns: a list [lnum, col] with the location of the error or [] " returns: a list [lnum, col] with the location of the error or []
function! s:find_error_in_expansion(span, file_name) function! s:FindErrorInExpansion(span, file_name) abort
if a:span.file_name ==# a:file_name if a:span.file_name ==# a:file_name
return [a:span.line_start, a:span.byte_start] return [a:span.line_start, a:span.byte_start]
endif endif
if !empty(a:span.expansion) if !empty(a:span.expansion)
return s:find_error_in_expansion(a:span.expansion.span, a:file_name) return s:FindErrorInExpansion(a:span.expansion.span, a:file_name)
endif endif
return [] return []
endfunction endfunction
function! ale_linters#rust#rustc#rustc_command(buffer_number) function! ale_linters#rust#rustc#RustcCommand(buffer_number) abort
" Try to guess the library search path. If the project is managed by cargo, " Try to guess the library search path. If the project is managed by cargo,
" it's usually <project root>/target/debug/deps/ or " it's usually <project root>/target/debug/deps/ or
" <project root>/target/release/deps/ " <project root>/target/release/deps/
@ -93,7 +96,7 @@ endfunction
call ale#linter#Define('rust', { call ale#linter#Define('rust', {
\ 'name': 'rustc', \ 'name': 'rustc',
\ 'executable': 'rustc', \ 'executable': 'rustc',
\ 'command_callback': 'ale_linters#rust#rustc#rustc_command', \ 'command_callback': 'ale_linters#rust#rustc#RustcCommand',
\ 'callback': 'ale_linters#rust#rustc#handle_rustc_errors', \ 'callback': 'ale_linters#rust#rustc#HandleRustcErrors',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\}) \})

View File

@ -91,7 +91,6 @@ The following languages and tools are supported.
* Pug: 'pug-lint' * Pug: 'pug-lint'
* Puppet: 'puppet', 'puppet-lint' * Puppet: 'puppet', 'puppet-lint'
* Python: 'flake8', 'pylint' * Python: 'flake8', 'pylint'
* Rust: 'rustc' (see |ale-integration-rust|)
* Ruby: 'rubocop' * Ruby: 'rubocop'
* SASS: 'sasslint', 'stylelint' * SASS: 'sasslint', 'stylelint'
* SCSS: 'sasslint', 'scsslint', 'stylelint' * SCSS: 'sasslint', 'scsslint', 'stylelint'