diff options
Diffstat (limited to 'lua/utils')
| -rw-r--r-- | lua/utils/init.lua | 28 | 
1 files changed, 28 insertions, 0 deletions
diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 16ad5e4a..df472c66 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -113,6 +113,34 @@ function utils.get_active_client_by_ft(filetype)    return nil  end +-- TODO: consider porting this logic to null-ls instead +function utils.get_supported_linters_by_filetype(filetype) +  local null_ls = require "null-ls" +  local matches = {} +  for _, provider in pairs(null_ls.builtins.diagnostics) do +    if vim.tbl_contains(provider.filetypes, filetype) then +      local provider_name = provider.name + +      table.insert(matches, provider_name) +    end +  end + +  return matches +end + +function utils.get_supported_formatters_by_filetype(filetype) +  local null_ls = require "null-ls" +  local matches = {} +  for _, provider in pairs(null_ls.builtins.formatting) do +    if provider.filetypes and vim.tbl_contains(provider.filetypes, filetype) then +      -- table.insert(matches, { provider.name, ft }) +      table.insert(matches, provider.name) +    end +  end + +  return matches +end +  function utils.unrequire(m)    package.loaded[m] = nil    _G[m] = nil  | 
