fix: Use null-ls eslint diagnostics config with eslint_d exe (#1159)

This commit is contained in:
Pasi Bergman 2021-07-29 16:03:03 +03:00 committed by GitHub
parent 7960a0e769
commit 3eaf6d461c
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,15 +13,25 @@ local find_local_exe = function(exe)
return local_exe
end
-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint
local get_normalized_exe = function(exe, type)
if type == "diagnostics" and exe == "eslint_d" then
return "eslint"
end
return exe
end
local function setup_ls(exe, type)
if utils.has_value(local_executables, exe) then
local smart_executable = null_ls.builtins[type][exe]
local normalized_exe = get_normalized_exe(exe, type)
local smart_executable = null_ls.builtins[type][normalized_exe]
local local_executable = find_local_exe(exe)
if vim.fn.executable(local_executable) == 1 then
smart_executable._opts.command = local_executable
table.insert(sources, smart_executable)
else
if vim.fn.executable(exe) == 1 then
smart_executable._opts.command = exe
table.insert(sources, smart_executable)
end
end