mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-05 09:27:44 +08:00
#4607 No conflicts with nvim-lspconfig by default
Default `g:ale_disable_lsp` to a new mode `'auto'` by default. With this setting applied, ALE will now check for the presence of nvim-lspconfig and automatically turn off particular LSP linters if already configured via nvim-lspconfig. For users that do not use `nvim-lspconfig`, everything should work as before.
This commit is contained in:
@@ -7,9 +7,6 @@ let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
|
||||
let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
|
||||
let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log')
|
||||
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
|
||||
" Ignoring linters, for disabling some, or ignoring LSP diagnostics.
|
||||
let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {})
|
||||
let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0)
|
||||
|
||||
" LSP window/showMessage format
|
||||
let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s')
|
||||
@@ -100,7 +97,24 @@ 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)
|
||||
let l:linters = ale#linter#RemoveIgnored(a:buffer, l:filetype, l:linters)
|
||||
|
||||
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
|
||||
" Load code to ignore linters only if we need to.
|
||||
if (
|
||||
\ !empty(l:ignore_config)
|
||||
\ || l:disable_lsp is 1
|
||||
\ || l:disable_lsp is v:true
|
||||
\ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0))
|
||||
\)
|
||||
let l:linters = ale#engine#ignore#Exclude(
|
||||
\ l:filetype,
|
||||
\ l:linters,
|
||||
\ l:ignore_config,
|
||||
\ l:disable_lsp,
|
||||
\)
|
||||
endif
|
||||
|
||||
" Tell other sources that they can start checking the buffer now.
|
||||
let g:ale_want_results_buffer = a:buffer
|
||||
|
||||
@@ -339,17 +339,7 @@ function! ale#code_action#GetCodeActions(options) abort
|
||||
silent! aunmenu PopUp.Refactor\.\.\.
|
||||
|
||||
" Only display the menu items if there's an LSP server.
|
||||
let l:has_lsp = 0
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
let l:has_lsp = 1
|
||||
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:has_lsp
|
||||
if len(ale#lsp_linter#GetEnabled(bufnr(''))) > 0
|
||||
if !empty(expand('<cword>'))
|
||||
silent! anoremenu <silent> PopUp.Rename :ALERename<CR>
|
||||
endif
|
||||
|
||||
@@ -473,15 +473,9 @@ function! ale#codefix#Execute(range, ...) abort
|
||||
endif
|
||||
|
||||
let l:MenuCallback = get(a:000, 0, v:null)
|
||||
let l:lsp_linters = []
|
||||
let l:linters = ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call add(l:lsp_linters, l:linter)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if empty(l:lsp_linters)
|
||||
if empty(l:linters)
|
||||
if l:MenuCallback is v:null
|
||||
call s:message('No active LSPs')
|
||||
else
|
||||
@@ -491,7 +485,7 @@ function! ale#codefix#Execute(range, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
for l:lsp_linter in l:lsp_linters
|
||||
call s:ExecuteGetCodeFix(l:lsp_linter, a:range, l:MenuCallback)
|
||||
for l:linter in l:linters
|
||||
call s:ExecuteGetCodeFix(l:linter, a:range, l:MenuCallback)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@@ -824,6 +824,8 @@ endfunction
|
||||
" the current buffer. 1 will be returned if there's a potential source of
|
||||
" completion data ALE can use, and 0 will be returned otherwise.
|
||||
function! ale#completion#CanProvideCompletions() abort
|
||||
" NOTE: We can report that ALE can provide completions to Deoplete from
|
||||
" here, and we might ignore linters still below.
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
return 1
|
||||
@@ -890,11 +892,9 @@ function! ale#completion#GetCompletions(...) abort
|
||||
|
||||
let l:started = 0
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
let l:started = 1
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(l:buffer)
|
||||
if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
let l:started = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
@@ -201,6 +201,35 @@ function! s:EchoLSPErrorMessages(all_linter_names) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:GetIgnoredLinters(buffer, enabled_linters) abort
|
||||
let l:filetype = &filetype
|
||||
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
|
||||
if (
|
||||
\ !empty(l:ignore_config)
|
||||
\ || l:disable_lsp is 1
|
||||
\ || l:disable_lsp is v:true
|
||||
\ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0))
|
||||
\)
|
||||
let l:non_ignored = ale#engine#ignore#Exclude(
|
||||
\ l:filetype,
|
||||
\ a:enabled_linters,
|
||||
\ l:ignore_config,
|
||||
\ l:disable_lsp,
|
||||
\)
|
||||
else
|
||||
let l:non_ignored = copy(a:enabled_linters)
|
||||
endif
|
||||
|
||||
call map(l:non_ignored, 'v:val.name')
|
||||
|
||||
return filter(
|
||||
\ copy(a:enabled_linters),
|
||||
\ 'index(l:non_ignored, v:val.name) < 0'
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! ale#debugging#Info(...) abort
|
||||
let l:options = (a:0 > 0) ? a:1 : {}
|
||||
let l:show_preview_info = get(l:options, 'preview')
|
||||
@@ -208,7 +237,6 @@ function! ale#debugging#Info(...) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:filetype = &filetype
|
||||
|
||||
" We get the list of enabled linters for free by the above function.
|
||||
let l:enabled_linters = deepcopy(ale#linter#Get(l:filetype))
|
||||
|
||||
" But have to build the list of available linters ourselves.
|
||||
@@ -232,13 +260,10 @@ function! ale#debugging#Info(...) abort
|
||||
let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1]))
|
||||
let l:fixers_string = join(map(copy(l:fixers), '"\n " . v:val'), '')
|
||||
|
||||
let l:non_ignored_names = map(
|
||||
\ copy(ale#linter#RemoveIgnored(l:buffer, l:filetype, l:enabled_linters)),
|
||||
\ 'v:val[''name'']',
|
||||
\)
|
||||
let l:ignored_names = filter(
|
||||
\ copy(l:enabled_names),
|
||||
\ 'index(l:non_ignored_names, v:val) < 0'
|
||||
" Get the names of ignored linters.
|
||||
let l:ignored_names = map(
|
||||
\ s:GetIgnoredLinters(l:buffer, l:enabled_linters),
|
||||
\ 'v:val.name'
|
||||
\)
|
||||
|
||||
call s:Echo(' Current Filetype: ' . l:filetype)
|
||||
|
||||
@@ -168,26 +168,20 @@ function! s:GoToLSPDefinition(linter, options, capability) abort
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoTo(options) abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'definition')
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'definition')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToType(options) abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition')
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToImpl(options) abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'implementation')
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'implementation')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ function! ale#engine#SendResultsToNeovimDiagnostics(buffer, loclist) abort
|
||||
|
||||
" Keep the Lua surface area really small in the VimL part of ALE,
|
||||
" and just require the diagnostics.lua module on demand.
|
||||
let l:SendDiagnostics = luaeval('require("diagnostics").sendAleResultsToDiagnostics')
|
||||
let l:SendDiagnostics = luaeval('require("ale.diagnostics").sendAleResultsToDiagnostics')
|
||||
call l:SendDiagnostics(a:buffer, a:loclist)
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Code for ignoring linters. Only loaded and if configured.
|
||||
|
||||
" A map for remapping lspconfig server names to linter names or aliases in
|
||||
" ALE. We should change the names where they will conflict with names in ALE.
|
||||
"
|
||||
" Notes on names from nvim-lspconfig not included here.
|
||||
"
|
||||
" * 'rubocop' is run in a language server mode
|
||||
" * 'eslint' is run via 'vscode-eslint-language-server'
|
||||
let s:lspconfig_map = {
|
||||
\ 'als': 'adals',
|
||||
\ 'ansiblels': 'ansible-language-server',
|
||||
\ 'bicep': 'bicep_language_server',
|
||||
\ 'cmake': 'cmake_language_server',
|
||||
\ 'denols': 'deno',
|
||||
\ 'erlangls': 'erlang_ls',
|
||||
\ 'html': 'vscodehtml',
|
||||
\ 'ocamlls': 'ocaml-language-server',
|
||||
\ 'ols': 'odin-lsp',
|
||||
\ 'puppet': 'puppet_languageserver',
|
||||
\}
|
||||
|
||||
" Given a filetype and a configuration for ignoring linters, return a List of
|
||||
" Strings for linter names to ignore.
|
||||
function! ale#engine#ignore#GetList(filetype, config) abort
|
||||
@@ -21,24 +41,51 @@ function! ale#engine#ignore#GetList(filetype, config) abort
|
||||
return []
|
||||
endfunction
|
||||
|
||||
" This function can be mocked in tests.
|
||||
function! ale#engine#ignore#GetLSPConfigNames() abort
|
||||
return luaeval('require ''ale.util''.configured_lspconfig_servers()')
|
||||
endfunction
|
||||
|
||||
function! s:GetMappedLSPConfigNames() abort
|
||||
" Check the lspconfig flag before calling luaeval.
|
||||
if !get(g:, 'lspconfig', 0)
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:lspconfig_servers = ale#engine#ignore#GetLSPConfigNames()
|
||||
|
||||
return map(
|
||||
\ !empty(l:lspconfig_servers) ? l:lspconfig_servers : [],
|
||||
\ {_, val -> get(s:lspconfig_map, val, val) }
|
||||
\)
|
||||
endfunction
|
||||
|
||||
" Given a List of linter descriptions, exclude the linters to be ignored.
|
||||
function! ale#engine#ignore#Exclude(filetype, all_linters, config, disable_lsp) abort
|
||||
let l:names_to_remove = ale#engine#ignore#GetList(a:filetype, a:config)
|
||||
|
||||
" If configured to automatically ignore otherwise configured LSP linter
|
||||
" names, add them to the names to remove. This could ignore linters
|
||||
" with matching names that are not marked as LSP linters.
|
||||
if a:disable_lsp is# 'auto'
|
||||
call extend(l:names_to_remove, s:GetMappedLSPConfigNames())
|
||||
endif
|
||||
|
||||
let l:ignore_all_lsps = a:disable_lsp is 1 || a:disable_lsp is v:true
|
||||
let l:filtered_linters = []
|
||||
|
||||
for l:linter in a:all_linters
|
||||
let l:name_list = [l:linter.name] + l:linter.aliases
|
||||
let l:should_include = 1
|
||||
let l:should_include = index(l:names_to_remove, l:linter.name) == -1
|
||||
let l:i = 0
|
||||
|
||||
for l:name in l:name_list
|
||||
if index(l:names_to_remove, l:name) >= 0
|
||||
let l:should_include = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
while l:should_include && l:i < len(l:linter.aliases)
|
||||
let l:name = l:linter.aliases[l:i]
|
||||
let l:should_include = index(l:names_to_remove, l:name) == -1
|
||||
let l:i += 1
|
||||
endwhile
|
||||
|
||||
if a:disable_lsp && has_key(l:linter, 'lsp') && l:linter.lsp isnot# ''
|
||||
let l:should_include = 0
|
||||
if l:should_include && l:ignore_all_lsps
|
||||
let l:should_include = empty(get(l:linter, 'lsp'))
|
||||
endif
|
||||
|
||||
if l:should_include
|
||||
|
||||
@@ -94,9 +94,10 @@ function! s:ExecuteFileRename(linter, options) abort
|
||||
endfunction
|
||||
|
||||
function! ale#filerename#Execute() abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:lsp_linters = []
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
for l:linter in ale#lsp_linter#GetEnabled(l:buffer)
|
||||
if l:linter.lsp is# 'tsserver'
|
||||
call add(l:lsp_linters, l:linter)
|
||||
endif
|
||||
@@ -108,7 +109,6 @@ function! ale#filerename#Execute() abort
|
||||
return
|
||||
endif
|
||||
|
||||
let l:buffer = bufnr('')
|
||||
let l:old_name = expand('#' . l:buffer . ':p')
|
||||
let l:new_name = ale#util#Input('New file name: ', l:old_name, 'file')
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ endfunction
|
||||
" Define the hdl_checker linter for a given filetype.
|
||||
function! ale#handlers#hdl_checker#DefineLinter(filetype) abort
|
||||
call ale#linter#Define(a:filetype, {
|
||||
\ 'name': 'hdl-checker',
|
||||
\ 'name': 'hdl_checker',
|
||||
\ 'aliases': ['hdl-checker'],
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'language': a:filetype,
|
||||
\ 'executable': function('ale#handlers#hdl_checker#GetExecutable'),
|
||||
@@ -70,4 +71,3 @@ function! ale#handlers#hdl_checker#DefineLinter(filetype) abort
|
||||
\ 'initialization_options': function('ale#handlers#hdl_checker#GetInitOptions'),
|
||||
\ })
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -329,10 +329,9 @@ function! ale#hover#Show(buffer, line, col, opt) abort
|
||||
let l:show_documentation = get(a:opt, 'show_documentation', 0)
|
||||
let l:Callback = function('s:OnReady', [a:line, a:col, a:opt])
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(a:buffer, '&filetype'))
|
||||
for l:linter in ale#lsp_linter#GetEnabled(a:buffer)
|
||||
" Only tsserver supports documentation requests at the moment.
|
||||
if !empty(l:linter.lsp)
|
||||
\&& (!l:show_documentation || l:linter.lsp is# 'tsserver')
|
||||
if !l:show_documentation || l:linter.lsp is# 'tsserver'
|
||||
call ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback)
|
||||
endif
|
||||
endfor
|
||||
|
||||
@@ -417,16 +417,6 @@ function! ale#linter#Get(original_filetypes) abort
|
||||
return reverse(l:combined_linters)
|
||||
endfunction
|
||||
|
||||
function! ale#linter#RemoveIgnored(buffer, filetype, linters) abort
|
||||
" Apply ignore lists for linters only if needed.
|
||||
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
|
||||
return !empty(l:ignore_config) || l:disable_lsp
|
||||
\ ? ale#engine#ignore#Exclude(a:filetype, a:linters, l:ignore_config, l:disable_lsp)
|
||||
\ : a:linters
|
||||
endfunction
|
||||
|
||||
" Given a buffer and linter, get the executable String for the linter.
|
||||
function! ale#linter#GetExecutable(buffer, linter) abort
|
||||
let l:Executable = a:linter.executable
|
||||
|
||||
@@ -15,6 +15,8 @@ function! ale#lsp#reset#StopAllLSPs() abort
|
||||
for l:buffer_string in keys(g:ale_buffer_info)
|
||||
let l:buffer = str2nr(l:buffer_string)
|
||||
|
||||
" Non-ignored and disabled linters are included here so we can
|
||||
" clear results for them after we ignore or disable them.
|
||||
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, [], 0)
|
||||
|
||||
@@ -27,28 +27,62 @@ function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort
|
||||
let s:lsp_linter_map = a:replacement_map
|
||||
endfunction
|
||||
|
||||
" Check if diagnostics for a particular linter should be ignored.
|
||||
function! s:ShouldIgnore(buffer, linter_name) abort
|
||||
" Ignore all diagnostics if LSP integration is disabled.
|
||||
if ale#Var(a:buffer, 'disable_lsp')
|
||||
return 1
|
||||
endif
|
||||
|
||||
let l:config = ale#Var(a:buffer, 'linters_ignore')
|
||||
|
||||
" Don't load code for ignoring diagnostics if there's nothing to ignore.
|
||||
if empty(l:config)
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Get all enabled LSP linters.
|
||||
" This list still includes linters ignored with `ale_linters_ignore`.
|
||||
"
|
||||
" `ale_linters_ignore` is designed to allow language servers to be used for
|
||||
" their functionality while ignoring the diagnostics they return.
|
||||
function! ale#lsp_linter#GetEnabled(buffer) abort
|
||||
let l:filetype = getbufvar(a:buffer, '&filetype')
|
||||
let l:ignore_list = ale#engine#ignore#GetList(l:filetype, l:config)
|
||||
" Only LSP linters are included here.
|
||||
let l:linters = filter(ale#linter#Get(l:filetype), '!empty(v:val.lsp)')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
|
||||
return index(l:ignore_list, a:linter_name) >= 0
|
||||
" Only load code for ignoring linters if we need it.
|
||||
if (
|
||||
\ l:disable_lsp is 1
|
||||
\ || l:disable_lsp is v:true
|
||||
\ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0))
|
||||
\)
|
||||
let l:linters = ale#engine#ignore#Exclude(
|
||||
\ l:filetype,
|
||||
\ l:linters,
|
||||
\ [],
|
||||
\ l:disable_lsp,
|
||||
\)
|
||||
endif
|
||||
|
||||
return l:linters
|
||||
endfunction
|
||||
|
||||
" Check if diagnostics for a particular linter should be ignored.
|
||||
function! s:ShouldIgnoreDiagnostics(buffer, linter) abort
|
||||
let l:config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
|
||||
" Only load code for ignoring linters if we need it.
|
||||
if (
|
||||
\ !empty(l:config)
|
||||
\ || l:disable_lsp is 1
|
||||
\ || l:disable_lsp is v:true
|
||||
\ || (l:disable_lsp is# 'auto' && get(g:, 'lspconfig', 0))
|
||||
\)
|
||||
" Re-use the ignore implementation just for this linter.
|
||||
return empty(
|
||||
\ ale#engine#ignore#Exclude(
|
||||
\ getbufvar(a:buffer, '&filetype'),
|
||||
\ [a:linter],
|
||||
\ l:config,
|
||||
\ l:disable_lsp,
|
||||
\ )
|
||||
\)
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:HandleLSPDiagnostics(conn_id, response) abort
|
||||
let l:linter_name = s:lsp_linter_map[a:conn_id]
|
||||
let l:linter = s:lsp_linter_map[a:conn_id]
|
||||
let l:filename = ale#util#ToResource(a:response.params.uri)
|
||||
let l:escaped_name = escape(
|
||||
\ fnameescape(l:filename),
|
||||
@@ -61,17 +95,22 @@ function! s:HandleLSPDiagnostics(conn_id, response) abort
|
||||
return
|
||||
endif
|
||||
|
||||
if s:ShouldIgnore(l:buffer, l:linter_name)
|
||||
if s:ShouldIgnoreDiagnostics(l:buffer, l:linter)
|
||||
return
|
||||
endif
|
||||
|
||||
let l:loclist = ale#lsp#response#ReadDiagnostics(a:response)
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0)
|
||||
endfunction
|
||||
|
||||
function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
let l:linter_name = 'tsserver'
|
||||
" Re-create a fake linter object for tsserver.
|
||||
let l:linter = {
|
||||
\ 'name': 'tsserver',
|
||||
\ 'aliases': [],
|
||||
\ 'lsp': 'tsserver',
|
||||
\}
|
||||
let l:escaped_name = escape(
|
||||
\ fnameescape(a:response.body.file),
|
||||
\ has('win32') ? '^' : '^,}]'
|
||||
@@ -83,9 +122,9 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
return
|
||||
endif
|
||||
|
||||
call ale#engine#MarkLinterInactive(l:info, l:linter_name)
|
||||
call ale#engine#MarkLinterInactive(l:info, l:linter.name)
|
||||
|
||||
if s:ShouldIgnore(l:buffer, l:linter_name)
|
||||
if s:ShouldIgnoreDiagnostics(l:buffer, l:linter)
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -123,15 +162,15 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
|
||||
\ + get(l:info, 'suggestion_loclist', [])
|
||||
\ + get(l:info, 'syntax_loclist', [])
|
||||
|
||||
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
|
||||
call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0)
|
||||
endfunction
|
||||
|
||||
function! s:HandleLSPErrorMessage(linter_name, response) abort
|
||||
function! s:HandleLSPErrorMessage(linter, response) abort
|
||||
if !g:ale_history_enabled || !g:ale_history_log_output
|
||||
return
|
||||
endif
|
||||
|
||||
if empty(a:linter_name)
|
||||
if empty(a:linter)
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -141,7 +180,7 @@ function! s:HandleLSPErrorMessage(linter_name, response) abort
|
||||
return
|
||||
endif
|
||||
|
||||
call ale#lsp_linter#AddErrorMessage(a:linter_name, l:message)
|
||||
call ale#lsp_linter#AddErrorMessage(a:linter.name, l:message)
|
||||
endfunction
|
||||
|
||||
function! ale#lsp_linter#AddErrorMessage(linter_name, message) abort
|
||||
@@ -160,14 +199,14 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
|
||||
let l:method = get(a:response, 'method', '')
|
||||
|
||||
if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error')
|
||||
let l:linter_name = get(s:lsp_linter_map, a:conn_id, '')
|
||||
let l:linter = get(s:lsp_linter_map, a:conn_id, {})
|
||||
|
||||
call s:HandleLSPErrorMessage(l:linter_name, a:response)
|
||||
call s:HandleLSPErrorMessage(l:linter, a:response)
|
||||
elseif l:method is# 'textDocument/publishDiagnostics'
|
||||
call s:HandleLSPDiagnostics(a:conn_id, a:response)
|
||||
elseif l:method is# 'window/showMessage'
|
||||
call ale#lsp_window#HandleShowMessage(
|
||||
\ s:lsp_linter_map[a:conn_id],
|
||||
\ s:lsp_linter_map[a:conn_id].name,
|
||||
\ g:ale_lsp_show_message_format,
|
||||
\ a:response.params
|
||||
\)
|
||||
@@ -472,7 +511,7 @@ function! s:CheckWithLSP(linter, details) abort
|
||||
call ale#lsp#RegisterCallback(l:id, l:Callback)
|
||||
|
||||
" Remember the linter this connection is for.
|
||||
let s:lsp_linter_map[l:id] = a:linter.name
|
||||
let s:lsp_linter_map[l:id] = a:linter
|
||||
|
||||
if a:linter.lsp is# 'tsserver'
|
||||
let l:message = ale#lsp#tsserver_message#Geterr(l:buffer)
|
||||
|
||||
@@ -57,9 +57,7 @@ function! s:OrganizeImports(linter) abort
|
||||
endfunction
|
||||
|
||||
function! ale#organize_imports#Execute() abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:OrganizeImports(l:linter)
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
call s:OrganizeImports(l:linter)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@@ -179,9 +179,7 @@ function! ale#references#Find(...) abort
|
||||
let l:column = min([l:column, len(getline(l:line))])
|
||||
let l:Callback = function('s:OnReady', [l:line, l:column, l:options])
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
endif
|
||||
for l:linter in ale#lsp_linter#GetEnabled(l:buffer)
|
||||
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@@ -178,15 +178,9 @@ function! s:ExecuteRename(linter, options) abort
|
||||
endfunction
|
||||
|
||||
function! ale#rename#Execute() abort
|
||||
let l:lsp_linters = []
|
||||
let l:linters = ale#lsp_linter#GetEnabled(bufnr(''))
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call add(l:lsp_linters, l:linter)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if empty(l:lsp_linters)
|
||||
if empty(l:linters)
|
||||
call s:message('No active LSPs')
|
||||
|
||||
return
|
||||
@@ -201,8 +195,8 @@ function! ale#rename#Execute() abort
|
||||
return
|
||||
endif
|
||||
|
||||
for l:lsp_linter in l:lsp_linters
|
||||
call s:ExecuteRename(l:lsp_linter, {
|
||||
for l:linter in l:linters
|
||||
call s:ExecuteRename(l:linter, {
|
||||
\ 'old_name': l:old_name,
|
||||
\ 'new_name': l:new_name,
|
||||
\})
|
||||
|
||||
@@ -102,8 +102,8 @@ function! ale#symbol#Search(args) abort
|
||||
call setbufvar(l:buffer, 'ale_symbol_request_made', 0)
|
||||
let l:Callback = function('s:OnReady', [l:query, l:options])
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver'
|
||||
for l:linter in ale#lsp_linter#GetEnabled(l:buffer)
|
||||
if l:linter.lsp isnot# 'tsserver'
|
||||
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
endif
|
||||
endfor
|
||||
|
||||
@@ -39,6 +39,8 @@ endfunction
|
||||
function! ale#uri#jdt#OpenJDTLink(encoded_uri, line, column, options, conn_id) abort
|
||||
let l:found_eclipselsp = v:false
|
||||
|
||||
" We should only arrive here from a 'go to definition' request, so we'll
|
||||
" assume the eclipselsp linter is enabled.
|
||||
for l:linter in ale#linter#Get('java')
|
||||
if l:linter.name is# 'eclipselsp'
|
||||
let l:found_eclipselsp = v:true
|
||||
@@ -87,8 +89,8 @@ function! ale#uri#jdt#ReadJDTLink(encoded_uri) abort
|
||||
|
||||
let l:linter_map = ale#lsp_linter#GetLSPLinterMap()
|
||||
|
||||
for l:conn_id in keys(l:linter_map)
|
||||
if l:linter_map[l:conn_id] is# 'eclipselsp'
|
||||
for [l:conn_id, l:linter] in items(l:linter_map)
|
||||
if l:linter.name is# 'eclipselsp'
|
||||
let l:root = l:conn_id[stridx(l:conn_id, ':')+1:]
|
||||
endif
|
||||
endfor
|
||||
|
||||
Reference in New Issue
Block a user