diff options
author | w0rp <devw0rp@gmail.com> | 2018-09-04 16:51:18 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-09-04 16:51:18 +0100 |
commit | d476578a402763f2c6e4e0ada2eb345d0ac938d7 (patch) | |
tree | 77f5a61c6eada15821391ecb4f78b87fa8e406db /ale_linters/vim | |
parent | 8f2e1c393f74326979e1c74af8dc9b6ca8004778 (diff) | |
download | ale-d476578a402763f2c6e4e0ada2eb345d0ac938d7.zip |
Improve ALE project style checking
* The project style linter now runs while you type.
* Now the scripts for checking the project require blank lines.
* Many style issues have been found and fixed.
Diffstat (limited to 'ale_linters/vim')
-rw-r--r-- | ale_linters/vim/ale_custom_linting_rules.vim | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ale_linters/vim/ale_custom_linting_rules.vim b/ale_linters/vim/ale_custom_linting_rules.vim index f4e111ee..3da44206 100644 --- a/ale_linters/vim/ale_custom_linting_rules.vim +++ b/ale_linters/vim/ale_custom_linting_rules.vim @@ -25,7 +25,13 @@ endfunction function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort let l:dir = s:GetALEProjectDir(a:buffer) - return ale#path#CdString(l:dir) . '%e .' + let l:temp_dir = ale#engine#CreateDirectory(a:buffer) + let l:temp_file = l:temp_dir . '/example.vim' + + let l:lines = getbufline(a:buffer, 1, '$') + call ale#util#Writefile(a:buffer, l:lines, l:temp_file) + + return ale#path#CdString(l:dir) . '%e ' . ale#Escape(l:temp_dir) endfunction function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort @@ -34,15 +40,17 @@ function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+) (.+)$' for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:filename = ale#path#GetAbsPath(l:dir, l:match[1]) - - if bufnr(l:filename) is a:buffer - call add(l:output, { - \ 'lnum': l:match[2], - \ 'text': l:match[3], - \ 'type': 'W', - \}) + " Ignore trailing whitespace errors if we've turned them off. + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + \&& l:match[3] is# 'Trailing whitespace' + continue endif + + call add(l:output, { + \ 'lnum': l:match[2], + \ 'text': l:match[3], + \ 'type': 'W', + \}) endfor return l:output @@ -53,5 +61,5 @@ call ale#linter#Define('vim', { \ 'executable_callback': 'ale_linters#vim#ale_custom_linting_rules#GetExecutable', \ 'command_callback': 'ale_linters#vim#ale_custom_linting_rules#GetCommand', \ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', -\ 'lint_file': 1, +\ 'read_buffer': 0, \}) |