diff options
Diffstat (limited to 'lua/lvim/lsp/null-ls/linters.lua')
-rw-r--r-- | lua/lvim/lsp/null-ls/linters.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lua/lvim/lsp/null-ls/linters.lua b/lua/lvim/lsp/null-ls/linters.lua index ced4bf34..efc3ffad 100644 --- a/lua/lvim/lsp/null-ls/linters.lua +++ b/lua/lvim/lsp/null-ls/linters.lua @@ -4,6 +4,8 @@ local null_ls = require "null-ls" local services = require "lvim.lsp.null-ls.services" local Log = require "lvim.core.log" +local is_registered = require("null-ls.sources").is_registered + function M.list_registered_providers(filetype) local null_ls_methods = require "null-ls.methods" local linter_method = null_ls_methods.internal["DIAGNOSTICS"] @@ -21,6 +23,7 @@ function M.list_available(filetype) table.insert(linters, provider.name) end end + table.sort(linters) return linters end @@ -29,24 +32,29 @@ function M.list_configured(linter_configs) local linters, errors = {}, {} for _, lnt_config in pairs(linter_configs) do - local linter_name = lnt_config.exe:gsub("-", "_") - local linter = null_ls.builtins.diagnostics[linter_name] + local name = lnt_config.exe:gsub("-", "_") + local linter = null_ls.builtins.diagnostics[name] if not linter then Log:error("Not a valid linter: " .. lnt_config.exe) errors[lnt_config.exe] = {} -- Add data here when necessary + elseif is_registered(lnt_config.exe) then + Log:trace "Skipping registering the source more than once" else local linter_cmd = services.find_command(linter._opts.command) if not linter_cmd then Log:warn("Not found: " .. linter._opts.command) - errors[lnt_config.exe] = {} -- Add data here when necessary + errors[name] = {} -- Add data here when necessary else Log:debug("Using linter: " .. linter_cmd) - linters[lnt_config.exe] = linter.with { - command = linter_cmd, - extra_args = lnt_config.args, - filetypes = lnt_config.filetypes, - } + table.insert( + linters, + linter.with { + command = linter_cmd, + extra_args = lnt_config.args, + filetypes = lnt_config.filetypes, + } + ) end end end |