summaryrefslogtreecommitdiff
path: root/autoload/ale
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/ale')
-rw-r--r--autoload/ale/code_action.vim12
-rw-r--r--autoload/ale/codefix.vim14
-rw-r--r--autoload/ale/completion.vim10
-rw-r--r--autoload/ale/debugging.vim41
-rw-r--r--autoload/ale/definition.vim18
-rw-r--r--autoload/ale/engine.vim2
-rw-r--r--autoload/ale/engine/ignore.vim69
-rw-r--r--autoload/ale/filerename.vim4
-rw-r--r--autoload/ale/handlers/hdl_checker.vim4
-rw-r--r--autoload/ale/hover.vim5
-rw-r--r--autoload/ale/linter.vim10
-rw-r--r--autoload/ale/lsp/reset.vim2
-rw-r--r--autoload/ale/lsp_linter.vim93
-rw-r--r--autoload/ale/organize_imports.vim6
-rw-r--r--autoload/ale/references.vim6
-rw-r--r--autoload/ale/rename.vim14
-rw-r--r--autoload/ale/symbol.vim4
-rw-r--r--autoload/ale/uri/jdt.vim6
18 files changed, 196 insertions, 124 deletions
diff --git a/autoload/ale/code_action.vim b/autoload/ale/code_action.vim
index db31aad5..4167e907 100644
--- a/autoload/ale/code_action.vim
+++ b/autoload/ale/code_action.vim
@@ -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
diff --git a/autoload/ale/codefix.vim b/autoload/ale/codefix.vim
index 34ce3e15..6eaadb23 100644
--- a/autoload/ale/codefix.vim
+++ b/autoload/ale/codefix.vim
@@ -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
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index c05ca53d..4fd02721 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -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
diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim
index 1becf332..89f5258f 100644
--- a/autoload/ale/debugging.vim
+++ b/autoload/ale/debugging.vim
@@ -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)
diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim
index fd6cd2e1..251bdcc5 100644
--- a/autoload/ale/definition.vim
+++ b/autoload/ale/definition.vim
@@ -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
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 185d54db..7e337191 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -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
diff --git a/autoload/ale/engine/ignore.vim b/autoload/ale/engine/ignore.vim
index 80574656..8ac36eb5 100644
--- a/autoload/ale/engine/ignore.vim
+++ b/autoload/ale/engine/ignore.vim
@@ -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
-
- for l:name in l:name_list
- if index(l:names_to_remove, l:name) >= 0
- let l:should_include = 0
- break
- endif
- endfor
+ let l:should_include = index(l:names_to_remove, l:linter.name) == -1
+ let l:i = 0
+
+ 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
diff --git a/autoload/ale/filerename.vim b/autoload/ale/filerename.vim
index ec20d279..93cf78e1 100644
--- a/autoload/ale/filerename.vim
+++ b/autoload/ale/filerename.vim
@@ -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')
diff --git a/autoload/ale/handlers/hdl_checker.vim b/autoload/ale/handlers/hdl_checker.vim
index e871b083..d45f86e1 100644
--- a/autoload/ale/handlers/hdl_checker.vim
+++ b/autoload/ale/handlers/hdl_checker.vim
@@ -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
-
diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim
index 6ad43316..7070b86d 100644
--- a/autoload/ale/hover.vim
+++ b/autoload/ale/hover.vim
@@ -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
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 73c47109..20104fbc 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -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
diff --git a/autoload/ale/lsp/reset.vim b/autoload/ale/lsp/reset.vim
index 2fc7f0a2..85188b5a 100644
--- a/autoload/ale/lsp/reset.vim
+++ b/autoload/ale/lsp/reset.vim
@@ -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)
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index 1c98d628..05a0294c 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -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
+" 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')
+ " 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')
+
+ " 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
- let l:config = ale#Var(a:buffer, 'linters_ignore')
+ return l:linters
+endfunction
- " Don't load code for ignoring diagnostics if there's nothing to ignore.
- if empty(l:config)
- return 0
+" 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
- let l:filetype = getbufvar(a:buffer, '&filetype')
- let l:ignore_list = ale#engine#ignore#GetList(l:filetype, l:config)
-
- return index(l:ignore_list, a:linter_name) >= 0
+ 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)
diff --git a/autoload/ale/organize_imports.vim b/autoload/ale/organize_imports.vim
index 395e6fbd..fb00bc21 100644
--- a/autoload/ale/organize_imports.vim
+++ b/autoload/ale/organize_imports.vim
@@ -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
diff --git a/autoload/ale/references.vim b/autoload/ale/references.vim
index c32663fe..df253c9c 100644
--- a/autoload/ale/references.vim
+++ b/autoload/ale/references.vim
@@ -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
diff --git a/autoload/ale/rename.vim b/autoload/ale/rename.vim
index 53c9fb5c..d7bc8699 100644
--- a/autoload/ale/rename.vim
+++ b/autoload/ale/rename.vim
@@ -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,
\})
diff --git a/autoload/ale/symbol.vim b/autoload/ale/symbol.vim
index 6c65f1b2..ba971e74 100644
--- a/autoload/ale/symbol.vim
+++ b/autoload/ale/symbol.vim
@@ -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
diff --git a/autoload/ale/uri/jdt.vim b/autoload/ale/uri/jdt.vim
index 46cea268..11a22d34 100644
--- a/autoload/ale/uri/jdt.vim
+++ b/autoload/ale/uri/jdt.vim
@@ -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