From 77cdf208765ad351e48724ed5ad57e55703eca61 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 5 Oct 2021 08:46:35 +0200 Subject: Add major update to LSP from lunarvim --- .config/nvim/lua/lsp/null-ls/linters.lua | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to '.config/nvim/lua/lsp/null-ls/linters.lua') diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua index 0f6cbc1..e9e92e9 100644 --- a/.config/nvim/lua/lsp/null-ls/linters.lua +++ b/.config/nvim/lua/lsp/null-ls/linters.lua @@ -1,29 +1,14 @@ local M = {} -local linters_by_ft = {} local null_ls = require "null-ls" local services = require "lsp.null-ls.services" -local Log = require("core.log") - -local function list_names(linters, option) - option = option or {} - local filter = option.filter or "supported" - - return vim.tbl_keys(linters[filter]) -end +local Log = require "core.log" function M.list_supported_names(filetype) - if not linters_by_ft[filetype] then - return {} - end - return list_names(linters_by_ft[filetype], { filter = "supported" }) -end - -function M.list_unsupported_names(filetype) - if not linters_by_ft[filetype] then - return {} - end - return list_names(linters_by_ft[filetype], { filter = "unsupported" }) + local null_ls_methods = require "null-ls.methods" + local linter_method = null_ls_methods.internal["DIAGNOSTICS"] + local registered_providers = services.list_registered_providers_names(filetype) + return registered_providers[linter_method] or {} end function M.list_available(filetype) @@ -65,12 +50,13 @@ function M.list_configured(linter_configs) return { supported = linters, unsupported = errors } end -function M.setup(filetype, option) - if not options.lang[filetype] or (linters_by_ft[filetype] and not option.force_reload) then +function M.setup(linter_configs, filetype) + if vim.tbl_isempty(linter_configs) then return end - linters_by_ft[filetype] = M.list_configured(options.lang[filetype].linters) + local linters_by_ft = {} + linters_by_ft[filetype] = M.list_configured(linter_configs) null_ls.register { sources = linters_by_ft[filetype].supported } end -- cgit v1.2.3-70-g09d2