summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/null-ls/init.lua
blob: f2b10427c5b42442181d362641b41046ebc00f08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local M = {}

function M.list_supported_provider_names(filetype)
  local names = {}

  local formatters = require "lsp.null-ls.formatters"
  local linters = require "lsp.null-ls.linters"

  vim.list_extend(names, formatters.list_supported_names(filetype))
  vim.list_extend(names, linters.list_supported_names(filetype))

  return names
end

function M.list_unsupported_provider_names(filetype)
  local names = {}

  local formatters = require "lsp.null-ls.formatters"
  local linters = require "lsp.null-ls.linters"

  vim.list_extend(names, formatters.list_unsupported_names(filetype))
  vim.list_extend(names, linters.list_unsupported_names(filetype))

  return names
end

-- TODO: for linters and formatters with spaces and '-' replace with '_'
function M.setup(filetype, option)
  option = option or {}

  local ok, _ = pcall(require, "null-ls")
  if not ok then
    require("core.log"):get_default().error "Missing null-ls dependency"
    return
  end

  local formatters = require "lsp.null-ls.formatters"
  local linters = require "lsp.null-ls.linters"

  formatters.setup(filetype, option)
  linters.setup(filetype, option)
end

return M