mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -10,8 +10,7 @@ let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
|
||||
let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {})
|
||||
|
||||
let s:lint_timer = -1
|
||||
let s:queued_buffer_number = -1
|
||||
let s:should_lint_file_for_buffer = {}
|
||||
let s:getcmdwintype_exists = exists('*getcmdwintype')
|
||||
|
||||
" Return 1 if a file is too large for ALE to handle.
|
||||
function! ale#FileTooLarge(buffer) abort
|
||||
@ -20,8 +19,6 @@ function! ale#FileTooLarge(buffer) abort
|
||||
return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0
|
||||
endfunction
|
||||
|
||||
let s:getcmdwintype_exists = exists('*getcmdwintype')
|
||||
|
||||
" A function for checking various conditions whereby ALE just shouldn't
|
||||
" attempt to do anything, say if particular buffer types are open in Vim.
|
||||
function! ale#ShouldDoNothing(buffer) abort
|
||||
@ -86,18 +83,44 @@ function! ale#ShouldDoNothing(buffer) abort
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:Lint(buffer, should_lint_file, timer_id) abort
|
||||
" Use the filetype from the buffer
|
||||
let l:filetype = getbufvar(a:buffer, '&filetype')
|
||||
let l:linters = ale#linter#Get(l:filetype)
|
||||
|
||||
" Apply ignore lists for linters only if needed.
|
||||
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:linters = !empty(l:ignore_config)
|
||||
\ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config)
|
||||
\ : l:linters
|
||||
|
||||
" Tell other sources that they can start checking the buffer now.
|
||||
let g:ale_want_results_buffer = a:buffer
|
||||
silent doautocmd <nomodeline> User ALEWantResults
|
||||
unlet! g:ale_want_results_buffer
|
||||
|
||||
" Don't set up buffer data and so on if there are no linters to run.
|
||||
if !has_key(g:ale_buffer_info, a:buffer) && empty(l:linters)
|
||||
return
|
||||
endif
|
||||
|
||||
" Clear lint_file linters, or only run them if the file exists.
|
||||
let l:lint_file = empty(l:linters)
|
||||
\ || (a:should_lint_file && filereadable(expand('#' . a:buffer . ':p')))
|
||||
|
||||
call ale#engine#RunLinters(a:buffer, l:linters, l:lint_file)
|
||||
endfunction
|
||||
|
||||
" (delay, [linting_flag, buffer_number])
|
||||
function! ale#Queue(delay, ...) abort
|
||||
if a:0 > 2
|
||||
throw 'too many arguments!'
|
||||
endif
|
||||
|
||||
" Default linting_flag to ''
|
||||
let l:linting_flag = get(a:000, 0, '')
|
||||
let l:buffer = get(a:000, 1, bufnr(''))
|
||||
let l:buffer = get(a:000, 1, v:null)
|
||||
|
||||
if l:linting_flag isnot# '' && l:linting_flag isnot# 'lint_file'
|
||||
throw "linting_flag must be either '' or 'lint_file'"
|
||||
if l:buffer is v:null
|
||||
let l:buffer = bufnr('')
|
||||
endif
|
||||
|
||||
if type(l:buffer) isnot v:t_number
|
||||
@ -108,80 +131,24 @@ function! ale#Queue(delay, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
" Remember that we want to check files for this buffer.
|
||||
" We will remember this until we finally run the linters, via any event.
|
||||
if l:linting_flag is# 'lint_file'
|
||||
let s:should_lint_file_for_buffer[l:buffer] = 1
|
||||
endif
|
||||
" Default linting_flag to ''
|
||||
let l:should_lint_file = get(a:000, 0) is# 'lint_file'
|
||||
|
||||
if s:lint_timer != -1
|
||||
call timer_stop(s:lint_timer)
|
||||
let s:lint_timer = -1
|
||||
endif
|
||||
|
||||
let l:linters = ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
|
||||
" Don't set up buffer data and so on if there are no linters to run.
|
||||
if empty(l:linters)
|
||||
" If we have some previous buffer data, then stop any jobs currently
|
||||
" running and clear everything.
|
||||
if has_key(g:ale_buffer_info, l:buffer)
|
||||
call ale#engine#RunLinters(l:buffer, [], 1)
|
||||
endif
|
||||
|
||||
return
|
||||
endif
|
||||
|
||||
if a:delay > 0
|
||||
let s:queued_buffer_number = l:buffer
|
||||
let s:lint_timer = timer_start(a:delay, function('ale#Lint'))
|
||||
let s:lint_timer = timer_start(
|
||||
\ a:delay,
|
||||
\ function('s:Lint', [l:buffer, l:should_lint_file])
|
||||
\)
|
||||
else
|
||||
call ale#Lint(-1, l:buffer)
|
||||
call s:Lint(l:buffer, l:should_lint_file, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#Lint(...) abort
|
||||
if a:0 > 1
|
||||
" Use the buffer number given as the optional second argument.
|
||||
let l:buffer = a:2
|
||||
elseif a:0 > 0 && a:1 == s:lint_timer
|
||||
" Use the buffer number for the buffer linting was queued for.
|
||||
let l:buffer = s:queued_buffer_number
|
||||
else
|
||||
" Use the current buffer number.
|
||||
let l:buffer = bufnr('')
|
||||
endif
|
||||
|
||||
if ale#ShouldDoNothing(l:buffer)
|
||||
return
|
||||
endif
|
||||
|
||||
" Use the filetype from the buffer
|
||||
let l:filetype = getbufvar(l:buffer, '&filetype')
|
||||
let l:linters = ale#linter#Get(l:filetype)
|
||||
let l:should_lint_file = 0
|
||||
|
||||
" Check if we previously requested checking the file.
|
||||
if has_key(s:should_lint_file_for_buffer, l:buffer)
|
||||
unlet s:should_lint_file_for_buffer[l:buffer]
|
||||
" Lint files if they exist.
|
||||
let l:should_lint_file = filereadable(expand('#' . l:buffer . ':p'))
|
||||
endif
|
||||
|
||||
" Apply ignore lists for linters only if needed.
|
||||
let l:ignore_config = ale#Var(l:buffer, 'linters_ignore')
|
||||
let l:linters = !empty(l:ignore_config)
|
||||
\ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config)
|
||||
\ : l:linters
|
||||
|
||||
call ale#engine#RunLinters(l:buffer, l:linters, l:should_lint_file)
|
||||
endfunction
|
||||
|
||||
" Reset flags indicating that files should be checked for all buffers.
|
||||
function! ale#ResetLintFileMarkers() abort
|
||||
let s:should_lint_file_for_buffer = {}
|
||||
endfunction
|
||||
|
||||
let g:ale_has_override = get(g:, 'ale_has_override', {})
|
||||
|
||||
" Call has(), but check a global Dictionary so we can force flags on or off
|
||||
|
@ -85,6 +85,14 @@ function! ale#assert#LSPOptions(expected_options) abort
|
||||
AssertEqual a:expected_options, l:initialization_options
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LSPConfig(expected_config) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
let l:config = ale#lsp_linter#GetConfig(l:buffer, l:linter)
|
||||
|
||||
AssertEqual a:expected_config, l:config
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LSPLanguage(expected_language) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
@ -147,6 +155,7 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>)
|
||||
command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted()
|
||||
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
|
||||
command! -nargs=+ AssertLSPConfig :call ale#assert#LSPConfig(<args>)
|
||||
command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>)
|
||||
command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>)
|
||||
command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress(<args>)
|
||||
@ -172,6 +181,10 @@ function! ale#assert#TearDownLinterTest() abort
|
||||
delcommand AssertLSPOptions
|
||||
endif
|
||||
|
||||
if exists(':AssertLSPConfig')
|
||||
delcommand AssertLSPConfig
|
||||
endif
|
||||
|
||||
if exists(':AssertLSPLanguage')
|
||||
delcommand AssertLSPLanguage
|
||||
endif
|
||||
|
@ -26,7 +26,20 @@ function! ale#cursor#TruncatedEcho(original_message) abort
|
||||
|
||||
" The message is truncated and saved to the history.
|
||||
setlocal shortmess+=T
|
||||
exec "norm! :echomsg l:message\n"
|
||||
|
||||
try
|
||||
exec "norm! :echomsg l:message\n"
|
||||
catch /^Vim\%((\a\+)\)\=:E523/
|
||||
" Fallback into manual truncate (#1987)
|
||||
let l:winwidth = winwidth(0)
|
||||
|
||||
if l:winwidth < strdisplaywidth(l:message)
|
||||
" Truncate message longer than window width with trailing '...'
|
||||
let l:message = l:message[:l:winwidth - 4] . '...'
|
||||
endif
|
||||
|
||||
exec 'echomsg l:message'
|
||||
endtry
|
||||
|
||||
" Reset the cursor position if we moved off the end of the line.
|
||||
" Using :norm and :echomsg can move the cursor off the end of the
|
||||
|
16
sources_non_forked/ale/autoload/ale/d.vim
Normal file
16
sources_non_forked/ale/autoload/ale/d.vim
Normal file
@ -0,0 +1,16 @@
|
||||
" Author: Auri <me@aurieh.me>
|
||||
" Description: Functions for integrating with D linters.
|
||||
|
||||
function! ale#d#FindDUBConfig(buffer) abort
|
||||
" Find a DUB configuration file in ancestor paths.
|
||||
" The most DUB-specific names will be tried first.
|
||||
for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json']
|
||||
let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename)
|
||||
|
||||
if !empty(l:dub_file)
|
||||
return l:dub_file
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
@ -79,6 +79,7 @@ function! ale#engine#InitBufferInfo(buffer) abort
|
||||
let g:ale_buffer_info[a:buffer] = {
|
||||
\ 'job_list': [],
|
||||
\ 'active_linter_list': [],
|
||||
\ 'active_other_sources_list': [],
|
||||
\ 'loclist': [],
|
||||
\ 'temporary_file_list': [],
|
||||
\ 'temporary_directory_list': [],
|
||||
@ -97,6 +98,7 @@ function! ale#engine#IsCheckingBuffer(buffer) abort
|
||||
let l:info = get(g:ale_buffer_info, a:buffer, {})
|
||||
|
||||
return !empty(get(l:info, 'active_linter_list', []))
|
||||
\ || !empty(get(l:info, 'active_other_sources_list', []))
|
||||
endfunction
|
||||
|
||||
" Register a temporary file to be managed with the ALE engine for
|
||||
@ -177,20 +179,27 @@ function! s:GatherOutput(job_id, line) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#engine#HandleLoclist(linter_name, buffer, loclist) abort
|
||||
function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort
|
||||
let l:info = get(g:ale_buffer_info, a:buffer, {})
|
||||
|
||||
if empty(l:info)
|
||||
return
|
||||
endif
|
||||
|
||||
" Remove this linter from the list of active linters.
|
||||
" This may have already been done when the job exits.
|
||||
call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name')
|
||||
if !a:from_other_source
|
||||
" Remove this linter from the list of active linters.
|
||||
" This may have already been done when the job exits.
|
||||
call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name')
|
||||
endif
|
||||
|
||||
" Make some adjustments to the loclists to fix common problems, and also
|
||||
" to set default values for loclist items.
|
||||
let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist)
|
||||
let l:linter_loclist = ale#engine#FixLocList(
|
||||
\ a:buffer,
|
||||
\ a:linter_name,
|
||||
\ a:from_other_source,
|
||||
\ a:loclist,
|
||||
\)
|
||||
|
||||
" Remove previous items for this linter.
|
||||
call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name')
|
||||
@ -263,7 +272,7 @@ function! s:HandleExit(job_id, exit_code) abort
|
||||
let l:loclist = []
|
||||
endtry
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist)
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0)
|
||||
endfunction
|
||||
|
||||
function! ale#engine#SetResults(buffer, loclist) abort
|
||||
@ -335,7 +344,7 @@ function! s:RemapItemTypes(type_map, loclist) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
|
||||
function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) abort
|
||||
let l:bufnr_map = {}
|
||||
let l:new_loclist = []
|
||||
|
||||
@ -368,6 +377,10 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
|
||||
\ 'linter_name': a:linter_name,
|
||||
\}
|
||||
|
||||
if a:from_other_source
|
||||
let l:item.from_other_source = 1
|
||||
endif
|
||||
|
||||
if has_key(l:old_item, 'code')
|
||||
let l:item.code = l:old_item.code
|
||||
endif
|
||||
@ -691,6 +704,7 @@ endfunction
|
||||
function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort
|
||||
" Figure out which linters are still enabled, and remove
|
||||
" problems for linters which are no longer enabled.
|
||||
" Problems from other sources will be kept.
|
||||
let l:name_map = {}
|
||||
|
||||
for l:linter in a:linters
|
||||
@ -699,7 +713,7 @@ function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort
|
||||
|
||||
call filter(
|
||||
\ get(g:ale_buffer_info[a:buffer], 'loclist', []),
|
||||
\ 'get(l:name_map, get(v:val, ''linter_name''))',
|
||||
\ 'get(v:val, ''from_other_source'') || get(l:name_map, get(v:val, ''linter_name''))',
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
@ -250,6 +250,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'objc', 'objcpp', 'd', 'java', 'p', 'vala' ],
|
||||
\ 'description': 'Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.',
|
||||
\ },
|
||||
\ 'terraform': {
|
||||
\ 'function': 'ale#fixers#terraform#Fix',
|
||||
\ 'suggested_filetypes': ['hcl', 'terraform'],
|
||||
\ 'description': 'Fix tf and hcl files with terraform fmt.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
@ -1,13 +1,13 @@
|
||||
" Author: butlerx <butlerx@notthe,cloud>
|
||||
" Description: Integration of Google-java-format with ALE.
|
||||
|
||||
call ale#Set('google_java_format_executable', 'google-java-format')
|
||||
call ale#Set('google_java_format_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('google_java_format_options', '')
|
||||
call ale#Set('java_google_java_format_executable', 'google-java-format')
|
||||
call ale#Set('java_google_java_format_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('java_google_java_format_options', '')
|
||||
|
||||
function! ale#fixers#google_java_format#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'google_java_format_options')
|
||||
let l:executable = ale#Var(a:buffer, 'google_java_format_executable')
|
||||
let l:options = ale#Var(a:buffer, 'java_google_java_format_options')
|
||||
let l:executable = ale#Var(a:buffer, 'java_google_java_format_executable')
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
|
@ -1,5 +1,6 @@
|
||||
call ale#Set('json_jq_executable', 'jq')
|
||||
call ale#Set('json_jq_options', '')
|
||||
call ale#Set('json_jq_filters', '.')
|
||||
|
||||
function! ale#fixers#jq#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'json_jq_executable')
|
||||
@ -7,9 +8,15 @@ endfunction
|
||||
|
||||
function! ale#fixers#jq#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'json_jq_options')
|
||||
let l:filters = ale#Var(a:buffer, 'json_jq_filters')
|
||||
|
||||
if empty(l:filters)
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer))
|
||||
\ . ' . ' . l:options,
|
||||
\ . ' ' . l:filters . ' '
|
||||
\ . l:options,
|
||||
\}
|
||||
endfunction
|
||||
|
@ -9,7 +9,7 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --auto-correct %t'
|
||||
\ . ' --auto-correct --force-exclusion %t'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#rubocop#Fix(buffer) abort
|
||||
|
17
sources_non_forked/ale/autoload/ale/fixers/terraform.vim
Normal file
17
sources_non_forked/ale/autoload/ale/fixers/terraform.vim
Normal file
@ -0,0 +1,17 @@
|
||||
" Author: dsifford <dereksifford@gmail.com>
|
||||
" Description: Fixer for terraform and .hcl files
|
||||
|
||||
call ale#Set('terraform_fmt_executable', 'terraform')
|
||||
call ale#Set('terraform_fmt_options', '')
|
||||
|
||||
function! ale#fixers#terraform#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'terraform_fmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'terraform_fmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' fmt'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' -'
|
||||
\}
|
||||
endfunction
|
13
sources_non_forked/ale/autoload/ale/handlers/elixir.vim
Normal file
13
sources_non_forked/ale/autoload/ale/handlers/elixir.vim
Normal file
@ -0,0 +1,13 @@
|
||||
" Author: Matteo Centenaro (bugant) - https://github.com/bugant
|
||||
"
|
||||
" Description: find the root directory for an elixir project that uses mix
|
||||
|
||||
function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort
|
||||
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
|
||||
|
||||
if !empty(l:mix_file)
|
||||
return fnamemodify(l:mix_file, ':p:h')
|
||||
endif
|
||||
|
||||
return '.'
|
||||
endfunction
|
@ -1,5 +1,15 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Error handling for the format GHC outputs.
|
||||
"
|
||||
function! ale#handlers#haskell#GetStackExecutable(bufnr) abort
|
||||
if ale#path#FindNearestFile(a:bufnr, 'stack.yaml') isnot# ''
|
||||
return 'stack'
|
||||
endif
|
||||
|
||||
" if there is no stack.yaml file, we don't use stack even if it exists,
|
||||
" so we return '', because executable('') apparently always fails
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Remember the directory used for temporary files for Vim.
|
||||
let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h')
|
||||
|
@ -7,6 +7,10 @@ if !exists('g:ale_rust_ignore_error_codes')
|
||||
let g:ale_rust_ignore_error_codes = []
|
||||
endif
|
||||
|
||||
if !exists('g:ale_rust_ignore_secondary_spans')
|
||||
let g:ale_rust_ignore_secondary_spans = 0
|
||||
endif
|
||||
|
||||
function! s:FindSpan(buffer, span) abort
|
||||
if ale#path#IsBufferPath(a:buffer, a:span.file_name) || a:span.file_name is# '<anon>'
|
||||
return a:span
|
||||
@ -47,6 +51,10 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort
|
||||
for l:root_span in l:error.spans
|
||||
let l:span = s:FindSpan(a:buffer, l:root_span)
|
||||
|
||||
if ale#Var(a:buffer, 'rust_ignore_secondary_spans') && !get(l:span, 'is_primary', 1)
|
||||
continue
|
||||
endif
|
||||
|
||||
if !empty(l:span)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:span.line_start,
|
||||
|
@ -35,6 +35,7 @@ let s:default_ale_linters = {
|
||||
\ 'hack': ['hack'],
|
||||
\ 'help': [],
|
||||
\ 'perl': ['perlcritic'],
|
||||
\ 'perl6': [],
|
||||
\ 'python': ['flake8', 'mypy', 'pylint'],
|
||||
\ 'rust': ['cargo'],
|
||||
\ 'spec': [],
|
||||
@ -255,6 +256,24 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
elseif has_key(a:linter, 'initialization_options')
|
||||
let l:obj.initialization_options = a:linter.initialization_options
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'lsp_config_callback')
|
||||
if has_key(a:linter, 'lsp_config')
|
||||
throw 'Only one of `lsp_config` or `lsp_config_callback` should be set'
|
||||
endif
|
||||
|
||||
let l:obj.lsp_config_callback = a:linter.lsp_config_callback
|
||||
|
||||
if !s:IsCallback(l:obj.lsp_config_callback)
|
||||
throw '`lsp_config_callback` must be a callback if defined'
|
||||
endif
|
||||
elseif has_key(a:linter, 'lsp_config')
|
||||
if type(a:linter.lsp_config) isnot v:t_dict
|
||||
throw '`lsp_config` must be a Dictionary'
|
||||
endif
|
||||
|
||||
let l:obj.lsp_config = a:linter.lsp_config
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
|
||||
@ -337,8 +356,9 @@ endfunction
|
||||
function! s:GetAliasedFiletype(original_filetype) abort
|
||||
let l:buffer_aliases = get(b:, 'ale_linter_aliases', {})
|
||||
|
||||
" b:ale_linter_aliases can be set to a List.
|
||||
" b:ale_linter_aliases can be set to a List or String.
|
||||
if type(l:buffer_aliases) is v:t_list
|
||||
\|| type(l:buffer_aliases) is v:t_string
|
||||
return l:buffer_aliases
|
||||
endif
|
||||
|
||||
|
@ -19,6 +19,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
||||
" initialized: 0 if the connection is ready, 1 otherwise.
|
||||
" init_request_id: The ID for the init request.
|
||||
" init_options: Options to send to the server.
|
||||
" config: Configuration settings to send to the server.
|
||||
" callback_list: A list of callbacks for handling LSP responses.
|
||||
" message_queue: Messages queued for sending to callbacks.
|
||||
" capabilities_queue: The list of callbacks to call with capabilities.
|
||||
@ -32,6 +33,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
||||
\ 'initialized': 0,
|
||||
\ 'init_request_id': 0,
|
||||
\ 'init_options': a:init_options,
|
||||
\ 'config': {},
|
||||
\ 'callback_list': [],
|
||||
\ 'message_queue': [],
|
||||
\ 'capabilities_queue': [],
|
||||
@ -41,6 +43,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
||||
\ 'completion': 0,
|
||||
\ 'completion_trigger_characters': [],
|
||||
\ 'definition': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ },
|
||||
\}
|
||||
endif
|
||||
@ -203,8 +206,31 @@ function! s:UpdateCapabilities(conn, capabilities) abort
|
||||
if get(a:capabilities, 'definitionProvider') is v:true
|
||||
let a:conn.capabilities.definition = 1
|
||||
endif
|
||||
|
||||
if get(a:capabilities, 'workspaceSymbolProvider') is v:true
|
||||
let a:conn.capabilities.symbol_search = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Update a connection's configuration dictionary and notify LSP servers
|
||||
" of any changes since the last update. Returns 1 if a configuration
|
||||
" update was sent; otherwise 0 will be returned.
|
||||
function! ale#lsp#UpdateConfig(conn_id, buffer, config) abort
|
||||
let l:conn = get(s:connections, a:conn_id, {})
|
||||
|
||||
if empty(l:conn) || a:config ==# l:conn.config " no-custom-checks
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:conn.config = a:config
|
||||
let l:message = ale#lsp#message#DidChangeConfiguration(a:buffer, a:config)
|
||||
|
||||
call ale#lsp#Send(a:conn_id, l:message)
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
|
||||
function! ale#lsp#HandleInitResponse(conn, response) abort
|
||||
if get(a:response, 'method', '') is# 'initialize'
|
||||
let a:conn.initialized = 1
|
||||
@ -285,6 +311,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.symbol_search = 1
|
||||
endfunction
|
||||
|
||||
" Start a program for LSP servers.
|
||||
|
@ -130,6 +130,12 @@ function! ale#lsp#message#References(buffer, line, column) abort
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#Symbol(query) abort
|
||||
return [0, 'workspace/symbol', {
|
||||
\ 'query': a:query,
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#Hover(buffer, line, column) abort
|
||||
return [0, 'textDocument/hover', {
|
||||
\ 'textDocument': {
|
||||
@ -138,3 +144,9 @@ function! ale#lsp#message#Hover(buffer, line, column) abort
|
||||
\ 'position': {'line': a:line - 1, 'character': a:column},
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#DidChangeConfiguration(buffer, config) abort
|
||||
return [0, 'workspace/didChangeConfiguration', {
|
||||
\ 'settings': a:config,
|
||||
\}]
|
||||
endfunction
|
||||
|
@ -17,7 +17,7 @@ function! ale#lsp#reset#StopAllLSPs() abort
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
if !empty(l:linter.lsp)
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, [])
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, [], 0)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
@ -38,7 +38,7 @@ function! s:HandleLSPDiagnostics(conn_id, response) abort
|
||||
|
||||
let l:loclist = ale#lsp#response#ReadDiagnostics(a:response)
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist)
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
endfunction
|
||||
|
||||
function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
@ -81,7 +81,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
let l:loclist = get(l:info, 'semantic_loclist', [])
|
||||
\ + get(l:info, 'syntax_loclist', [])
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist)
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
endfunction
|
||||
|
||||
function! s:HandleLSPErrorMessage(linter_name, response) abort
|
||||
@ -140,6 +140,18 @@ function! ale#lsp_linter#GetOptions(buffer, linter) abort
|
||||
return l:initialization_options
|
||||
endfunction
|
||||
|
||||
function! ale#lsp_linter#GetConfig(buffer, linter) abort
|
||||
let l:config = {}
|
||||
|
||||
if has_key(a:linter, 'lsp_config_callback')
|
||||
let l:config = ale#util#GetFunction(a:linter.lsp_config_callback)(a:buffer)
|
||||
elseif has_key(a:linter, 'lsp_config')
|
||||
let l:config = a:linter.lsp_config
|
||||
endif
|
||||
|
||||
return l:config
|
||||
endfunction
|
||||
|
||||
" Given a buffer, an LSP linter, start up an LSP linter and get ready to
|
||||
" receive messages for the document.
|
||||
function! ale#lsp_linter#StartLSP(buffer, linter) abort
|
||||
@ -188,6 +200,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort
|
||||
call ale#lsp#MarkConnectionAsTsserver(l:conn_id)
|
||||
endif
|
||||
|
||||
let l:config = ale#lsp_linter#GetConfig(a:buffer, a:linter)
|
||||
let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer)
|
||||
|
||||
let l:details = {
|
||||
@ -198,6 +211,8 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort
|
||||
\ 'language_id': l:language_id,
|
||||
\}
|
||||
|
||||
call ale#lsp#UpdateConfig(l:conn_id, a:buffer, l:config)
|
||||
|
||||
if ale#lsp#OpenDocument(l:conn_id, a:buffer, l:language_id)
|
||||
if g:ale_history_enabled && !empty(l:command)
|
||||
call ale#history#Add(a:buffer, 'started', l:conn_id, l:command)
|
||||
|
21
sources_non_forked/ale/autoload/ale/other_source.vim
Normal file
21
sources_non_forked/ale/autoload/ale/other_source.vim
Normal file
@ -0,0 +1,21 @@
|
||||
" Tell ALE that another source has started checking a buffer.
|
||||
function! ale#other_source#StartChecking(buffer, linter_name) abort
|
||||
call ale#engine#InitBufferInfo(a:buffer)
|
||||
let l:list = g:ale_buffer_info[a:buffer].active_other_sources_list
|
||||
|
||||
call add(l:list, a:linter_name)
|
||||
call uniq(sort(l:list))
|
||||
endfunction
|
||||
|
||||
" Show some results, and stop checking a buffer.
|
||||
" To clear results or cancel checking a buffer, an empty List can be given.
|
||||
function! ale#other_source#ShowResults(buffer, linter_name, loclist) abort
|
||||
call ale#engine#InitBufferInfo(a:buffer)
|
||||
let l:info = g:ale_buffer_info[a:buffer]
|
||||
|
||||
" Remove this linter name from the active list.
|
||||
let l:list = l:info.active_other_sources_list
|
||||
call filter(l:list, 'v:val isnot# a:linter_name')
|
||||
|
||||
call ale#engine#HandleLoclist(a:linter_name, a:buffer, a:loclist, 1)
|
||||
endfunction
|
@ -65,7 +65,11 @@ endfunction
|
||||
" Output 'cd <directory> && '
|
||||
" This function can be used changing the directory for a linter command.
|
||||
function! ale#path#CdString(directory) abort
|
||||
return 'cd ' . ale#Escape(a:directory) . ' && '
|
||||
if has('win32')
|
||||
return 'cd /d ' . ale#Escape(a:directory) . ' && '
|
||||
else
|
||||
return 'cd ' . ale#Escape(a:directory) . ' && '
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Output 'cd <buffer_filename_directory> && '
|
||||
|
@ -46,11 +46,14 @@ function! ale#preview#ShowSelection(item_list) abort
|
||||
|
||||
" Create lines to display to users.
|
||||
for l:item in a:item_list
|
||||
let l:match = get(l:item, 'match', '')
|
||||
|
||||
call add(
|
||||
\ l:lines,
|
||||
\ l:item.filename
|
||||
\ . ':' . l:item.line
|
||||
\ . ':' . l:item.column,
|
||||
\ . ':' . l:item.column
|
||||
\ . (!empty(l:match) ? ' ' . l:match : ''),
|
||||
\)
|
||||
endfor
|
||||
|
||||
|
109
sources_non_forked/ale/autoload/ale/symbol.vim
Normal file
109
sources_non_forked/ale/autoload/ale/symbol.vim
Normal file
@ -0,0 +1,109 @@
|
||||
let s:symbol_map = {}
|
||||
|
||||
" Used to get the symbol map in tests.
|
||||
function! ale#symbol#GetMap() abort
|
||||
return deepcopy(s:symbol_map)
|
||||
endfunction
|
||||
|
||||
" Used to set the symbol map in tests.
|
||||
function! ale#symbol#SetMap(map) abort
|
||||
let s:symbol_map = a:map
|
||||
endfunction
|
||||
|
||||
function! ale#symbol#ClearLSPData() abort
|
||||
let s:symbol_map = {}
|
||||
endfunction
|
||||
|
||||
function! ale#symbol#HandleLSPResponse(conn_id, response) abort
|
||||
if has_key(a:response, 'id')
|
||||
\&& has_key(s:symbol_map, a:response.id)
|
||||
let l:options = remove(s:symbol_map, a:response.id)
|
||||
|
||||
let l:result = get(a:response, 'result', v:null)
|
||||
let l:item_list = []
|
||||
|
||||
if type(l:result) is v:t_list
|
||||
" Each item looks like this:
|
||||
" {
|
||||
" 'name': 'foo',
|
||||
" 'kind': 123,
|
||||
" 'deprecated': v:false,
|
||||
" 'location': {
|
||||
" 'uri': 'file://...',
|
||||
" 'range': {
|
||||
" 'start': {'line': 0, 'character': 0},
|
||||
" 'end': {'line': 0, 'character': 0},
|
||||
" },
|
||||
" },
|
||||
" 'containerName': 'SomeContainer',
|
||||
" }
|
||||
for l:response_item in l:result
|
||||
let l:location = l:response_item.location
|
||||
|
||||
call add(l:item_list, {
|
||||
\ 'filename': ale#path#FromURI(l:location.uri),
|
||||
\ 'line': l:location.range.start.line + 1,
|
||||
\ 'column': l:location.range.start.character + 1,
|
||||
\ 'match': l:response_item.name,
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
if empty(l:item_list)
|
||||
call ale#util#Execute('echom ''No symbols found.''')
|
||||
else
|
||||
call ale#preview#ShowSelection(l:item_list)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OnReady(linter, lsp_details, query, ...) abort
|
||||
let l:buffer = a:lsp_details.buffer
|
||||
|
||||
" If we already made a request, stop here.
|
||||
if getbufvar(l:buffer, 'ale_symbol_request_made', 0)
|
||||
return
|
||||
endif
|
||||
|
||||
let l:id = a:lsp_details.connection_id
|
||||
|
||||
let l:Callback = function('ale#symbol#HandleLSPResponse')
|
||||
call ale#lsp#RegisterCallback(l:id, l:Callback)
|
||||
|
||||
let l:message = ale#lsp#message#Symbol(a:query)
|
||||
let l:request_id = ale#lsp#Send(l:id, l:message)
|
||||
|
||||
call setbufvar(l:buffer, 'ale_symbol_request_made', 1)
|
||||
let s:symbol_map[l:request_id] = {
|
||||
\ 'buffer': l:buffer,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! s:Search(linter, buffer, query) abort
|
||||
let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter)
|
||||
|
||||
if !empty(l:lsp_details)
|
||||
call ale#lsp#WaitForCapability(
|
||||
\ l:lsp_details.connection_id,
|
||||
\ 'symbol_search',
|
||||
\ function('s:OnReady', [a:linter, l:lsp_details, a:query]),
|
||||
\)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#symbol#Search(query) abort
|
||||
if type(a:query) isnot v:t_string || empty(a:query)
|
||||
throw 'A non-empty string must be provided!'
|
||||
endif
|
||||
|
||||
let l:buffer = bufnr('')
|
||||
|
||||
" Set a flag so we only make one request.
|
||||
call setbufvar(l:buffer, 'ale_symbol_request_made', 0)
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver'
|
||||
call s:Search(l:linter, l:buffer, a:query)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
Reference in New Issue
Block a user