mirror of
https://github.com/amix/vimrc
synced 2025-07-12 14:15:00 +08:00
Updated plugins
This commit is contained in:
@ -23,19 +23,23 @@ function! ale#ant#FindExecutable(buffer) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Given a buffer number, build a command to print the classpath of the root
|
||||
" project. Returns an empty string if cannot build the command.
|
||||
" Given a buffer number, get a working directory and command to print the
|
||||
" classpath of the root project.
|
||||
"
|
||||
" Returns an empty string for the command if Ant is not detected.
|
||||
function! ale#ant#BuildClasspathCommand(buffer) abort
|
||||
let l:executable = ale#ant#FindExecutable(a:buffer)
|
||||
let l:project_root = ale#ant#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:executable) && !empty(l:project_root)
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' classpath'
|
||||
\ . ' -S'
|
||||
\ . ' -q'
|
||||
if !empty(l:executable)
|
||||
let l:project_root = ale#ant#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:project_root)
|
||||
return [
|
||||
\ l:project_root,
|
||||
\ ale#Escape(l:executable) .' classpath -S -q'
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
@ -52,6 +52,36 @@ function! s:ProcessDeferredCommands(initial_result) abort
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
function! s:ProcessDeferredCwds(initial_command, initial_cwd) abort
|
||||
let l:result = a:initial_command
|
||||
let l:last_cwd = v:null
|
||||
let l:command_index = 0
|
||||
let l:cwd_list = []
|
||||
|
||||
while ale#command#IsDeferred(l:result)
|
||||
call add(l:cwd_list, l:result.cwd)
|
||||
|
||||
if get(g:, 'ale_run_synchronously_emulate_commands')
|
||||
" Don't run commands, but simulate the results.
|
||||
let l:Callback = g:ale_run_synchronously_callbacks[0]
|
||||
let l:output = get(s:command_output, l:command_index, [])
|
||||
call l:Callback(0, l:output)
|
||||
unlet g:ale_run_synchronously_callbacks
|
||||
|
||||
let l:command_index += 1
|
||||
else
|
||||
" Run the commands in the shell, synchronously.
|
||||
call ale#test#FlushJobs()
|
||||
endif
|
||||
|
||||
let l:result = l:result.value
|
||||
endwhile
|
||||
|
||||
call add(l:cwd_list, a:initial_cwd is v:null ? l:last_cwd : a:initial_cwd)
|
||||
|
||||
return l:cwd_list
|
||||
endfunction
|
||||
|
||||
" Load the currently loaded linter for a test case, and check that the command
|
||||
" matches the given string.
|
||||
function! ale#assert#Linter(expected_executable, expected_command) abort
|
||||
@ -85,6 +115,38 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
|
||||
\ [l:executable, l:command]
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LinterCwd(expected_cwd) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
|
||||
let l:initial_cwd = ale#linter#GetCwd(l:buffer, l:linter)
|
||||
call ale#command#SetCwd(l:buffer, l:initial_cwd)
|
||||
|
||||
let l:cwd = s:ProcessDeferredCwds(
|
||||
\ ale#linter#GetCommand(l:buffer, l:linter),
|
||||
\ l:initial_cwd,
|
||||
\)
|
||||
|
||||
call ale#command#ResetCwd(l:buffer)
|
||||
|
||||
if type(a:expected_cwd) isnot v:t_list
|
||||
let l:cwd = l:cwd[-1]
|
||||
endif
|
||||
|
||||
AssertEqual a:expected_cwd, l:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#assert#FixerCwd(expected_cwd) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:cwd = s:ProcessDeferredCwds(s:FixerFunction(l:buffer), v:null)
|
||||
|
||||
if type(a:expected_cwd) isnot v:t_list
|
||||
let l:cwd = l:cwd[-1]
|
||||
endif
|
||||
|
||||
AssertEqual a:expected_cwd, l:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#assert#Fixer(expected_result) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer))
|
||||
@ -107,8 +169,21 @@ function! ale#assert#LinterNotExecuted() abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
let l:executable = ale#linter#GetExecutable(l:buffer, l:linter)
|
||||
let l:executed = 1
|
||||
|
||||
Assert empty(l:executable), "The linter will be executed when it shouldn't be"
|
||||
if !empty(l:executable)
|
||||
let l:command = ale#linter#GetCommand(l:buffer, l:linter)
|
||||
|
||||
if type(l:command) is v:t_list
|
||||
let l:command = l:command[-1]
|
||||
endif
|
||||
|
||||
let l:executed = !empty(l:command)
|
||||
else
|
||||
let l:executed = 0
|
||||
endif
|
||||
|
||||
Assert !l:executed, "The linter will be executed when it shouldn't be"
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LSPOptions(expected_options) abort
|
||||
@ -153,6 +228,7 @@ endfunction
|
||||
|
||||
function! ale#assert#SetUpLinterTestCommands() abort
|
||||
command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput(<args>)
|
||||
command! -nargs=+ AssertLinterCwd :call ale#assert#LinterCwd(<args>)
|
||||
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>)
|
||||
command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted()
|
||||
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
|
||||
@ -164,10 +240,35 @@ endfunction
|
||||
|
||||
function! ale#assert#SetUpFixerTestCommands() abort
|
||||
command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput(<args>)
|
||||
command! -nargs=+ AssertFixerCwd :call ale#assert#FixerCwd(<args>)
|
||||
command! -nargs=+ AssertFixer :call ale#assert#Fixer(<args>)
|
||||
command! -nargs=0 AssertFixerNotExecuted :call ale#assert#FixerNotExecuted()
|
||||
endfunction
|
||||
|
||||
function! ale#assert#ResetVariables(filetype, name, ...) abort
|
||||
" If the suffix of the option names format is different, an additional
|
||||
" argument can be used for that instead.
|
||||
if a:0 > 1
|
||||
throw 'Too many arguments'
|
||||
endif
|
||||
|
||||
let l:option_suffix = get(a:000, 0, a:name)
|
||||
let l:prefix = 'ale_' . a:filetype . '_'
|
||||
\ . substitute(l:option_suffix, '-', '_', 'g')
|
||||
let l:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
|
||||
" Save and clear linter variables.
|
||||
" We'll load the runtime file to reset them to defaults.
|
||||
for l:key in filter(keys(g:), l:filter_expr)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
for l:key in filter(keys(b:), l:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" A dummy function for making sure this module is loaded.
|
||||
function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||
" Set up a marker so ALE doesn't create real random temporary filenames.
|
||||
@ -177,35 +278,22 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||
call ale#linter#Reset()
|
||||
call ale#linter#PreventLoading(a:filetype)
|
||||
|
||||
let l:prefix = 'ale_' . a:filetype . '_' . a:name
|
||||
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
Save g:ale_root
|
||||
let g:ale_root = {}
|
||||
|
||||
Save g:ale_lsp_root
|
||||
let g:ale_lsp_root = {}
|
||||
Save b:ale_root
|
||||
unlet! b:ale_root
|
||||
|
||||
Save b:ale_lsp_root
|
||||
unlet! b:ale_lsp_root
|
||||
call ale#assert#ResetVariables(a:filetype, a:name)
|
||||
|
||||
Save g:ale_c_build_dir
|
||||
unlet! g:ale_c_build_dir
|
||||
|
||||
" Save and clear linter variables.
|
||||
" We'll load the runtime file to reset them to defaults.
|
||||
for l:key in filter(keys(g:), b:filter_expr)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
unlet! b:ale_c_build_dir
|
||||
|
||||
for l:key in filter(keys(b:), b:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
|
||||
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim'
|
||||
|
||||
if !exists('g:dir')
|
||||
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
||||
call ale#test#SetDirectory('/testplugin/test/linter')
|
||||
endif
|
||||
|
||||
call ale#assert#SetUpLinterTestCommands()
|
||||
@ -226,6 +314,10 @@ function! ale#assert#TearDownLinterTest() abort
|
||||
delcommand GivenCommandOutput
|
||||
endif
|
||||
|
||||
if exists(':AssertLinterCwd')
|
||||
delcommand AssertLinterCwd
|
||||
endif
|
||||
|
||||
if exists(':AssertLinter')
|
||||
delcommand AssertLinter
|
||||
endif
|
||||
@ -281,18 +373,7 @@ function! ale#assert#SetUpFixerTest(filetype, name, ...) abort
|
||||
let s:FixerFunction = function(l:function_name)
|
||||
|
||||
let l:option_suffix = get(a:000, 0, a:name)
|
||||
let l:prefix = 'ale_' . a:filetype . '_'
|
||||
\ . substitute(l:option_suffix, '-', '_', 'g')
|
||||
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
|
||||
for l:key in filter(keys(g:), b:filter_expr)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
for l:key in filter(keys(b:), b:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
call ale#assert#ResetVariables(a:filetype, a:name, l:option_suffix)
|
||||
|
||||
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
|
||||
|
||||
@ -329,6 +410,10 @@ function! ale#assert#TearDownFixerTest() abort
|
||||
delcommand GivenCommandOutput
|
||||
endif
|
||||
|
||||
if exists(':AssertFixerCwd')
|
||||
delcommand AssertFixerCwd
|
||||
endif
|
||||
|
||||
if exists(':AssertFixer')
|
||||
delcommand AssertFixer
|
||||
endif
|
||||
|
@ -152,6 +152,7 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort
|
||||
\ || stridx(l:option, '-idirafter') == 0
|
||||
\ || stridx(l:option, '-iframework') == 0
|
||||
\ || stridx(l:option, '-include') == 0
|
||||
\ || stridx(l:option, '-imacros') == 0
|
||||
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
|
||||
let l:arg = join(split(l:option, '\zs')[2:], '')
|
||||
let l:option = '-I'
|
||||
@ -490,7 +491,7 @@ function! ale#c#GetCFlags(buffer, output) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:CanParseMakefile(a:buffer) && !empty(a:output) && !empty(l:cflags)
|
||||
if empty(l:cflags) && s:CanParseMakefile(a:buffer) && !empty(a:output)
|
||||
let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output)
|
||||
endif
|
||||
|
||||
@ -505,19 +506,25 @@ function! ale#c#GetMakeCommand(buffer) abort
|
||||
if s:CanParseMakefile(a:buffer)
|
||||
let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile')
|
||||
|
||||
if empty(l:path)
|
||||
let l:path = ale#path#FindNearestFile(a:buffer, 'GNUmakefile')
|
||||
endif
|
||||
|
||||
if !empty(l:path)
|
||||
let l:always_make = ale#Var(a:buffer, 'c_always_make')
|
||||
|
||||
return ale#path#CdString(fnamemodify(l:path, ':h'))
|
||||
\ . 'make -n' . (l:always_make ? ' --always-make' : '')
|
||||
return [
|
||||
\ fnamemodify(l:path, ':h'),
|
||||
\ 'make -n' . (l:always_make ? ' --always-make' : ''),
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
||||
function! ale#c#RunMakeCommand(buffer, Callback) abort
|
||||
let l:command = ale#c#GetMakeCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#c#GetMakeCommand(a:buffer)
|
||||
|
||||
if empty(l:command)
|
||||
return a:Callback(a:buffer, [])
|
||||
@ -527,6 +534,7 @@ function! ale#c#RunMakeCommand(buffer, Callback) abort
|
||||
\ a:buffer,
|
||||
\ l:command,
|
||||
\ {b, output -> a:Callback(a:buffer, output)},
|
||||
\ {'cwd': l:cwd},
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
@ -71,6 +71,11 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
|
||||
|
||||
if l:buffer > 0
|
||||
let l:lines = getbufline(l:buffer, 1, '$')
|
||||
|
||||
" Add empty line if there's trailing newline, like readfile() does.
|
||||
if getbufvar(l:buffer, '&eol')
|
||||
let l:lines += ['']
|
||||
endif
|
||||
else
|
||||
let l:lines = readfile(a:filename, 'b')
|
||||
endif
|
||||
@ -89,62 +94,82 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
|
||||
let l:end_column = l:code_edit.end.offset
|
||||
let l:text = l:code_edit.newText
|
||||
|
||||
" Adjust the ends according to previous edits.
|
||||
if l:end_line > len(l:lines)
|
||||
let l:end_line_len = 0
|
||||
else
|
||||
let l:end_line_len = len(l:lines[l:end_line - 1])
|
||||
endif
|
||||
|
||||
let l:insertions = split(l:text, '\n', 1)
|
||||
|
||||
if l:line is 1
|
||||
" Same logic as for column below. Vimscript's slice [:-1] will not
|
||||
" be an empty list.
|
||||
let l:start = []
|
||||
else
|
||||
let l:start = l:lines[: l:line - 2]
|
||||
" Fix invalid columns
|
||||
let l:column = l:column > 0 ? l:column : 1
|
||||
let l:end_column = l:end_column > 0 ? l:end_column : 1
|
||||
|
||||
" Clamp start to BOF
|
||||
if l:line < 1
|
||||
let [l:line, l:column] = [1, 1]
|
||||
endif
|
||||
|
||||
" Special case when text must be added after new line
|
||||
if l:column > len(l:lines[l:line - 1])
|
||||
call extend(l:start, [l:lines[l:line - 1]])
|
||||
let l:column = 1
|
||||
" Clamp start to EOF
|
||||
if l:line > len(l:lines) || l:line == len(l:lines) && l:column > len(l:lines[-1]) + 1
|
||||
let [l:line, l:column] = [len(l:lines), len(l:lines[-1]) + 1]
|
||||
" Special case when start is after EOL
|
||||
elseif l:line < len(l:lines) && l:column > len(l:lines[l:line - 1]) + 1
|
||||
let [l:line, l:column] = [l:line + 1, 1]
|
||||
endif
|
||||
|
||||
if l:column is 1
|
||||
" We need to handle column 1 specially, because we can't slice an
|
||||
" empty string ending on index 0.
|
||||
let l:middle = [l:insertions[0]]
|
||||
else
|
||||
let l:middle = [l:lines[l:line - 1][: l:column - 2] . l:insertions[0]]
|
||||
" Adjust end: clamp if invalid and/or adjust if we moved start
|
||||
if l:end_line < l:line || l:end_line == l:line && l:end_column < l:column
|
||||
let [l:end_line, l:end_column] = [l:line, l:column]
|
||||
endif
|
||||
|
||||
call extend(l:middle, l:insertions[1:])
|
||||
|
||||
if l:end_line <= len(l:lines)
|
||||
" Only extend the last line if end_line is within the range of
|
||||
" lines.
|
||||
let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
|
||||
" Clamp end to EOF
|
||||
if l:end_line > len(l:lines) || l:end_line == len(l:lines) && l:end_column > len(l:lines[-1]) + 1
|
||||
let [l:end_line, l:end_column] = [len(l:lines), len(l:lines[-1]) + 1]
|
||||
" Special case when end is after EOL
|
||||
elseif l:end_line < len(l:lines) && l:end_column > len(l:lines[l:end_line - 1]) + 1
|
||||
let [l:end_line, l:end_column] = [l:end_line + 1, 1]
|
||||
endif
|
||||
|
||||
" Careful, [:-1] is not an empty list
|
||||
let l:start = l:line is 1 ? [] : l:lines[: l:line - 2]
|
||||
let l:middle = l:column is 1 ? [''] : [l:lines[l:line - 1][: l:column - 2]]
|
||||
|
||||
let l:middle[-1] .= l:insertions[0]
|
||||
let l:middle += l:insertions[1:]
|
||||
let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
|
||||
|
||||
let l:end_line_len = len(l:lines[l:end_line - 1])
|
||||
let l:lines_before_change = len(l:lines)
|
||||
let l:lines = l:start + l:middle + l:lines[l:end_line :]
|
||||
|
||||
let l:current_line_offset = len(l:lines) - l:lines_before_change
|
||||
let l:column_offset = len(l:middle[-1]) - l:end_line_len
|
||||
|
||||
let l:pos = s:UpdateCursor(l:pos,
|
||||
\ [l:line, l:column],
|
||||
\ [l:end_line, l:end_column],
|
||||
\ [l:current_line_offset, l:column_offset])
|
||||
" Keep cursor where it was (if outside of changes) or move it after
|
||||
" the changed text (if inside), but don't touch it when the change
|
||||
" spans the entire buffer, in which case we have no clue and it's
|
||||
" better to not do anything.
|
||||
if l:line isnot 1 || l:column isnot 1
|
||||
\|| l:end_line < l:lines_before_change
|
||||
\|| l:end_line == l:lines_before_change && l:end_column <= l:end_line_len
|
||||
let l:pos = s:UpdateCursor(l:pos,
|
||||
\ [l:line, l:column],
|
||||
\ [l:end_line, l:end_column],
|
||||
\ [l:current_line_offset, l:column_offset])
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:lines[-1] is# ''
|
||||
if l:buffer > 0
|
||||
" Make sure ale#util#{Writefile,SetBufferContents} add trailing
|
||||
" newline if and only if it should be added.
|
||||
if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol')
|
||||
call remove(l:lines, -1)
|
||||
else
|
||||
call setbufvar(l:buffer, '&eol', 0)
|
||||
endif
|
||||
elseif exists('+fixeol') && &fixeol && l:lines[-1] is# ''
|
||||
" Not in buffer, ale#util#Writefile can't check &eol and always adds
|
||||
" newline if &fixeol: remove to prevent double trailing newline.
|
||||
call remove(l:lines, -1)
|
||||
endif
|
||||
|
||||
if a:should_save
|
||||
if a:should_save || l:buffer < 0
|
||||
call ale#util#Writefile(l:buffer, l:lines, a:filename)
|
||||
else
|
||||
call ale#util#SetBufferContents(l:buffer, l:lines)
|
||||
@ -222,6 +247,10 @@ function! s:UpdateCursor(cursor, start, end, offset) abort
|
||||
endfunction
|
||||
|
||||
function! ale#code_action#GetChanges(workspace_edit) abort
|
||||
if a:workspace_edit is v:null
|
||||
return {}
|
||||
endif
|
||||
|
||||
let l:changes = {}
|
||||
|
||||
if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes)
|
||||
|
@ -261,7 +261,10 @@ function! ale#codefix#HandleLSPResponse(conn_id, response) abort
|
||||
|
||||
" Send the results to the menu callback, if set.
|
||||
if l:MenuCallback isnot v:null
|
||||
call l:MenuCallback(map(copy(l:result), '[''lsp'', v:val]'))
|
||||
call l:MenuCallback(
|
||||
\ l:data,
|
||||
\ map(copy(l:result), '[''lsp'', v:val]')
|
||||
\)
|
||||
|
||||
return
|
||||
endif
|
||||
|
@ -7,6 +7,9 @@ if !exists('s:buffer_data')
|
||||
let s:buffer_data = {}
|
||||
endif
|
||||
|
||||
" The regular expression used for formatting filenames with modifiers.
|
||||
let s:path_format_regex = '\v\%s(%(:h|:t|:r|:e)*)'
|
||||
|
||||
" Used to get the data in tests.
|
||||
function! ale#command#GetData() abort
|
||||
return deepcopy(s:buffer_data)
|
||||
@ -26,6 +29,19 @@ function! ale#command#InitData(buffer) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Set the cwd for commands that are about to run.
|
||||
" Used internally.
|
||||
function! ale#command#SetCwd(buffer, cwd) abort
|
||||
call ale#command#InitData(a:buffer)
|
||||
let s:buffer_data[a:buffer].cwd = a:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#command#ResetCwd(buffer) abort
|
||||
if has_key(s:buffer_data, a:buffer)
|
||||
let s:buffer_data[a:buffer].cwd = v:null
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#command#ManageFile(buffer, file) abort
|
||||
call ale#command#InitData(a:buffer)
|
||||
call add(s:buffer_data[a:buffer].file_list, a:file)
|
||||
@ -151,6 +167,24 @@ function! s:FormatFilename(filename, mappings, modifiers) abort
|
||||
return ale#Escape(l:filename)
|
||||
endfunction
|
||||
|
||||
" Produce a command prefix to check to a particular directory for a command.
|
||||
" %s format markers with filename-modifiers can be used as the directory, and
|
||||
" will be returned verbatim for formatting in paths relative to files.
|
||||
function! ale#command#CdString(directory) abort
|
||||
let l:match = matchstrpos(a:directory, s:path_format_regex)
|
||||
" Do not escape the directory here if it's a valid format string.
|
||||
" This allows us to use sequences like %s:h, %s:h:h, etc.
|
||||
let l:directory = l:match[1:] == [0, len(a:directory)]
|
||||
\ ? a:directory
|
||||
\ : ale#Escape(a:directory)
|
||||
|
||||
if has('win32')
|
||||
return 'cd /d ' . l:directory . ' && '
|
||||
endif
|
||||
|
||||
return 'cd ' . l:directory . ' && '
|
||||
endfunction
|
||||
|
||||
" Given a command string, replace every...
|
||||
" %s -> with the current filename
|
||||
" %t -> with the name of an unused file in a temporary directory
|
||||
@ -161,11 +195,16 @@ function! ale#command#FormatCommand(
|
||||
\ command,
|
||||
\ pipe_file_if_needed,
|
||||
\ input,
|
||||
\ cwd,
|
||||
\ mappings,
|
||||
\) abort
|
||||
let l:temporary_file = ''
|
||||
let l:command = a:command
|
||||
|
||||
if !empty(a:cwd)
|
||||
let l:command = ale#command#CdString(a:cwd) . l:command
|
||||
endif
|
||||
|
||||
" First replace all uses of %%, used for literal percent characters,
|
||||
" with an ugly string.
|
||||
let l:command = substitute(l:command, '%%', '<<PERCENTS>>', 'g')
|
||||
@ -181,7 +220,7 @@ function! ale#command#FormatCommand(
|
||||
let l:filename = fnamemodify(bufname(a:buffer), ':p')
|
||||
let l:command = substitute(
|
||||
\ l:command,
|
||||
\ '\v\%s(%(:h|:t|:r|:e)*)',
|
||||
\ s:path_format_regex,
|
||||
\ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))',
|
||||
\ 'g'
|
||||
\)
|
||||
@ -279,9 +318,16 @@ function! s:ExitCallback(buffer, line_list, Callback, data) abort
|
||||
let l:result = a:data.result
|
||||
let l:result.value = l:value
|
||||
|
||||
if get(l:result, 'result_callback', v:null) isnot v:null
|
||||
call call(l:result.result_callback, [l:value])
|
||||
endif
|
||||
" Set the default cwd for this buffer in this call stack.
|
||||
call ale#command#SetCwd(a:buffer, l:result.cwd)
|
||||
|
||||
try
|
||||
if get(l:result, 'result_callback', v:null) isnot v:null
|
||||
call call(l:result.result_callback, [l:value])
|
||||
endif
|
||||
finally
|
||||
call ale#command#ResetCwd(a:buffer)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! ale#command#Run(buffer, command, Callback, ...) abort
|
||||
@ -293,6 +339,13 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
||||
|
||||
let l:output_stream = get(l:options, 'output_stream', 'stdout')
|
||||
let l:line_list = []
|
||||
let l:cwd = get(l:options, 'cwd', v:null)
|
||||
|
||||
if l:cwd is v:null
|
||||
" Default the working directory to whatever it was for the last
|
||||
" command run in the chain.
|
||||
let l:cwd = get(get(s:buffer_data, a:buffer, {}), 'cwd', v:null)
|
||||
endif
|
||||
|
||||
let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
|
||||
\ a:buffer,
|
||||
@ -300,6 +353,7 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
||||
\ a:command,
|
||||
\ get(l:options, 'read_buffer', 0),
|
||||
\ get(l:options, 'input', v:null),
|
||||
\ l:cwd,
|
||||
\ get(l:options, 'filename_mappings', []),
|
||||
\)
|
||||
let l:command = ale#job#PrepareCommand(a:buffer, l:command)
|
||||
@ -366,10 +420,14 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
||||
" The `_deferred_job_id` is used for both checking the type of object, and
|
||||
" for checking the job ID and status.
|
||||
"
|
||||
" The cwd is kept and used as the default value for the next command in
|
||||
" the chain.
|
||||
"
|
||||
" The original command here is used in tests.
|
||||
let l:result = {
|
||||
\ '_deferred_job_id': l:job_id,
|
||||
\ 'executable': get(l:options, 'executable', ''),
|
||||
\ 'cwd': l:cwd,
|
||||
\ 'command': a:command,
|
||||
\}
|
||||
|
||||
|
@ -614,6 +614,8 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
||||
\ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
|
||||
\ 'icase': 1,
|
||||
\ 'menu': l:detail,
|
||||
\ 'dup': get(l:info, 'additional_edits_only', 0)
|
||||
\ || g:ale_completion_autoimport,
|
||||
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
|
||||
\}
|
||||
" This flag is used to tell if this completion came from ALE or not.
|
||||
|
@ -9,7 +9,6 @@ let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10)
|
||||
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
|
||||
|
||||
let s:cursor_timer = -1
|
||||
let s:last_pos = [0, 0, 0]
|
||||
|
||||
function! ale#cursor#TruncatedEcho(original_message) abort
|
||||
let l:message = a:original_message
|
||||
@ -118,14 +117,18 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort
|
||||
|
||||
let l:pos = getpos('.')[0:2]
|
||||
|
||||
if !exists('w:last_pos')
|
||||
let w:last_pos = [0, 0, 0]
|
||||
endif
|
||||
|
||||
" Check the current buffer, line, and column number against the last
|
||||
" recorded position. If the position has actually changed, *then*
|
||||
" we should echo something. Otherwise we can end up doing processing
|
||||
" the echo message far too frequently.
|
||||
if l:pos != s:last_pos
|
||||
if l:pos != w:last_pos
|
||||
let l:delay = ale#Var(l:buffer, 'echo_delay')
|
||||
|
||||
let s:last_pos = l:pos
|
||||
let w:last_pos = l:pos
|
||||
let s:cursor_timer = timer_start(
|
||||
\ l:delay,
|
||||
\ function('ale#cursor#EchoCursorWarning')
|
||||
@ -139,11 +142,16 @@ function! s:ShowCursorDetailForItem(loc, options) abort
|
||||
let s:last_detailed_line = line('.')
|
||||
let l:message = get(a:loc, 'detail', a:loc.text)
|
||||
let l:lines = split(l:message, "\n")
|
||||
call ale#preview#Show(l:lines, {'stay_here': l:stay_here})
|
||||
|
||||
" Clear the echo message if we manually displayed details.
|
||||
if !l:stay_here
|
||||
execute 'echo'
|
||||
if g:ale_floating_preview || g:ale_detail_to_floating_preview
|
||||
call ale#floating_preview#Show(l:lines)
|
||||
else
|
||||
call ale#preview#Show(l:lines, {'stay_here': l:stay_here})
|
||||
|
||||
" Clear the echo message if we manually displayed details.
|
||||
if !l:stay_here
|
||||
execute 'echo'
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -33,13 +33,13 @@ let s:global_variable_list = [
|
||||
\ 'ale_list_vertical',
|
||||
\ 'ale_list_window_size',
|
||||
\ 'ale_loclist_msg_format',
|
||||
\ 'ale_lsp_root',
|
||||
\ 'ale_max_buffer_history_size',
|
||||
\ 'ale_max_signs',
|
||||
\ 'ale_maximum_file_size',
|
||||
\ 'ale_open_list',
|
||||
\ 'ale_pattern_options',
|
||||
\ 'ale_pattern_options_enabled',
|
||||
\ 'ale_root',
|
||||
\ 'ale_set_balloons',
|
||||
\ 'ale_set_highlights',
|
||||
\ 'ale_set_loclist',
|
||||
|
@ -36,7 +36,7 @@ function! ale#definition#UpdateTagStack() abort
|
||||
endfunction
|
||||
|
||||
function! ale#definition#HandleTSServerResponse(conn_id, response) abort
|
||||
if get(a:response, 'command', '') is# 'definition'
|
||||
if has_key(a:response, 'request_seq')
|
||||
\&& has_key(s:go_to_definition_map, a:response.request_seq)
|
||||
let l:options = remove(s:go_to_definition_map, a:response.request_seq)
|
||||
|
||||
@ -66,9 +66,17 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort
|
||||
endif
|
||||
|
||||
for l:item in l:result
|
||||
let l:filename = ale#path#FromURI(l:item.uri)
|
||||
let l:line = l:item.range.start.line + 1
|
||||
let l:column = l:item.range.start.character + 1
|
||||
if has_key(l:item, 'targetUri')
|
||||
" LocationLink items use targetUri
|
||||
let l:filename = ale#path#FromURI(l:item.targetUri)
|
||||
let l:line = l:item.targetRange.start.line + 1
|
||||
let l:column = l:item.targetRange.start.character + 1
|
||||
else
|
||||
" LocationLink items use uri
|
||||
let l:filename = ale#path#FromURI(l:item.uri)
|
||||
let l:line = l:item.range.start.line + 1
|
||||
let l:column = l:item.range.start.character + 1
|
||||
endif
|
||||
|
||||
call ale#definition#UpdateTagStack()
|
||||
call ale#util#Open(l:filename, l:line, l:column, l:options)
|
||||
@ -92,11 +100,19 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor
|
||||
call ale#lsp#RegisterCallback(l:id, l:Callback)
|
||||
|
||||
if a:linter.lsp is# 'tsserver'
|
||||
let l:message = ale#lsp#tsserver_message#Definition(
|
||||
\ l:buffer,
|
||||
\ a:line,
|
||||
\ a:column
|
||||
\)
|
||||
if a:capability is# 'definition'
|
||||
let l:message = ale#lsp#tsserver_message#Definition(
|
||||
\ l:buffer,
|
||||
\ a:line,
|
||||
\ a:column
|
||||
\)
|
||||
elseif a:capability is# 'typeDefinition'
|
||||
let l:message = ale#lsp#tsserver_message#TypeDefinition(
|
||||
\ l:buffer,
|
||||
\ a:line,
|
||||
\ a:column
|
||||
\)
|
||||
endif
|
||||
else
|
||||
" Send a message saying the buffer has changed first, or the
|
||||
" definition position probably won't make sense.
|
||||
@ -145,12 +161,6 @@ endfunction
|
||||
function! ale#definition#GoToType(options) abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
" TODO: handle typeDefinition for tsserver if supported by the
|
||||
" protocol
|
||||
if l:linter.lsp is# 'tsserver'
|
||||
continue
|
||||
endif
|
||||
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition')
|
||||
endif
|
||||
endfor
|
||||
|
24
sources_non_forked/ale/autoload/ale/dhall.vim
Normal file
24
sources_non_forked/ale/autoload/ale/dhall.vim
Normal file
@ -0,0 +1,24 @@
|
||||
" Author: Pat Brisbin <pbrisbin@gmail.com>, toastal <toastal@protonmail.com>
|
||||
" Description: Functions for working with Dhall’s executable
|
||||
|
||||
call ale#Set('dhall_executable', 'dhall')
|
||||
call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('dhall_options', '')
|
||||
|
||||
function! ale#dhall#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'dhall_executable')
|
||||
|
||||
" Dhall is written in Haskell and commonly installed with Stack
|
||||
return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall')
|
||||
endfunction
|
||||
|
||||
function! ale#dhall#GetExecutableWithOptions(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutable(a:buffer)
|
||||
|
||||
return l:executable
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'dhall_options'))
|
||||
endfunction
|
||||
|
||||
function! ale#dhall#GetCommand(buffer) abort
|
||||
return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options'))
|
||||
endfunction
|
@ -413,6 +413,7 @@ function! s:RunJob(command, options) abort
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:cwd = a:options.cwd
|
||||
let l:executable = a:options.executable
|
||||
let l:buffer = a:options.buffer
|
||||
let l:linter = a:options.linter
|
||||
@ -425,6 +426,7 @@ function! s:RunJob(command, options) abort
|
||||
\ 'executable': l:executable,
|
||||
\}])
|
||||
let l:result = ale#command#Run(l:buffer, l:command, l:Callback, {
|
||||
\ 'cwd': l:cwd,
|
||||
\ 'output_stream': l:output_stream,
|
||||
\ 'executable': l:executable,
|
||||
\ 'read_buffer': l:read_buffer,
|
||||
@ -541,8 +543,22 @@ function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort
|
||||
let l:job_type = a:lint_file ? 'file_linter' : 'linter'
|
||||
call setbufvar(a:buffer, 'ale_job_type', l:job_type)
|
||||
|
||||
" Get the cwd for the linter and set it before we call GetCommand.
|
||||
" This will ensure that ale#command#Run uses it by default.
|
||||
let l:cwd = ale#linter#GetCwd(a:buffer, a:linter)
|
||||
|
||||
if l:cwd isnot v:null
|
||||
call ale#command#SetCwd(a:buffer, l:cwd)
|
||||
endif
|
||||
|
||||
let l:command = ale#linter#GetCommand(a:buffer, a:linter)
|
||||
|
||||
if l:cwd isnot v:null
|
||||
call ale#command#ResetCwd(a:buffer)
|
||||
endif
|
||||
|
||||
let l:options = {
|
||||
\ 'cwd': l:cwd,
|
||||
\ 'executable': a:executable,
|
||||
\ 'buffer': a:buffer,
|
||||
\ 'linter': a:linter,
|
||||
|
@ -172,6 +172,7 @@ function! s:RunJob(result, options) abort
|
||||
let l:read_temporary_file = get(a:result, 'read_temporary_file', 0)
|
||||
let l:read_buffer = get(a:result, 'read_buffer', 1)
|
||||
let l:output_stream = get(a:result, 'output_stream', 'stdout')
|
||||
let l:cwd = get(a:result, 'cwd', v:null)
|
||||
|
||||
if l:read_temporary_file
|
||||
let l:output_stream = 'none'
|
||||
@ -190,6 +191,7 @@ function! s:RunJob(result, options) abort
|
||||
\ 'read_buffer': l:read_buffer,
|
||||
\ 'input': l:input,
|
||||
\ 'log_output': 0,
|
||||
\ 'cwd': l:cwd,
|
||||
\ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:fixer_name),
|
||||
\})
|
||||
|
||||
|
@ -32,11 +32,42 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix PEP8 issues with black.',
|
||||
\ },
|
||||
\ 'buildifier': {
|
||||
\ 'function': 'ale#fixers#buildifier#Fix',
|
||||
\ 'suggested_filetypes': ['bzl'],
|
||||
\ 'description': 'Format BUILD and .bzl files with buildifier.',
|
||||
\ },
|
||||
\ 'deno': {
|
||||
\ 'function': 'ale#fixers#deno#Fix',
|
||||
\ 'suggested_filetypes': ['typescript'],
|
||||
\ 'description': 'Fix TypeScript using deno fmt.',
|
||||
\ },
|
||||
\ 'dfmt': {
|
||||
\ 'function': 'ale#fixers#dfmt#Fix',
|
||||
\ 'suggested_filetypes': ['d'],
|
||||
\ 'description': 'Fix D files with dfmt.',
|
||||
\ },
|
||||
\ 'dhall': {
|
||||
\ 'function': 'ale#fixers#dhall#Fix',
|
||||
\ 'suggested_filetypes': ['dhall'],
|
||||
\ 'description': 'Fix Dhall files with dhall-format.',
|
||||
\ },
|
||||
\ 'dhall-format': {
|
||||
\ 'function': 'ale#fixers#dhall_format#Fix',
|
||||
\ 'suggested_filetypes': ['dhall'],
|
||||
\ 'description': 'Standard code formatter for the Dhall language',
|
||||
\ 'aliases': ['dhall'],
|
||||
\ },
|
||||
\ 'dhall-freeze': {
|
||||
\ 'function': 'ale#fixers#dhall_freeze#Freeze',
|
||||
\ 'suggested_filetypes': ['dhall'],
|
||||
\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language',
|
||||
\ },
|
||||
\ 'dhall-lint': {
|
||||
\ 'function': 'ale#fixers#dhall_lint#Fix',
|
||||
\ 'suggested_filetypes': ['dhall'],
|
||||
\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
|
||||
\ },
|
||||
\ 'fecs': {
|
||||
\ 'function': 'ale#fixers#fecs#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
|
||||
@ -81,7 +112,7 @@ let s:default_registry = {
|
||||
\ },
|
||||
\ 'prettier': {
|
||||
\ 'function': 'ale#fixers#prettier#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml'],
|
||||
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'],
|
||||
\ 'description': 'Apply prettier to a file.',
|
||||
\ },
|
||||
\ 'prettier_eslint': {
|
||||
@ -132,7 +163,7 @@ let s:default_registry = {
|
||||
\ },
|
||||
\ 'scalafmt': {
|
||||
\ 'function': 'ale#fixers#scalafmt#Fix',
|
||||
\ 'suggested_filetypes': ['scala'],
|
||||
\ 'suggested_filetypes': ['sbt', 'scala'],
|
||||
\ 'description': 'Fix Scala files using scalafmt',
|
||||
\ },
|
||||
\ 'sorbet': {
|
||||
@ -160,6 +191,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['swift'],
|
||||
\ 'description': 'Apply SwiftFormat to a file.',
|
||||
\ },
|
||||
\ 'apple-swift-format': {
|
||||
\ 'function': 'ale#fixers#appleswiftformat#Fix',
|
||||
\ 'suggested_filetypes': ['swift'],
|
||||
\ 'description': 'Apply apple/swift-format to a file.',
|
||||
\ },
|
||||
\ 'phpcbf': {
|
||||
\ 'function': 'ale#fixers#phpcbf#Fix',
|
||||
\ 'suggested_filetypes': ['php'],
|
||||
@ -190,6 +226,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['cmake'],
|
||||
\ 'description': 'Fix CMake files with cmake-format.',
|
||||
\ },
|
||||
\ 'fish_indent': {
|
||||
\ 'function': 'ale#fixers#fish_indent#Fix',
|
||||
\ 'suggested_filetypes': ['fish'],
|
||||
\ 'description': 'Format fish scripts using fish_indent.',
|
||||
\ },
|
||||
\ 'gofmt': {
|
||||
\ 'function': 'ale#fixers#gofmt#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
@ -305,6 +346,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['json'],
|
||||
\ 'description': 'Fix JSON files with jq.',
|
||||
\ },
|
||||
\ 'protolint': {
|
||||
\ 'function': 'ale#fixers#protolint#Fix',
|
||||
\ 'suggested_filetypes': ['proto'],
|
||||
\ 'description': 'Fix Protocol Buffer files with protolint.',
|
||||
\ },
|
||||
\ 'perltidy': {
|
||||
\ 'function': 'ale#fixers#perltidy#Fix',
|
||||
\ 'suggested_filetypes': ['perl'],
|
||||
@ -342,7 +388,7 @@ let s:default_registry = {
|
||||
\ },
|
||||
\ 'ktlint': {
|
||||
\ 'function': 'ale#fixers#ktlint#Fix',
|
||||
\ 'suggested_filetypes': ['kt'],
|
||||
\ 'suggested_filetypes': ['kt', 'kotlin'],
|
||||
\ 'description': 'Fix Kotlin files with ktlint.',
|
||||
\ },
|
||||
\ 'styler': {
|
||||
@ -370,6 +416,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['ada'],
|
||||
\ 'description': 'Format Ada files with gnatpp.',
|
||||
\ },
|
||||
\ 'nixfmt': {
|
||||
\ 'function': 'ale#fixers#nixfmt#Fix',
|
||||
\ 'suggested_filetypes': ['nix'],
|
||||
\ 'description': 'A nix formatter written in Haskell.',
|
||||
\ },
|
||||
\ 'nixpkgs-fmt': {
|
||||
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
|
||||
\ 'suggested_filetypes': ['nix'],
|
||||
@ -390,16 +441,21 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['lua'],
|
||||
\ 'description': 'Fix Lua files with luafmt.',
|
||||
\ },
|
||||
\ 'dhall': {
|
||||
\ 'function': 'ale#fixers#dhall#Fix',
|
||||
\ 'suggested_filetypes': ['dhall'],
|
||||
\ 'description': 'Fix Dhall files with dhall-format.',
|
||||
\ },
|
||||
\ 'ormolu': {
|
||||
\ 'function': 'ale#fixers#ormolu#Fix',
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'A formatter for Haskell source code.',
|
||||
\ },
|
||||
\ 'ptop': {
|
||||
\ 'function': 'ale#fixers#ptop#Fix',
|
||||
\ 'suggested_filetypes': ['pascal'],
|
||||
\ 'description': 'Fix Pascal files with ptop.',
|
||||
\ },
|
||||
\ 'vfmt': {
|
||||
\ 'function': 'ale#fixers#vfmt#Fix',
|
||||
\ 'suggested_filetypes': ['v'],
|
||||
\ 'description': 'A formatter for V source code.',
|
||||
\ }
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
@ -0,0 +1,16 @@
|
||||
" Author: (bosr) <bosr@bosr.cc>
|
||||
" Description: Integration of apple/swift-format formatter with ALE.
|
||||
|
||||
function! ale#fixers#appleswiftformat#Fix(buffer) abort
|
||||
let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' format --in-place %t'
|
||||
let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer)
|
||||
|
||||
if l:config_args isnot# ''
|
||||
let l:command_args = l:command_args . ' ' . l:config_args
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': l:command_args,
|
||||
\}
|
||||
endfunction
|
@ -19,7 +19,9 @@ function! ale#fixers#autoimport#Fix(buffer) abort
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -',
|
||||
\}
|
||||
endfunction
|
||||
|
@ -17,25 +17,25 @@ function! ale#fixers#black#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#black#Fix(buffer) abort
|
||||
let l:cd_string = ale#Var(a:buffer, 'python_black_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
let l:executable = ale#fixers#black#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run black'
|
||||
\ : ''
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_black_options')
|
||||
|
||||
if expand('#' . a:buffer . ':e') is? 'pyi'
|
||||
let l:options .= '--pyi'
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
|
||||
let l:result = {
|
||||
\ 'command': ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -',
|
||||
\}
|
||||
|
||||
if ale#Var(a:buffer, 'python_black_change_directory')
|
||||
let l:result.cwd = '%s:h'
|
||||
endif
|
||||
|
||||
return l:result
|
||||
endfunction
|
||||
|
26
sources_non_forked/ale/autoload/ale/fixers/buildifier.vim
Normal file
26
sources_non_forked/ale/autoload/ale/fixers/buildifier.vim
Normal file
@ -0,0 +1,26 @@
|
||||
" Author: Jon Parise <jon@indelible.org>
|
||||
" Description: Format Bazel BUILD and .bzl files with buildifier.
|
||||
"
|
||||
call ale#Set('bazel_buildifier_executable', 'buildifier')
|
||||
call ale#Set('bazel_buildifier_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('bazel_buildifier_options', '')
|
||||
|
||||
function! ale#fixers#buildifier#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'bazel_buildifier', [
|
||||
\ 'buildifier',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#buildifier#Fix(buffer) abort
|
||||
let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer))
|
||||
let l:options = ale#Var(a:buffer, 'bazel_buildifier_options')
|
||||
let l:filename = ale#Escape(bufname(a:buffer))
|
||||
|
||||
let l:command = l:executable . ' -mode fix -lint fix -path ' . l:filename
|
||||
|
||||
if l:options isnot# ''
|
||||
let l:command .= ' ' . l:options
|
||||
endif
|
||||
|
||||
return {'command': l:command . ' -'}
|
||||
endfunction
|
@ -5,6 +5,8 @@ scriptencoding utf-8
|
||||
call ale#Set('c_clangformat_executable', 'clang-format')
|
||||
call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('c_clangformat_options', '')
|
||||
call ale#Set('c_clangformat_style_option', '')
|
||||
call ale#Set('c_clangformat_use_local_file', 0)
|
||||
|
||||
function! ale#fixers#clangformat#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'c_clangformat', [
|
||||
@ -16,6 +18,24 @@ function! ale#fixers#clangformat#Fix(buffer) abort
|
||||
let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
|
||||
let l:filename = ale#Escape(bufname(a:buffer))
|
||||
let l:options = ale#Var(a:buffer, 'c_clangformat_options')
|
||||
let l:style_option = ale#Var(a:buffer, 'c_clangformat_style_option')
|
||||
let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file')
|
||||
|
||||
if l:style_option isnot# ''
|
||||
let l:style_option = '-style=' . "'" . l:style_option . "'"
|
||||
endif
|
||||
|
||||
if l:use_local_file
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.clang-format')
|
||||
|
||||
if !empty(l:config)
|
||||
let l:style_option = '-style=file'
|
||||
endif
|
||||
endif
|
||||
|
||||
if l:style_option isnot# ''
|
||||
let l:options .= ' ' . l:style_option
|
||||
endif
|
||||
|
||||
let l:command = l:executable . ' --assume-filename=' . l:filename
|
||||
|
||||
|
17
sources_non_forked/ale/autoload/ale/fixers/deno.vim
Normal file
17
sources_non_forked/ale/autoload/ale/fixers/deno.vim
Normal file
@ -0,0 +1,17 @@
|
||||
function! ale#fixers#deno#Fix(buffer) abort
|
||||
let l:executable = ale#handlers#deno#GetExecutable(a:buffer)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:options = ' fmt -'
|
||||
|
||||
if ale#Var(a:buffer, 'deno_unstable')
|
||||
let l:options = l:options . ' --unstable'
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . l:options
|
||||
\}
|
||||
endfunction
|
@ -1,23 +0,0 @@
|
||||
" Author: Pat Brisbin <pbrisbin@gmail.com>
|
||||
" Description: Integration of dhall-format with ALE.
|
||||
|
||||
call ale#Set('dhall_format_executable', 'dhall')
|
||||
|
||||
function! ale#fixers#dhall#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'dhall_format_executable')
|
||||
|
||||
" Dhall is written in Haskell and commonly installed with Stack
|
||||
return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall')
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#dhall#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#dhall#GetExecutable(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': l:executable
|
||||
\ . ' format'
|
||||
\ . ' --inplace'
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
14
sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim
Normal file
14
sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim
Normal file
@ -0,0 +1,14 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Description: Dhall’s built-in formatter
|
||||
"
|
||||
function! ale#fixers#dhall_format#Fix(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' format'
|
||||
\ . ' --inplace %t'
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
18
sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim
Normal file
18
sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim
Normal file
@ -0,0 +1,18 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Description: Dhall’s package freezing
|
||||
|
||||
call ale#Set('dhall_freeze_options', '')
|
||||
|
||||
function! ale#fixers#dhall_freeze#Freeze(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' freeze'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options'))
|
||||
\ . ' --inplace %t'
|
||||
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
14
sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim
Normal file
14
sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim
Normal file
@ -0,0 +1,14 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Description: Dhall’s built-in linter/formatter
|
||||
|
||||
function! ale#fixers#dhall_lint#Fix(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' lint'
|
||||
\ . ' --inplace %t'
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
21
sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim
Normal file
21
sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim
Normal file
@ -0,0 +1,21 @@
|
||||
" Author: AntoineGagne - https://github.com/AntoineGagne
|
||||
" Description: Integration of erlfmt with ALE.
|
||||
|
||||
call ale#Set('erlang_erlfmt_executable', 'erlfmt')
|
||||
call ale#Set('erlang_erlfmt_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('erlang_erlfmt_options', '')
|
||||
|
||||
function! ale#fixers#erlfmt#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt'])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#erlfmt#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'erlang_erlfmt_options')
|
||||
let l:executable = ale#fixers#erlfmt#GetExecutable(a:buffer)
|
||||
|
||||
let l:command = ale#Escape(l:executable) . (empty(l:options) ? '' : ' ' . l:options) . ' %s'
|
||||
|
||||
return {
|
||||
\ 'command': l:command
|
||||
\}
|
||||
endfunction
|
@ -53,8 +53,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort
|
||||
" Use --fix-to-stdout with eslint_d
|
||||
if l:executable =~# 'eslint_d$' && ale#semver#GTE(a:version, [3, 19, 0])
|
||||
return {
|
||||
\ 'command': ale#handlers#eslint#GetCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
\ 'cwd': ale#handlers#eslint#GetCwd(a:buffer),
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
@ -64,8 +64,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort
|
||||
" 4.9.0 is the first version with --fix-dry-run
|
||||
if ale#semver#GTE(a:version, [4, 9, 0])
|
||||
return {
|
||||
\ 'command': ale#handlers#eslint#GetCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
\ 'cwd': ale#handlers#eslint#GetCwd(a:buffer),
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
@ -73,8 +73,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#handlers#eslint#GetCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
\ 'cwd': ale#handlers#eslint#GetCwd(a:buffer),
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ale#Pad(l:options)
|
||||
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
|
||||
\ . ' --fix %t',
|
||||
|
19
sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim
Normal file
19
sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim
Normal file
@ -0,0 +1,19 @@
|
||||
" Author: Chen YuanYuan <cyyever@outlook.com>
|
||||
" Description: Integration of fish_indent with ALE.
|
||||
|
||||
call ale#Set('fish_fish_indent_executable', 'fish_indent')
|
||||
call ale#Set('fish_fish_indent_options', '')
|
||||
|
||||
function! ale#fixers#fish_indent#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'fish_fish_indent_executable')
|
||||
let l:options = ale#Var(a:buffer, 'fish_fish_indent_options')
|
||||
let l:filename = ale#Escape(bufname(a:buffer))
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -w '
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
@ -2,24 +2,33 @@
|
||||
" Description: Fixing Python imports with isort.
|
||||
|
||||
call ale#Set('python_isort_executable', 'isort')
|
||||
call ale#Set('python_isort_options', '')
|
||||
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_isort_options', '')
|
||||
call ale#Set('python_isort_auto_pipenv', 0)
|
||||
|
||||
function! ale#fixers#isort#GetExecutable(buffer) abort
|
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv'))
|
||||
\ && ale#python#PipenvPresent(a:buffer)
|
||||
return 'pipenv'
|
||||
endif
|
||||
|
||||
return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#isort#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'python_isort_options')
|
||||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run isort'
|
||||
\ : ''
|
||||
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'python_isort',
|
||||
\ ['isort'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
if !executable(l:executable) && l:executable isnot# 'pipenv'
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\}
|
||||
endfunction
|
||||
|
15
sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim
Normal file
15
sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim
Normal file
@ -0,0 +1,15 @@
|
||||
scriptencoding utf-8
|
||||
" Author: houstdav000 <houstdav000@gh0st.sh>
|
||||
" Description: Fix files with nixfmt
|
||||
|
||||
call ale#Set('nix_nixfmt_executable', 'nixfmt')
|
||||
call ale#Set('nix_nixfmt_options', '')
|
||||
|
||||
function! ale#fixers#nixfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'nix_nixfmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'nix_nixfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ale#Pad(l:options),
|
||||
\}
|
||||
endfunction
|
@ -34,19 +34,11 @@ function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort
|
||||
return a:output
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#prettier#GetProjectRoot(buffer) abort
|
||||
function! ale#fixers#prettier#GetCwd(buffer) abort
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.prettierignore')
|
||||
|
||||
if !empty(l:config)
|
||||
return fnamemodify(l:config, ':h')
|
||||
endif
|
||||
|
||||
" Fall back to the directory of the buffer
|
||||
return fnamemodify(bufname(a:buffer), ':p:h')
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#prettier#CdProjectRoot(buffer) abort
|
||||
return ale#path#CdString(ale#fixers#prettier#GetProjectRoot(a:buffer))
|
||||
return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
@ -82,8 +74,11 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
\ 'graphql': 'graphql',
|
||||
\ 'markdown': 'markdown',
|
||||
\ 'vue': 'vue',
|
||||
\ 'svelte': 'svelte',
|
||||
\ 'yaml': 'yaml',
|
||||
\ 'openapi': 'yaml',
|
||||
\ 'html': 'html',
|
||||
\ 'ruby': 'ruby',
|
||||
\}
|
||||
|
||||
for l:filetype in l:filetypes
|
||||
@ -101,8 +96,8 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
" Special error handling needed for prettier_d
|
||||
if l:executable =~# 'prettier_d$'
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command':ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput',
|
||||
@ -112,8 +107,8 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
" 1.4.0 is the first version with --stdin-filepath
|
||||
if ale#semver#GTE(a:version, [1, 4, 0])
|
||||
return {
|
||||
\ 'command': ale#fixers#prettier#CdProjectRoot(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ 'cwd': ale#fixers#prettier#GetCwd(a:buffer),
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\}
|
||||
|
@ -37,8 +37,8 @@ function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version) abort
|
||||
" 4.4.0 is the first version with --stdin-filepath
|
||||
if ale#semver#GTE(a:version, [4, 4, 0])
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . l:eslint_config_option
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
|
26
sources_non_forked/ale/autoload/ale/fixers/protolint.vim
Normal file
26
sources_non_forked/ale/autoload/ale/fixers/protolint.vim
Normal file
@ -0,0 +1,26 @@
|
||||
" Author: Yohei Yoshimuta <yoheimuta@gmail.com>
|
||||
" Description: Integration of protolint with ALE.
|
||||
|
||||
call ale#Set('proto_protolint_executable', 'protolint')
|
||||
call ale#Set('proto_protolint_config', '')
|
||||
|
||||
function! ale#fixers#protolint#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'proto_protolint_executable')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#protolint#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#protolint#GetExecutable(a:buffer)
|
||||
let l:config = ale#Var(a:buffer, 'proto_protolint_config')
|
||||
|
||||
return {
|
||||
\ 'command': l:executable
|
||||
\ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '')
|
||||
\ . ' -fix'
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
|
17
sources_non_forked/ale/autoload/ale/fixers/ptop.vim
Normal file
17
sources_non_forked/ale/autoload/ale/fixers/ptop.vim
Normal file
@ -0,0 +1,17 @@
|
||||
" Author: BarrOff https://github.com/BarrOff
|
||||
" Description: Integration of ptop with ALE.
|
||||
|
||||
call ale#Set('pascal_ptop_executable', 'ptop')
|
||||
call ale#Set('pascal_ptop_options', '')
|
||||
|
||||
function! ale#fixers#ptop#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'pascal_ptop_executable')
|
||||
let l:options = ale#Var(a:buffer, 'pascal_ptop_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %s %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
@ -12,12 +12,12 @@ function! ale#fixers#standardrb#GetCommand(buffer) abort
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'standardrb')
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --fix --force-exclusion %t'
|
||||
\ . ' --fix --force-exclusion --stdin %s'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#standardrb#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#standardrb#GetCommand(a:buffer),
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'process_with': 'ale#fixers#rubocop#PostProcess'
|
||||
\}
|
||||
endfunction
|
||||
|
@ -17,11 +17,10 @@ function! ale#fixers#stylelint#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'stylelint_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' %t'
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' --fix',
|
||||
\ 'read_temporary_file': 1,
|
||||
\ . ' --fix --stdin --stdin-filename %s',
|
||||
\ 'read_temporary_file': 0,
|
||||
\}
|
||||
endfunction
|
||||
|
13
sources_non_forked/ale/autoload/ale/fixers/vfmt.vim
Normal file
13
sources_non_forked/ale/autoload/ale/fixers/vfmt.vim
Normal file
@ -0,0 +1,13 @@
|
||||
" Author: fiatjaf <fiatjaf@alhur.es>
|
||||
" Description: Integration of `v fmt` with ALE.
|
||||
|
||||
call ale#Set('v_vfmt_options', '')
|
||||
|
||||
function! ale#fixers#vfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'v_v_executable')
|
||||
let l:options = ale#Var(a:buffer, 'v_vfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' fmt' . ale#Pad(l:options)
|
||||
\}
|
||||
endfunction
|
@ -1,23 +1,36 @@
|
||||
" Author: Albert Marquez - https://github.com/a-marquez
|
||||
" Description: Fixing files with XO.
|
||||
|
||||
call ale#Set('javascript_xo_executable', 'xo')
|
||||
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_xo_options', '')
|
||||
function! ale#fixers#xo#Fix(buffer) abort
|
||||
let l:executable = ale#handlers#xo#GetExecutable(a:buffer)
|
||||
let l:options = ale#handlers#xo#GetOptions(a:buffer)
|
||||
|
||||
function! ale#fixers#xo#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
|
||||
\ 'node_modules/xo/cli.js',
|
||||
\ 'node_modules/.bin/xo',
|
||||
\])
|
||||
return ale#semver#RunWithVersionCheck(
|
||||
\ a:buffer,
|
||||
\ l:executable,
|
||||
\ '%e --version',
|
||||
\ {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)}
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#xo#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#xo#GetExecutable(a:buffer)
|
||||
function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort
|
||||
let l:executable = ale#node#Executable(a:buffer, a:executable)
|
||||
let l:options = ale#Pad(a:options)
|
||||
|
||||
" 0.30.0 is the first version with a working --stdin --fix
|
||||
if ale#semver#GTE(a:version, [0, 30, 0])
|
||||
return {
|
||||
\ 'command': l:executable
|
||||
\ . ' --stdin --stdin-filename %s'
|
||||
\ . ' --fix'
|
||||
\ . l:options,
|
||||
\}
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --fix %t',
|
||||
\ 'command': l:executable
|
||||
\ . ' --fix %t'
|
||||
\ . l:options,
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
@ -7,7 +7,6 @@ call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0)
|
||||
|
||||
function! ale#fixers#yamlfix#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options')
|
||||
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'yaml_yamlfix',
|
||||
@ -19,7 +18,8 @@ function! ale#fixers#yamlfix#Fix(buffer) abort
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\}
|
||||
endfunction
|
||||
|
134
sources_non_forked/ale/autoload/ale/floating_preview.vim
Normal file
134
sources_non_forked/ale/autoload/ale/floating_preview.vim
Normal file
@ -0,0 +1,134 @@
|
||||
" Author: Jan-Grimo Sobez <jan-grimo.sobez@phys.chem.ethz.ch>
|
||||
" Author: Kevin Clark <kevin.clark@gmail.com>
|
||||
" Description: Floating preview window for showing whatever information in.
|
||||
|
||||
" Precondition: exists('*nvim_open_win')
|
||||
|
||||
function! ale#floating_preview#Show(lines, ...) abort
|
||||
if !exists('*nvim_open_win')
|
||||
execute 'echom ''Floating windows not supported in this vim instance.'''
|
||||
|
||||
return
|
||||
endif
|
||||
|
||||
" Remove the close autocmd so it doesn't happen mid update
|
||||
augroup ale_floating_preview_window
|
||||
autocmd!
|
||||
augroup END
|
||||
|
||||
let l:options = get(a:000, 0, {})
|
||||
|
||||
" Only create a new window if we need it
|
||||
if !exists('w:preview') || index(nvim_list_wins(), w:preview['id']) is# -1
|
||||
call s:Create(l:options)
|
||||
else
|
||||
call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:true)
|
||||
endif
|
||||
|
||||
" Execute commands in window context
|
||||
let l:parent_window = nvim_get_current_win()
|
||||
|
||||
call nvim_set_current_win(w:preview['id'])
|
||||
|
||||
for l:command in get(l:options, 'commands', [])
|
||||
call execute(l:command)
|
||||
endfor
|
||||
|
||||
call nvim_set_current_win(l:parent_window)
|
||||
|
||||
" Return to parent context on move
|
||||
augroup ale_floating_preview_window
|
||||
autocmd!
|
||||
|
||||
if g:ale_close_preview_on_insert
|
||||
autocmd CursorMoved,TabLeave,WinLeave,InsertEnter <buffer> ++once call s:Close()
|
||||
else
|
||||
autocmd CursorMoved,TabLeave,WinLeave <buffer> ++once call s:Close()
|
||||
endif
|
||||
augroup END
|
||||
|
||||
let [l:lines, l:width, l:height] = s:PrepareWindowContent(a:lines)
|
||||
|
||||
call nvim_win_set_width(w:preview['id'], l:width)
|
||||
call nvim_win_set_height(w:preview['id'], l:height)
|
||||
call nvim_buf_set_lines(w:preview['buffer'], 0, -1, v:false, l:lines)
|
||||
call nvim_buf_set_option(w:preview['buffer'], 'modified', v:false)
|
||||
call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:false)
|
||||
endfunction
|
||||
|
||||
function! s:PrepareWindowContent(lines) abort
|
||||
let l:max_height = 10
|
||||
|
||||
let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)'))
|
||||
let l:height = min([len(a:lines), l:max_height])
|
||||
|
||||
if empty(g:ale_floating_window_border)
|
||||
return [a:lines, l:width, l:height]
|
||||
endif
|
||||
|
||||
" Add the size of borders
|
||||
let l:width += 2
|
||||
let l:height += 2
|
||||
|
||||
let l:hor = g:ale_floating_window_border[0]
|
||||
let l:top = g:ale_floating_window_border[1]
|
||||
let l:top_left = g:ale_floating_window_border[2]
|
||||
let l:top_right = g:ale_floating_window_border[3]
|
||||
let l:bottom_right = g:ale_floating_window_border[4]
|
||||
let l:bottom_left = g:ale_floating_window_border[5]
|
||||
|
||||
let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right]
|
||||
|
||||
for l:line in a:lines
|
||||
let l:line_width = strchars(l:line)
|
||||
let l:lines = add(l:lines, l:hor . l:line . repeat(' ', l:width - l:line_width - 2). l:hor)
|
||||
endfor
|
||||
|
||||
" Truncate the lines
|
||||
if len(l:lines) > l:max_height + 1
|
||||
let l:lines = l:lines[0:l:max_height]
|
||||
endif
|
||||
|
||||
let l:lines = add(l:lines, l:bottom_left . repeat(l:top, l:width - 2) . l:bottom_right)
|
||||
|
||||
return [l:lines, l:width, l:height]
|
||||
endfunction
|
||||
|
||||
function! s:Create(options) abort
|
||||
let l:buffer = nvim_create_buf(v:false, v:false)
|
||||
let l:winid = nvim_open_win(l:buffer, v:false, {
|
||||
\ 'relative': 'cursor',
|
||||
\ 'row': 1,
|
||||
\ 'col': 0,
|
||||
\ 'width': 42,
|
||||
\ 'height': 4,
|
||||
\ 'style': 'minimal'
|
||||
\ })
|
||||
call nvim_buf_set_option(l:buffer, 'buftype', 'acwrite')
|
||||
call nvim_buf_set_option(l:buffer, 'bufhidden', 'delete')
|
||||
call nvim_buf_set_option(l:buffer, 'swapfile', v:false)
|
||||
call nvim_buf_set_option(l:buffer, 'filetype', get(a:options, 'filetype', 'ale-preview'))
|
||||
|
||||
let w:preview = {'id': l:winid, 'buffer': l:buffer}
|
||||
endfunction
|
||||
|
||||
function! s:Close() abort
|
||||
let l:mode = mode()
|
||||
let l:restore_visual = l:mode is# 'v' || l:mode is# 'V' || l:mode is# "\<C-V>"
|
||||
|
||||
if !exists('w:preview')
|
||||
return
|
||||
endif
|
||||
|
||||
call setbufvar(w:preview['buffer'], '&modified', 0)
|
||||
|
||||
if win_id2win(w:preview['id']) > 0
|
||||
execute win_id2win(w:preview['id']).'wincmd c'
|
||||
endif
|
||||
|
||||
unlet w:preview
|
||||
|
||||
if l:restore_visual
|
||||
normal! gv
|
||||
endif
|
||||
endfunction
|
@ -50,18 +50,25 @@ function! ale#gradle#FindExecutable(buffer) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Given a buffer number, build a command to print the classpath of the root
|
||||
" project. Returns an empty string if cannot build the command.
|
||||
" Given a buffer number, get a working directory and command to print the
|
||||
" classpath of the root project.
|
||||
"
|
||||
" Returns an empty string for the command if Gradle is not detected.
|
||||
function! ale#gradle#BuildClasspathCommand(buffer) abort
|
||||
let l:executable = ale#gradle#FindExecutable(a:buffer)
|
||||
let l:project_root = ale#gradle#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:executable) && !empty(l:project_root)
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' -I ' . ale#Escape(s:init_path)
|
||||
\ . ' -q printClasspath'
|
||||
if !empty(l:executable)
|
||||
let l:project_root = ale#gradle#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:project_root)
|
||||
return [
|
||||
\ l:project_root,
|
||||
\ ale#Escape(l:executable)
|
||||
\ . ' -I ' . ale#Escape(s:init_path)
|
||||
\ . ' -q printClasspath'
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
41
sources_non_forked/ale/autoload/ale/handlers/atools.vim
Normal file
41
sources_non_forked/ale/autoload/ale/handlers/atools.vim
Normal file
@ -0,0 +1,41 @@
|
||||
" Author: Leo <thinkabit.ukim@gmail.com>
|
||||
" Description: Handlers for output expected from atools
|
||||
|
||||
function! ale#handlers#atools#Handle(buffer, lines) abort
|
||||
" Format: SEVERITY:[TAG]:PATH:LINENUM:MSG
|
||||
" Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install=
|
||||
let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
" We are expected to receive 2 characters, the first character
|
||||
" can be 'S', 'I', 'M' 'T', which are respectively:
|
||||
" Serious (Error)
|
||||
" Important (Error)
|
||||
" Minor (Warning)
|
||||
" Style (Warning)
|
||||
"
|
||||
" The second character can be either 'C' or 'P', which are respectively:
|
||||
" Certain (Error)
|
||||
" Possible (Warning)
|
||||
let l:severity = matchstr(l:match[1], '^.')
|
||||
let l:certainty = matchstr(l:match[1], '.$')
|
||||
|
||||
let l:type = 'E'
|
||||
" If the tag returns 'Minor' or 'Style' or is 'Possible'
|
||||
" then return a warning
|
||||
|
||||
if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P'
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'type': l:type,
|
||||
\ 'code': matchstr(l:match[2], 'AL[0-9]*'),
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
@ -1,10 +1,9 @@
|
||||
" Description: Handle errors for cppcheck.
|
||||
|
||||
function! ale#handlers#cppcheck#GetCdCommand(buffer) abort
|
||||
function! ale#handlers#cppcheck#GetCwd(buffer) abort
|
||||
let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer)
|
||||
let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : ''
|
||||
|
||||
return l:cd_command
|
||||
return !empty(l:dir) ? l:dir : ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort
|
||||
|
52
sources_non_forked/ale/autoload/ale/handlers/deno.vim
Normal file
52
sources_non_forked/ale/autoload/ale/handlers/deno.vim
Normal file
@ -0,0 +1,52 @@
|
||||
" Author: Mohammed Chelouti - https://github.com/motato1
|
||||
" Description: Handler functions for Deno.
|
||||
|
||||
call ale#Set('deno_executable', 'deno')
|
||||
call ale#Set('deno_unstable', 0)
|
||||
call ale#Set('deno_lsp_project_root', '')
|
||||
|
||||
function! ale#handlers#deno#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'deno_executable')
|
||||
endfunction
|
||||
|
||||
" Find project root for Deno's language server.
|
||||
"
|
||||
" Deno projects do not require a project or configuration file at the project root.
|
||||
" This means the root directory has to be guessed,
|
||||
" unless it is explicitly specified by the user.
|
||||
"
|
||||
" The project root is determined by ...
|
||||
" 1. using a user-specified value from deno_lsp_project_root
|
||||
" 2. looking for common top-level files/dirs
|
||||
" 3. using the buffer's directory
|
||||
function! ale#handlers#deno#GetProjectRoot(buffer) abort
|
||||
let l:project_root = ale#Var(a:buffer, 'deno_lsp_project_root')
|
||||
|
||||
if !empty(l:project_root)
|
||||
return l:project_root
|
||||
endif
|
||||
|
||||
let l:possible_project_roots = [
|
||||
\ 'tsconfig.json',
|
||||
\ '.git',
|
||||
\ bufname(a:buffer),
|
||||
\]
|
||||
|
||||
for l:possible_root in l:possible_project_roots
|
||||
let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root)
|
||||
|
||||
if empty(l:project_root)
|
||||
let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root)
|
||||
endif
|
||||
|
||||
if !empty(l:project_root)
|
||||
" dir:p expands to /full/path/to/dir/ whereas
|
||||
" file:p expands to /full/path/to/file (no trailing slash)
|
||||
" Appending '/' ensures that :h:h removes the path's last segment
|
||||
" regardless of whether it is a directory or not.
|
||||
return fnamemodify(l:project_root . '/', ':p:h:h')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
@ -39,9 +39,8 @@ function! ale#handlers#eslint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_eslint', s:executables)
|
||||
endfunction
|
||||
|
||||
" Given a buffer, return a command prefix string which changes directory
|
||||
" as necessary for running ESLint.
|
||||
function! ale#handlers#eslint#GetCdString(buffer) abort
|
||||
" Given a buffer, return an appropriate working directory for ESLint.
|
||||
function! ale#handlers#eslint#GetCwd(buffer) abort
|
||||
" ESLint 6 loads plugins/configs/parsers from the project root
|
||||
" By default, the project root is simply the CWD of the running process.
|
||||
" https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md
|
||||
@ -60,7 +59,7 @@ function! ale#handlers#eslint#GetCdString(buffer) abort
|
||||
let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
|
||||
endif
|
||||
|
||||
return !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : ''
|
||||
return !empty(l:project_dir) ? l:project_dir : ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#eslint#GetCommand(buffer) abort
|
||||
@ -68,8 +67,7 @@ function! ale#handlers#eslint#GetCommand(buffer) abort
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'javascript_eslint_options')
|
||||
|
||||
return ale#handlers#eslint#GetCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -f json --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
@ -32,6 +32,8 @@ function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort
|
||||
if ale#handlers#hdl_checker#IsDotGit(l:project_root)
|
||||
return fnamemodify(l:project_root, ':h:h')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#hdl_checker#GetExecutable(buffer) abort
|
||||
|
37
sources_non_forked/ale/autoload/ale/handlers/inko.vim
Normal file
37
sources_non_forked/ale/autoload/ale/handlers/inko.vim
Normal file
@ -0,0 +1,37 @@
|
||||
" Author: Yorick Peterse <yorick@yorickpeterse.com>
|
||||
" Description: output handlers for the Inko JSON format
|
||||
|
||||
function! ale#handlers#inko#GetType(severity) abort
|
||||
if a:severity is? 'warning'
|
||||
return 'W'
|
||||
endif
|
||||
|
||||
return 'E'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#inko#Handle(buffer, lines) abort
|
||||
try
|
||||
let l:errors = json_decode(join(a:lines, ''))
|
||||
catch
|
||||
return []
|
||||
endtry
|
||||
|
||||
if empty(l:errors)
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:output = []
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
|
||||
for l:error in l:errors
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']),
|
||||
\ 'lnum': l:error['line'],
|
||||
\ 'col': l:error['column'],
|
||||
\ 'text': l:error['message'],
|
||||
\ 'type': ale#handlers#inko#GetType(l:error['level']),
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
23
sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim
Normal file
23
sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim
Normal file
@ -0,0 +1,23 @@
|
||||
" Author: Risto Stevcev <me@risto.codes>
|
||||
" Description: Handlers for the official OCaml language server
|
||||
|
||||
function! ale#handlers#ocamllsp#GetExecutable(buffer) abort
|
||||
return 'ocamllsp'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#ocamllsp#GetCommand(buffer) abort
|
||||
let l:executable = ale#handlers#ocamllsp#GetExecutable(a:buffer)
|
||||
let l:ocaml_ocamllsp_use_opam = ale#Var(a:buffer, 'ocaml_ocamllsp_use_opam')
|
||||
|
||||
return l:ocaml_ocamllsp_use_opam ? 'opam config exec -- ' . l:executable : l:executable
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#ocamllsp#GetLanguage(buffer) abort
|
||||
return getbufvar(a:buffer, '&filetype')
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#ocamllsp#GetProjectRoot(buffer) abort
|
||||
let l:dune_project_file = ale#path#FindNearestFile(a:buffer, 'dune-project')
|
||||
|
||||
return !empty(l:dune_project_file) ? fnamemodify(l:dune_project_file, ':h') : ''
|
||||
endfunction
|
@ -40,21 +40,21 @@ function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#shellcheck#GetCwd(buffer) abort
|
||||
return ale#Var(a:buffer, 'sh_shellcheck_change_directory') ? '%s:h' : ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#shellcheck#GetCommand(buffer, version) abort
|
||||
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
|
||||
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
||||
let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect')
|
||||
let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
|
||||
let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
if l:dialect is# 'auto'
|
||||
let l:dialect = ale#handlers#shellcheck#GetDialectArgument(a:buffer)
|
||||
endif
|
||||
|
||||
return l:cd_string
|
||||
\ . '%e'
|
||||
return '%e'
|
||||
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
|
||||
@ -111,6 +111,7 @@ function! ale#handlers#shellcheck#DefineLinter(filetype) abort
|
||||
call ale#linter#Define(a:filetype, {
|
||||
\ 'name': 'shellcheck',
|
||||
\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
|
||||
\ 'cwd': function('ale#handlers#shellcheck#GetCwd'),
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'sh_shellcheck_executable'),
|
||||
|
98
sources_non_forked/ale/autoload/ale/handlers/solhint.vim
Normal file
98
sources_non_forked/ale/autoload/ale/handlers/solhint.vim
Normal file
@ -0,0 +1,98 @@
|
||||
" Author: Henrique Barcelos <@hbarcelos>
|
||||
" Description: Functions for working with local solhint for checking *.sol files.
|
||||
|
||||
let s:executables = [
|
||||
\ 'node_modules/.bin/solhint',
|
||||
\ 'node_modules/solhint/solhint.js',
|
||||
\ 'solhint',
|
||||
\]
|
||||
|
||||
let s:sep = has('win32') ? '\' : '/'
|
||||
|
||||
call ale#Set('solidity_solhint_options', '')
|
||||
call ale#Set('solidity_solhint_executable', 'solhint')
|
||||
call ale#Set('solidity_solhint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale#handlers#solhint#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars)
|
||||
let l:output = []
|
||||
|
||||
let l:lint_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:lint_pattern)
|
||||
let l:isError = l:match[3] is? 'error'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'code': l:match[5],
|
||||
\ 'type': l:isError ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
let l:syntax_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (Parse error): (.*)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:syntax_pattern)
|
||||
let l:isError = l:match[3] is? 'error'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[4],
|
||||
\ 'type': l:isError ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#solhint#FindConfig(buffer) abort
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
for l:basename in [
|
||||
\ '.solhintrc.js',
|
||||
\ '.solhintrc.json',
|
||||
\ '.solhintrc',
|
||||
\]
|
||||
let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep))
|
||||
|
||||
if filereadable(l:config)
|
||||
return l:config
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ale#path#FindNearestFile(a:buffer, 'package.json')
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#solhint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'solidity_solhint', s:executables)
|
||||
endfunction
|
||||
|
||||
" Given a buffer, return an appropriate working directory for solhint.
|
||||
function! ale#handlers#solhint#GetCwd(buffer) abort
|
||||
" If solhint is installed in a directory which contains the buffer, assume
|
||||
" it is the solhint project root. Otherwise, use nearest node_modules.
|
||||
" Note: If node_modules not present yet, can't load local deps anyway.
|
||||
let l:executable = ale#node#FindNearestExecutable(a:buffer, s:executables)
|
||||
|
||||
if !empty(l:executable)
|
||||
let l:nmi = strridx(l:executable, 'node_modules')
|
||||
let l:project_dir = l:executable[0:l:nmi - 2]
|
||||
else
|
||||
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
|
||||
let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
|
||||
endif
|
||||
|
||||
return !empty(l:project_dir) ? l:project_dir : ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#solhint#GetCommand(buffer) abort
|
||||
let l:executable = ale#handlers#solhint#GetExecutable(a:buffer)
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'solidity_solhint_options')
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --formatter compact %s'
|
||||
endfunction
|
31
sources_non_forked/ale/autoload/ale/handlers/spectral.vim
Normal file
31
sources_non_forked/ale/autoload/ale/handlers/spectral.vim
Normal file
@ -0,0 +1,31 @@
|
||||
" Author: t2h5 <https://github.com/t2h5>
|
||||
" Description: Integration of Stoplight Spectral CLI with ALE.
|
||||
|
||||
function! ale#handlers#spectral#HandleSpectralOutput(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" openapi.yml:1:1 error oas3-schema "Object should have required property `info`."
|
||||
" openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array."
|
||||
let l:pattern = '\v^.*:(\d+):(\d+) (error|warning) (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:obj = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\ 'text': l:match[4],
|
||||
\}
|
||||
|
||||
let l:code_match = matchlist(l:obj.text, '\v^(.+) "(.+)"$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
let l:obj.code = l:code_match[1]
|
||||
let l:obj.text = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:obj)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
44
sources_non_forked/ale/autoload/ale/handlers/xo.vim
Normal file
44
sources_non_forked/ale/autoload/ale/handlers/xo.vim
Normal file
@ -0,0 +1,44 @@
|
||||
call ale#Set('javascript_xo_executable', 'xo')
|
||||
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_xo_options', '')
|
||||
|
||||
call ale#Set('typescript_xo_executable', 'xo')
|
||||
call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('typescript_xo_options', '')
|
||||
|
||||
function! ale#handlers#xo#GetExecutable(buffer) abort
|
||||
let l:type = ale#handlers#xo#GetType(a:buffer)
|
||||
|
||||
return ale#node#FindExecutable(a:buffer, l:type . '_xo', [
|
||||
\ 'node_modules/xo/cli.js',
|
||||
\ 'node_modules/.bin/xo',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#xo#GetLintCommand(buffer) abort
|
||||
return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer))
|
||||
\ . ale#Pad(ale#handlers#xo#GetOptions(a:buffer))
|
||||
\ . ' --reporter json --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#xo#GetOptions(buffer) abort
|
||||
let l:type = ale#handlers#xo#GetType(a:buffer)
|
||||
|
||||
return ale#Var(a:buffer, l:type . '_xo_options')
|
||||
endfunction
|
||||
|
||||
" xo uses eslint and the output format is the same
|
||||
function! ale#handlers#xo#HandleJSON(buffer, lines) abort
|
||||
return ale#handlers#eslint#HandleJSON(a:buffer, a:lines)
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#xo#GetType(buffer) abort
|
||||
let l:filetype = getbufvar(a:buffer, '&filetype')
|
||||
let l:type = 'javascript'
|
||||
|
||||
if l:filetype =~# 'typescript'
|
||||
let l:type = 'typescript'
|
||||
endif
|
||||
|
||||
return l:type
|
||||
endfunction
|
39
sources_non_forked/ale/autoload/ale/handlers/yamllint.vim
Normal file
39
sources_non_forked/ale/autoload/ale/handlers/yamllint.vim
Normal file
@ -0,0 +1,39 @@
|
||||
function! ale#handlers#yamllint#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
|
||||
\ . ' -f parsable %t'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#yamllint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
" something.yaml:1:1: [warning] missing document start "---" (document-start)
|
||||
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
|
||||
let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\}
|
||||
|
||||
let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
if l:code_match[2] is# 'trailing-spaces'
|
||||
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
" Skip warnings for trailing whitespace if the option is off.
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:item.text = l:code_match[1]
|
||||
let l:item.code = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
@ -46,6 +46,10 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
|
||||
call balloon_show(a:response.body.displayString)
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
|
||||
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
|
||||
call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
\})
|
||||
elseif g:ale_hover_to_preview
|
||||
call ale#preview#Show(split(a:response.body.displayString, "\n"), {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
@ -226,6 +230,11 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
|
||||
call balloon_show(join(l:lines, "\n"))
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
call ale#cursor#TruncatedEcho(l:lines[0])
|
||||
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
|
||||
call ale#floating_preview#Show(l:lines, {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
\ 'commands': l:commands,
|
||||
\})
|
||||
elseif g:ale_hover_to_preview
|
||||
call ale#preview#Show(l:lines, {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
|
@ -38,11 +38,13 @@ let s:default_ale_linter_aliases = {
|
||||
"
|
||||
" NOTE: Update the g:ale_linters documentation when modifying this.
|
||||
let s:default_ale_linters = {
|
||||
\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'],
|
||||
\ 'csh': ['shell'],
|
||||
\ 'elixir': ['credo', 'dialyxir', 'dogma'],
|
||||
\ 'go': ['gofmt', 'golint', 'go vet'],
|
||||
\ 'hack': ['hack'],
|
||||
\ 'help': [],
|
||||
\ 'inko': ['inko'],
|
||||
\ 'perl': ['perlcritic'],
|
||||
\ 'perl6': [],
|
||||
\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'],
|
||||
@ -51,6 +53,7 @@ let s:default_ale_linters = {
|
||||
\ 'text': [],
|
||||
\ 'vue': ['eslint', 'vls'],
|
||||
\ 'zsh': ['shell'],
|
||||
\ 'v': ['v'],
|
||||
\}
|
||||
|
||||
" Testing/debugging helper to unload all linters.
|
||||
@ -149,17 +152,30 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
|
||||
let l:obj.address = a:linter.address
|
||||
|
||||
if has_key(a:linter, 'cwd')
|
||||
throw '`cwd` makes no sense for socket LSP connections'
|
||||
endif
|
||||
else
|
||||
throw '`address` must be defined for getting the LSP address'
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'cwd')
|
||||
let l:obj.cwd = a:linter.cwd
|
||||
|
||||
if type(l:obj.cwd) isnot v:t_string
|
||||
\&& type(l:obj.cwd) isnot v:t_func
|
||||
throw '`cwd` must be a String or Function if defined'
|
||||
endif
|
||||
endif
|
||||
|
||||
if l:needs_lsp_details
|
||||
" Default to using the filetype as the language.
|
||||
let l:obj.language = get(a:linter, 'language', a:filetype)
|
||||
|
||||
if type(l:obj.language) isnot v:t_string
|
||||
\&& type(l:obj.language) isnot v:t_func
|
||||
throw '`language` must be a String or Funcref if defined'
|
||||
throw '`language` must be a String or Function if defined'
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'project_root')
|
||||
@ -413,6 +429,12 @@ function! ale#linter#GetExecutable(buffer, linter) abort
|
||||
\ : l:Executable
|
||||
endfunction
|
||||
|
||||
function! ale#linter#GetCwd(buffer, linter) abort
|
||||
let l:Cwd = get(a:linter, 'cwd', v:null)
|
||||
|
||||
return type(l:Cwd) is v:t_func ? l:Cwd(a:buffer) : l:Cwd
|
||||
endfunction
|
||||
|
||||
" Given a buffer and linter, get the command String for the linter.
|
||||
function! ale#linter#GetCommand(buffer, linter) abort
|
||||
let l:Command = a:linter.command
|
||||
|
@ -20,11 +20,17 @@ endif
|
||||
|
||||
" Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list
|
||||
function! ale#list#IsQuickfixOpen() abort
|
||||
for l:buf in range(1, bufnr('$'))
|
||||
if getbufvar(l:buf, '&buftype') is# 'quickfix'
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
let l:res = getqflist({ 'winid' : winnr() })
|
||||
|
||||
if has_key(l:res, 'winid') && l:res.winid > 0
|
||||
return 1
|
||||
endif
|
||||
|
||||
let l:res = getloclist(0, { 'winid' : winnr() })
|
||||
|
||||
if has_key(l:res, 'winid') && l:res.winid > 0
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
@ -357,6 +357,7 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort
|
||||
let l:conn.capabilities.completion = 1
|
||||
let l:conn.capabilities.completion_trigger_characters = ['.']
|
||||
let l:conn.capabilities.definition = 1
|
||||
let l:conn.capabilities.typeDefinition = 1
|
||||
let l:conn.capabilities.symbol_search = 1
|
||||
let l:conn.capabilities.rename = 1
|
||||
let l:conn.capabilities.code_actions = 1
|
||||
|
@ -64,6 +64,14 @@ function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort
|
||||
return [0, 'ts@typeDefinition', {
|
||||
\ 'line': a:line,
|
||||
\ 'offset': a:column,
|
||||
\ 'file': expand('#' . a:buffer . ':p'),
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#tsserver_message#References(buffer, line, column) abort
|
||||
return [0, 'ts@references', {
|
||||
\ 'line': a:line,
|
||||
|
@ -85,12 +85,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
endif
|
||||
|
||||
let l:info.syntax_loclist = l:thislist
|
||||
else
|
||||
elseif a:error_type is# 'semantic'
|
||||
if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0
|
||||
let l:no_changes = 1
|
||||
endif
|
||||
|
||||
let l:info.semantic_loclist = l:thislist
|
||||
else
|
||||
if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0
|
||||
let l:no_changes = 1
|
||||
endif
|
||||
|
||||
let l:info.suggestion_loclist = l:thislist
|
||||
endif
|
||||
|
||||
if l:no_changes
|
||||
@ -98,6 +104,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
endif
|
||||
|
||||
let l:loclist = get(l:info, 'semantic_loclist', [])
|
||||
\ + get(l:info, 'suggestion_loclist', [])
|
||||
\ + get(l:info, 'syntax_loclist', [])
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
@ -150,6 +157,10 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
|
||||
elseif get(a:response, 'type', '') is# 'event'
|
||||
\&& get(a:response, 'event', '') is# 'syntaxDiag'
|
||||
call s:HandleTSServerDiagnostics(a:response, 'syntax')
|
||||
elseif get(a:response, 'type', '') is# 'event'
|
||||
\&& get(a:response, 'event', '') is# 'suggestionDiag'
|
||||
\&& get(g:, 'ale_lsp_suggestions', '1') == 1
|
||||
call s:HandleTSServerDiagnostics(a:response, 'suggestion')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -190,7 +201,11 @@ function! ale#lsp_linter#GetConfig(buffer, linter) abort
|
||||
endfunction
|
||||
|
||||
function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort
|
||||
let l:buffer_ale_root = getbufvar(a:buffer, 'ale_lsp_root', {})
|
||||
let l:buffer_ale_root = getbufvar(
|
||||
\ a:buffer,
|
||||
\ 'ale_root',
|
||||
\ getbufvar(a:buffer, 'ale_lsp_root', {})
|
||||
\)
|
||||
|
||||
if type(l:buffer_ale_root) is v:t_string
|
||||
return l:buffer_ale_root
|
||||
@ -207,9 +222,15 @@ function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:global_root = g:ale_root
|
||||
|
||||
if empty(g:ale_root) && exists('g:ale_lsp_root')
|
||||
let l:global_root = g:ale_lsp_root
|
||||
endif
|
||||
|
||||
" Try to get a global setting for the root
|
||||
if has_key(g:ale_lsp_root, a:linter.name)
|
||||
let l:Root = g:ale_lsp_root[a:linter.name]
|
||||
if has_key(l:global_root, a:linter.name)
|
||||
let l:Root = l:global_root[a:linter.name]
|
||||
|
||||
if type(l:Root) is v:t_func
|
||||
return l:Root(a:buffer)
|
||||
@ -273,13 +294,15 @@ function! s:StartLSP(options, address, executable, command) abort
|
||||
call ale#lsp#MarkConnectionAsTsserver(l:conn_id)
|
||||
endif
|
||||
|
||||
let l:cwd = ale#linter#GetCwd(l:buffer, l:linter)
|
||||
let l:command = ale#command#FormatCommand(
|
||||
\ l:buffer,
|
||||
\ a:executable,
|
||||
\ a:command,
|
||||
\ 0,
|
||||
\ v:false,
|
||||
\ [],
|
||||
\ l:cwd,
|
||||
\ ale#GetFilenameMappings(l:buffer, l:linter.name),
|
||||
\)[1]
|
||||
let l:command = ale#job#PrepareCommand(l:buffer, l:command)
|
||||
let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command)
|
||||
|
@ -17,7 +17,6 @@ function! ale#maven#FindProjectRoot(buffer) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
" Given a buffer number, find the path to the executable.
|
||||
" First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found,
|
||||
" try the global command. Returns an empty string if cannot find the executable.
|
||||
@ -25,7 +24,7 @@ function! ale#maven#FindExecutable(buffer) abort
|
||||
let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd'
|
||||
let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd)
|
||||
|
||||
if executable(l:wrapper_path)
|
||||
if !empty(l:wrapper_path) && executable(l:wrapper_path)
|
||||
return l:wrapper_path
|
||||
endif
|
||||
|
||||
@ -36,16 +35,23 @@ function! ale#maven#FindExecutable(buffer) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Given a buffer number, build a command to print the classpath of the root
|
||||
" project. Returns an empty string if cannot build the command.
|
||||
" Given a buffer number, get a working directory and command to print the
|
||||
" classpath of the root project.
|
||||
"
|
||||
" Returns an empty string for the command if Maven is not detected.
|
||||
function! ale#maven#BuildClasspathCommand(buffer) abort
|
||||
let l:executable = ale#maven#FindExecutable(a:buffer)
|
||||
let l:project_root = ale#maven#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:executable) && !empty(l:project_root)
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . l:executable . ' dependency:build-classpath'
|
||||
if !empty(l:executable)
|
||||
let l:project_root = ale#maven#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:project_root)
|
||||
return [
|
||||
\ l:project_root,
|
||||
\ ale#Escape(l:executable) . ' dependency:build-classpath'
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
@ -77,26 +77,6 @@ function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abor
|
||||
return l:path
|
||||
endfunction
|
||||
|
||||
" Output 'cd <directory> && '
|
||||
" This function can be used changing the directory for a linter command.
|
||||
function! ale#path#CdString(directory) abort
|
||||
if has('win32')
|
||||
return 'cd /d ' . ale#Escape(a:directory) . ' && '
|
||||
endif
|
||||
|
||||
return 'cd ' . ale#Escape(a:directory) . ' && '
|
||||
endfunction
|
||||
|
||||
" Output 'cd <buffer_filename_directory> && '
|
||||
" This function can be used changing the directory for a linter command.
|
||||
function! ale#path#BufferCdString(buffer) abort
|
||||
if has('win32')
|
||||
return 'cd /d %s:h && '
|
||||
endif
|
||||
|
||||
return 'cd %s:h && '
|
||||
endfunction
|
||||
|
||||
" Return 1 if a path is an absolute path.
|
||||
function! ale#path#IsAbsolute(filename) abort
|
||||
if has('win32') && a:filename[:0] is# '\'
|
||||
@ -136,7 +116,7 @@ function! ale#path#Dirname(path) abort
|
||||
endif
|
||||
|
||||
" For /foo/bar/ we need :h:h to get /foo
|
||||
if a:path[-1:] is# '/'
|
||||
if a:path[-1:] is# '/' || (has('win32') && a:path[-1:] is# '\')
|
||||
return fnamemodify(a:path, ':h:h')
|
||||
endif
|
||||
|
||||
|
@ -32,6 +32,8 @@ function! ale#python#FindProjectRootIni(buffer) abort
|
||||
\|| filereadable(l:path . '/.pylintrc')
|
||||
\|| filereadable(l:path . '/Pipfile')
|
||||
\|| filereadable(l:path . '/Pipfile.lock')
|
||||
\|| filereadable(l:path . '/poetry.lock')
|
||||
\|| filereadable(l:path . '/pyproject.toml')
|
||||
return l:path
|
||||
endif
|
||||
endfor
|
||||
|
@ -50,9 +50,12 @@ if !hlexists('ALESignColumnWithErrors')
|
||||
endif
|
||||
|
||||
function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort
|
||||
let l:verbose = &verbose
|
||||
set verbose=0
|
||||
redir => l:output
|
||||
0verbose silent highlight SignColumn
|
||||
redir end
|
||||
let &verbose = l:verbose
|
||||
|
||||
let l:highlight_syntax = join(split(l:output)[2:])
|
||||
let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$')
|
||||
|
@ -72,9 +72,8 @@ function! ale#socket#Open(address, options) abort
|
||||
elseif exists('*chansend') && exists('*sockconnect')
|
||||
" NeoVim 0.3+
|
||||
try
|
||||
let l:channel_id = sockconnect('tcp', a:address, {
|
||||
\ 'on_data': function('s:NeoVimOutputCallback'),
|
||||
\})
|
||||
let l:channel_id = sockconnect(stridx(a:address, ':') != -1 ? 'tcp' : 'pipe',
|
||||
\ a:address, {'on_data': function('s:NeoVimOutputCallback')})
|
||||
let l:channel_info.last_line = ''
|
||||
catch /connection failed/
|
||||
let l:channel_id = -1
|
||||
|
@ -11,3 +11,60 @@ function! ale#swift#FindProjectRoot(buffer) abort
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Support Apple Swift Format {{{1
|
||||
|
||||
call ale#Set('swift_appleswiftformat_executable', 'swift-format')
|
||||
call ale#Set('swift_appleswiftformat_use_swiftpm', 0)
|
||||
|
||||
" Return the executable depending on whether or not to use Swift Package Manager.
|
||||
"
|
||||
" If not asked to use Swift Package Manager (use_swiftpm = 0), the returned
|
||||
" value is the global executable, else the returned value is 'swift' because
|
||||
" the final command line will be `swift run swift-format ...`.
|
||||
"
|
||||
" Failure is expected if use_swiftpm is `1` but no Package.swift can be located.
|
||||
function! ale#swift#GetAppleSwiftFormatExecutable(buffer) abort
|
||||
if !ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm')
|
||||
return ale#Var(a:buffer, 'swift_appleswiftformat_executable')
|
||||
endif
|
||||
|
||||
if ale#path#FindNearestFile(a:buffer, 'Package.swift') is# ''
|
||||
" If there is no Package.swift file, we don't use swift-format even if it exists,
|
||||
" so we return '' to indicate failure.
|
||||
return ''
|
||||
endif
|
||||
|
||||
return 'swift'
|
||||
endfunction
|
||||
|
||||
" Return the command depending on whether or not to use Swift Package Manager.
|
||||
"
|
||||
" If asked to use Swift Package Manager (use_swiftpm = 1), the command
|
||||
" arguments are prefixed with 'swift run'.
|
||||
"
|
||||
" In either case, the configuration file is located and added to the command.
|
||||
function! ale#swift#GetAppleSwiftFormatCommand(buffer) abort
|
||||
let l:executable = ale#swift#GetAppleSwiftFormatExecutable(a:buffer)
|
||||
let l:command_args = ''
|
||||
|
||||
if ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm')
|
||||
let l:command_args = ' ' . 'run swift-format'
|
||||
endif
|
||||
|
||||
return ale#Escape(l:executable) . l:command_args
|
||||
endfunction
|
||||
|
||||
" Locate the nearest '.swift-format' configuration file, and return the
|
||||
" arguments, else return an empty string.
|
||||
function! ale#swift#GetAppleSwiftFormatConfigArgs(buffer) abort
|
||||
let l:config_filepath = ale#path#FindNearestFile(a:buffer, '.swift-format')
|
||||
|
||||
if l:config_filepath isnot# ''
|
||||
return '--configuration' . ' ' . l:config_filepath
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
@ -34,12 +34,11 @@ function! ale#test#RestoreDirectory() abort
|
||||
unlet! g:dir
|
||||
endfunction
|
||||
|
||||
" Change the filename for the current buffer using a relative path to
|
||||
" the script without running autocmd commands.
|
||||
" Get a filename for the current buffer using a relative path to the script.
|
||||
"
|
||||
" If a g:dir variable is set, it will be used as the path to the directory
|
||||
" containing the test file.
|
||||
function! ale#test#SetFilename(path) abort
|
||||
function! ale#test#GetFilename(path) abort
|
||||
let l:dir = get(g:, 'dir', '')
|
||||
|
||||
if empty(l:dir)
|
||||
@ -50,7 +49,17 @@ function! ale#test#SetFilename(path) abort
|
||||
\ ? a:path
|
||||
\ : l:dir . '/' . a:path
|
||||
|
||||
silent! noautocmd execute 'file ' . fnameescape(ale#path#Simplify(l:full_path))
|
||||
return ale#path#Simplify(l:full_path)
|
||||
endfunction
|
||||
|
||||
" Change the filename for the current buffer using a relative path to
|
||||
" the script without running autocmd commands.
|
||||
"
|
||||
" If a g:dir variable is set, it will be used as the path to the directory
|
||||
" containing the test file.
|
||||
function! ale#test#SetFilename(path) abort
|
||||
let l:full_path = ale#test#GetFilename(a:path)
|
||||
silent! noautocmd execute 'file ' . fnameescape(l:full_path)
|
||||
endfunction
|
||||
|
||||
function! s:RemoveModule(results) abort
|
||||
|
@ -340,6 +340,16 @@ function! ale#util#GetMatches(lines, patterns) abort
|
||||
return l:matches
|
||||
endfunction
|
||||
|
||||
" Given a single line, or a List of lines, and a single pattern, or a List of
|
||||
" patterns, and a callback function for mapping the items matches, return the
|
||||
" result of mapping all of the matches for the lines from the given patterns,
|
||||
" using matchlist()
|
||||
"
|
||||
" Only the first pattern which matches a line will be returned.
|
||||
function! ale#util#MapMatches(lines, patterns, Callback) abort
|
||||
return map(ale#util#GetMatches(a:lines, a:patterns), 'a:Callback(v:val)')
|
||||
endfunction
|
||||
|
||||
function! s:LoadArgCount(function) abort
|
||||
try
|
||||
let l:output = execute('function a:function')
|
||||
@ -409,7 +419,7 @@ function! ale#util#FuzzyJSONDecode(data, default) abort
|
||||
endif
|
||||
|
||||
return l:result
|
||||
catch /E474/
|
||||
catch /E474\|E491/
|
||||
return a:default
|
||||
endtry
|
||||
endfunction
|
||||
@ -486,7 +496,7 @@ function! ale#util#Input(message, value) abort
|
||||
endfunction
|
||||
|
||||
function! ale#util#HasBuflineApi() abort
|
||||
return exists('*deletebufline') && exists('*appendbufline') && exists('*getpos') && exists('*setpos')
|
||||
return exists('*deletebufline') && exists('*setbufline')
|
||||
endfunction
|
||||
|
||||
" Sets buffer contents to lines
|
||||
@ -507,11 +517,8 @@ function! ale#util#SetBufferContents(buffer, lines) abort
|
||||
|
||||
" Use a Vim API for setting lines in other buffers, if available.
|
||||
if l:has_bufline_api
|
||||
let l:save_cursor = getpos('.')
|
||||
call deletebufline(a:buffer, 1, '$')
|
||||
call appendbufline(a:buffer, 1, l:new_lines)
|
||||
call deletebufline(a:buffer, 1, 1)
|
||||
call setpos('.', l:save_cursor)
|
||||
call setbufline(a:buffer, 1, l:new_lines)
|
||||
call deletebufline(a:buffer, l:first_line_to_remove, '$')
|
||||
" Fall back on setting lines the old way, for the current buffer.
|
||||
else
|
||||
let l:old_line_length = line('$')
|
||||
|
Reference in New Issue
Block a user