diff options
author | w0rp <devw0rp@gmail.com> | 2016-10-08 21:52:41 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2016-10-08 21:52:41 +0100 |
commit | f17a66088863d5bf44a84b7c2d996063640f1d6b (patch) | |
tree | 9421c1c427b6bb733e219f0b590c13dfdb76e6f2 /plugin | |
parent | 20a28b7856fd2377527add58161a1c40c00f7232 (diff) | |
download | ale-f17a66088863d5bf44a84b7c2d996063640f1d6b.zip |
Send the buffers to the linters using getbufline() on Windows, re issue #39
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/ale/zmain.vim | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/plugin/ale/zmain.vim b/plugin/ale/zmain.vim index 7b11bd4b..72d0a263 100644 --- a/plugin/ale/zmain.vim +++ b/plugin/ale/zmain.vim @@ -215,11 +215,10 @@ function! s:ApplyLinter(buffer, linter) endif else let job_options = { + \ 'in_mode': 'nl', \ 'out_mode': 'nl', \ 'err_mode': 'nl', \ 'close_cb': function('s:HandleExitVim'), - \ 'in_io': 'buffer', - \ 'in_buf': a:buffer, \} if a:linter.output_stream ==# 'stderr' @@ -238,14 +237,19 @@ function! s:ApplyLinter(buffer, linter) " othwerwise %PATHTEXT% will not be used to programs ending int " .cmd, .bat, .exe, etc. let l:command = 'cmd /c ' . l:command + else + " On Unix machines, we can send the Vim buffer directly. + " This is faster than reading the lines ourselves. + let job_options.in_io = 'buffer' + let job_options.in_buf = a:buffer endif " Vim 8 will read the stdin from the file's buffer. let job = job_start(l:command, l:job_options) endif - " Sometimes the job can be failed to be created at all in Vim 8. - if job != 'no process' + " Only proceed if the job is being run. + if has('nvim') || (job != 'no process' && job_status(job) == 'run') let a:linter.job = job " Store the ID for the job in the map to read back again. @@ -256,9 +260,21 @@ function! s:ApplyLinter(buffer, linter) \} if has('nvim') - " For NeoVim, we have to send the text in the buffer to the command. - call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n") - call jobclose(a:linter.job, 'stdin') + " In NeoVim, we have to send the buffer lines ourselves. + let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n" + + call jobsend(job, input) + call jobclose(job, 'stdin') + elseif has('win32') + " On Windows, we have to send the buffer lines ourselves, + " as there are issues with Windows and 'in_buf' + let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n" + let channel = job_getchannel(job) + + if ch_status(channel) == 'open' + call ch_sendraw(channel, input) + call ch_close_in(channel) + endif endif endif endfunction @@ -395,7 +411,7 @@ endif if g:ale_lint_on_enter augroup ALERunOnEnterGroup autocmd! - autocmd BufEnter,BufRead * call ALELint(0) + autocmd BufEnter,BufRead * call ALELint(100) augroup END endif |