diff options
author | kylo252 <[email protected]> | 2022-01-01 14:25:23 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-01-01 14:25:23 +0100 |
commit | 91077623f093bf173ea9b224bb7bde15f3c2a13b (patch) | |
tree | 767b285146429dc724d2d9cacf272154941bd3fb /lua/lvim/lsp/null-ls | |
parent | 7d1b2f697b70cd81adb34c734a6e02fdf991d2db (diff) |
refactor(info): use new null-ls api for sources (#2125)
Diffstat (limited to 'lua/lvim/lsp/null-ls')
-rw-r--r-- | lua/lvim/lsp/null-ls/code_actions.lua | 11 | ||||
-rw-r--r-- | lua/lvim/lsp/null-ls/formatters.lua | 20 | ||||
-rw-r--r-- | lua/lvim/lsp/null-ls/linters.lua | 20 |
3 files changed, 13 insertions, 38 deletions
diff --git a/lua/lvim/lsp/null-ls/code_actions.lua b/lua/lvim/lsp/null-ls/code_actions.lua index ff59fabf..bf6492b5 100644 --- a/lua/lvim/lsp/null-ls/code_actions.lua +++ b/lua/lvim/lsp/null-ls/code_actions.lua @@ -14,20 +14,11 @@ local is_registered = function(name) return require("null-ls.sources").is_registered(query) end -function M.list_registered_providers(filetype) +function M.list_registered(filetype) local registered_providers = services.list_registered_providers_names(filetype) return registered_providers[METHOD] or {} end -function M.list_available(filetype) - local availables = require("null-ls.sources").get_available(filetype, METHOD) - local actors = vim.tbl_map(function(src) - return src.name - end, availables) - table.sort(actors) - return actors -end - function M.list_configured(actions_configs) local actors, errors = {}, {} diff --git a/lua/lvim/lsp/null-ls/formatters.lua b/lua/lvim/lsp/null-ls/formatters.lua index b2e191c5..0613f16f 100644 --- a/lua/lvim/lsp/null-ls/formatters.lua +++ b/lua/lvim/lsp/null-ls/formatters.lua @@ -12,26 +12,18 @@ local is_registered = function(name) return require("null-ls.sources").is_registered(query) end -function M.list_registered_providers(filetype) +function M.list_registered(filetype) local null_ls_methods = require "null-ls.methods" local formatter_method = null_ls_methods.internal["FORMATTING"] local registered_providers = services.list_registered_providers_names(filetype) return registered_providers[formatter_method] or {} end -function M.list_available(filetype) - local formatters = {} - local tbl = require "lvim.utils.table" - for _, provider in pairs(null_ls.builtins.formatting) do - if tbl.contains(provider.filetypes or {}, function(ft) - return ft == "*" or ft == filetype - end) then - table.insert(formatters, provider.name) - end - end - - table.sort(formatters) - return formatters +function M.list_supported(filetype) + local s = require "null-ls.sources" + local supported_formatters = s.get_supported(filetype, "formatting") + table.sort(supported_formatters) + return supported_formatters end function M.list_configured(formatter_configs) diff --git a/lua/lvim/lsp/null-ls/linters.lua b/lua/lvim/lsp/null-ls/linters.lua index 6a793d26..67e530a9 100644 --- a/lua/lvim/lsp/null-ls/linters.lua +++ b/lua/lvim/lsp/null-ls/linters.lua @@ -12,26 +12,18 @@ local is_registered = function(name) return require("null-ls.sources").is_registered(query) end -function M.list_registered_providers(filetype) +function M.list_registered(filetype) 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) - local linters = {} - local tbl = require "lvim.utils.table" - for _, provider in pairs(null_ls.builtins.diagnostics) do - if tbl.contains(provider.filetypes or {}, function(ft) - return ft == "*" or ft == filetype - end) then - table.insert(linters, provider.name) - end - end - - table.sort(linters) - return linters +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.list_configured(linter_configs) |