diff options
Diffstat (limited to '.config/nvim/lua/lsp/null-ls/init.lua')
-rw-r--r-- | .config/nvim/lua/lsp/null-ls/init.lua | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/.config/nvim/lua/lsp/null-ls/init.lua b/.config/nvim/lua/lsp/null-ls/init.lua index d12b40a..571fb6b 100644 --- a/.config/nvim/lua/lsp/null-ls/init.lua +++ b/.config/nvim/lua/lsp/null-ls/init.lua @@ -1,44 +1,26 @@ 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"):error "Missing null-ls dependency" +local Log = require "core.log" +local formatters = require "lsp.null-ls.formatters" +local linters = require "lsp.null-ls.linters" + +function M:setup() + local status_ok, null_ls = pcall(require, "null-ls") + if not status_ok then + Log: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) + null_ls.config() + require("lspconfig")["null-ls"].setup(options.lsp.null_ls.setup) + for _, filetype in pairs(options.lang) do + if filetype.formatters then + formatters.setup(filetype.formatters, filetype) + end + if filetype.linters then + linters.setup(filetype.linters, filetype) + end + end end return M |