summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-01-12 18:34:17 +0000
committerw0rp <devw0rp@gmail.com>2019-01-12 18:34:26 +0000
commitc0b2090fbbc7a72dcf4963bf4d72cb6fc0b61e1d (patch)
tree46dd47356cf5b6e28882e84a56f61ad98d618e9e /autoload
parent7f176390fc4c1b3c1a7be484e0a84c4eb8f896e3 (diff)
downloadale-c0b2090fbbc7a72dcf4963bf4d72cb6fc0b61e1d.zip
#2132 Move CreateTemporaryFileForJob calls into FormatCommand
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/command.vim6
-rw-r--r--autoload/ale/engine.vim5
-rw-r--r--autoload/ale/fix.vim6
-rw-r--r--autoload/ale/lsp_linter.vim2
4 files changed, 11 insertions, 8 deletions
diff --git a/autoload/ale/command.vim b/autoload/ale/command.vim
index 543c9953..6c56d518 100644
--- a/autoload/ale/command.vim
+++ b/autoload/ale/command.vim
@@ -20,7 +20,7 @@ endfunction
" %s -> with the current filename
" %t -> with the name of an unused file in a temporary directory
" %% -> with a literal %
-function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed) abort
+function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed, CreateTemporaryFileForJob) abort
let l:temporary_file = ''
let l:command = a:command
@@ -58,5 +58,7 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne
let l:command = l:command . ' < ' . ale#Escape(l:temporary_file)
endif
- return [l:temporary_file, l:command]
+ let l:file_created = a:CreateTemporaryFileForJob(a:buffer, l:temporary_file)
+
+ return [l:temporary_file, l:command, l:file_created]
endfunction
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index e1c8d93f..ace123dc 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -512,14 +512,15 @@ function! s:RunJob(options) abort
let l:read_buffer = a:options.read_buffer
let l:info = g:ale_buffer_info[l:buffer]
- let [l:temporary_file, l:command] = ale#command#FormatCommand(
+ let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
\ l:buffer,
\ l:executable,
\ l:command,
\ l:read_buffer,
+ \ function('s:CreateTemporaryFileForJob'),
\)
- if s:CreateTemporaryFileForJob(l:buffer, l:temporary_file)
+ if l:file_created
" If a temporary filename has been formatted in to the command, then
" we do not need to send the Vim buffer to the command.
let l:read_buffer = 0
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 423e85be..59502933 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -172,7 +172,7 @@ function! ale#fix#RemoveManagedFiles(buffer) abort
let g:ale_fix_buffer_data[a:buffer].temporary_directory_list = []
endfunction
-function! s:CreateTemporaryFileForJob(buffer, temporary_file, input) abort
+function! s:CreateTemporaryFileForJob(input, buffer, temporary_file) abort
if empty(a:temporary_file)
" There is no file, so we didn't create anything.
return 0
@@ -218,13 +218,13 @@ function! s:RunJob(options) abort
return 1
endif
- let [l:temporary_file, l:command] = ale#command#FormatCommand(
+ let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
\ l:buffer,
\ '',
\ l:command,
\ l:read_buffer,
+ \ function('s:CreateTemporaryFileForJob', [l:input]),
\)
- call s:CreateTemporaryFileForJob(l:buffer, l:temporary_file, l:input)
let l:command = ale#job#PrepareCommand(l:buffer, l:command)
let l:job_options = {
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index 42d67398..d92dae7e 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -182,7 +182,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort
let l:command = ale#linter#GetCommand(a:buffer, a:linter)
" Format the command, so %e can be formatted into it.
- let l:command = ale#command#FormatCommand(a:buffer, l:executable, l:command, 0)[1]
+ let l:command = ale#command#FormatCommand(a:buffer, l:executable, l:command, 0, {-> 0})[1]
let l:command = ale#job#PrepareCommand(a:buffer, l:command)
let l:ready = ale#lsp#StartProgram(l:conn_id, l:executable, l:command)
endif