diff options
Diffstat (limited to 'mac/.config/LunarVim/lua/lvim/lsp/null-ls/linters.lua')
| -rw-r--r-- | mac/.config/LunarVim/lua/lvim/lsp/null-ls/linters.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mac/.config/LunarVim/lua/lvim/lsp/null-ls/linters.lua b/mac/.config/LunarVim/lua/lvim/lsp/null-ls/linters.lua new file mode 100644 index 0000000..ba7670d --- /dev/null +++ b/mac/.config/LunarVim/lua/lvim/lsp/null-ls/linters.lua @@ -0,0 +1,43 @@ +local M = {} + +local Log = require "lvim.core.log" + +local null_ls = require "null-ls" +local services = require "lvim.lsp.null-ls.services" +local method = null_ls.methods.DIAGNOSTICS + +local alternative_methods = { + null_ls.methods.DIAGNOSTICS, + null_ls.methods.DIAGNOSTICS_ON_OPEN, + null_ls.methods.DIAGNOSTICS_ON_SAVE, +} + +function M.list_registered(filetype) + local registered_providers = services.list_registered_providers_names(filetype) + local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m) + return registered_providers[m] or {} + end, alternative_methods)) + + return providers_for_methods +end + +function M.list_supported(filetype) + local s = require "null-ls.sources" + local supported_linters = s.get_supported(filetype, "diagnostics") + table.sort(supported_linters) + return supported_linters +end + +function M.setup(linter_configs) + if vim.tbl_isempty(linter_configs) then + return + end + + local registered = services.register_sources(linter_configs, method) + + if #registered > 0 then + Log:debug("Registered the following linters: " .. unpack(registered)) + end +end + +return M |
