summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/null-ls
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/lsp/null-ls')
-rw-r--r--.config/nvim/lua/lsp/null-ls/code_actions.lua81
-rw-r--r--.config/nvim/lua/lsp/null-ls/formatters.lua82
-rw-r--r--.config/nvim/lua/lsp/null-ls/init.lua22
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua82
-rw-r--r--.config/nvim/lua/lsp/null-ls/services.lua61
5 files changed, 0 insertions, 328 deletions
diff --git a/.config/nvim/lua/lsp/null-ls/code_actions.lua b/.config/nvim/lua/lsp/null-ls/code_actions.lua
deleted file mode 100644
index 70cecda..0000000
--- a/.config/nvim/lua/lsp/null-ls/code_actions.lua
+++ /dev/null
@@ -1,81 +0,0 @@
-local M = {}
-
-local null_ls = require "null-ls"
-local services = require "lsp.null-ls.services"
-local Log = require "core.log"
-
-local METHOD = null_ls.methods.CODE_ACTION
-
-local is_registered = function(name)
- local query = {
- name = name,
- method = METHOD,
- }
- return require("null-ls.sources").is_registered(query)
-end
-
-function M.list_registered_providers(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 = {}, {}
-
- for _, config in ipairs(actions_configs) do
- vim.validate {
- ["config.name"] = { config.name, "string" },
- }
-
- local name = config.name:gsub("-", "_")
- local actor = null_ls.builtins.code_actions[name]
-
- if not actor then
- Log:error("Not a valid code_actions: " .. config.name)
- errors[name] = {} -- Add data here when necessary
- elseif is_registered(config.name) then
- Log:trace "Skipping registering the source more than once"
- else
- local command
- if actor._opts.command then
- command = services.find_command(actor._opts.command)
- end
- if not command and actor._opts.command ~= nil then
- Log:warn("Not found: " .. actor._opts.command)
- errors[name] = {} -- Add data here when necessary
- else
- Log:debug("Using code_actions: " .. (command or config.name))
- table.insert(
- actors,
- actor.with {
- command = command, -- could be nil
- extra_args = config.args,
- filetypes = config.filetypes,
- }
- )
- end
- end
- end
-
- return { supported = actors, unsupported = errors }
-end
-
-function M.setup(actions_configs)
- if vim.tbl_isempty(actions_configs) then
- return
- end
-
- local actions = M.list_configured(actions_configs)
- null_ls.register { sources = actions.supported }
-end
-
-return M
diff --git a/.config/nvim/lua/lsp/null-ls/formatters.lua b/.config/nvim/lua/lsp/null-ls/formatters.lua
deleted file mode 100644
index 72d622a..0000000
--- a/.config/nvim/lua/lsp/null-ls/formatters.lua
+++ /dev/null
@@ -1,82 +0,0 @@
-local M = {}
-
-local null_ls = require "null-ls"
-local services = require "lsp.null-ls.services"
-local Log = require "core.log"
-
-local is_registered = function(name)
- local query = {
- name = name,
- method = require("null-ls").methods.FORMATTING,
- }
- return require("null-ls.sources").is_registered(query)
-end
-
-function M.list_registered_providers(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 "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
-end
-
-function M.list_configured(formatter_configs)
- local formatters, errors = {}, {}
-
- for _, fmt_config in ipairs(formatter_configs) do
- local name = fmt_config.exe:gsub("-", "_")
- local formatter = null_ls.builtins.formatting[name]
-
- if not formatter then
- Log:error("Not a valid formatter: " .. fmt_config.exe)
- errors[name] = {} -- Add data here when necessary
- elseif is_registered(fmt_config.exe) then
- Log:trace "Skipping registering the source more than once"
- else
- local formatter_cmd = services.find_command(formatter._opts.command)
- if not formatter_cmd then
- Log:warn("Not found: " .. formatter._opts.command)
- errors[name] = {} -- Add data here when necessary
- else
- Log:debug("Using formatter: " .. formatter_cmd)
- table.insert(
- formatters,
- formatter.with {
- command = formatter_cmd,
- extra_args = fmt_config.args,
- filetypes = fmt_config.filetypes,
- }
- )
- end
- end
- end
-
- return { supported = formatters, unsupported = errors }
-end
-
-function M.setup(formatter_configs)
- if vim.tbl_isempty(formatter_configs) then
- return
- end
-
- local formatters = M.list_configured(formatter_configs)
- null_ls.register { sources = formatters.supported }
-end
-
-return M
diff --git a/.config/nvim/lua/lsp/null-ls/init.lua b/.config/nvim/lua/lsp/null-ls/init.lua
deleted file mode 100644
index adbc5b2..0000000
--- a/.config/nvim/lua/lsp/null-ls/init.lua
+++ /dev/null
@@ -1,22 +0,0 @@
-local M = {}
-
-local Log = require "core.log"
-
-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
-
- null_ls.config(options.lsp.null_ls.config)
- local default_opts = require("lsp").get_common_opts()
-
- if vim.tbl_isempty(options.lsp.null_ls.setup or {}) then
- options.lsp.null_ls.setup = default_opts
- end
-
- require("lspconfig")["null-ls"].setup(options.lsp.null_ls.setup)
-end
-
-return M
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
deleted file mode 100644
index ec5e25a..0000000
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ /dev/null
@@ -1,82 +0,0 @@
-local M = {}
-
-local null_ls = require "null-ls"
-local services = require "lsp.null-ls.services"
-local Log = require "core.log"
-
-local is_registered = function(name)
- local query = {
- name = name,
- method = require("null-ls").methods.DIAGNOSTICS,
- }
- return require("null-ls.sources").is_registered(query)
-end
-
-function M.list_registered_providers(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 "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
-end
-
-function M.list_configured(linter_configs)
- local linters, errors = {}, {}
-
- for _, lnt_config in pairs(linter_configs) do
- local name = lnt_config.exe:gsub("-", "_")
- local linter = null_ls.builtins.diagnostics[name]
-
- if not linter then
- Log:error("Not a valid linter: " .. lnt_config.exe)
- errors[lnt_config.exe] = {} -- Add data here when necessary
- elseif is_registered(lnt_config.exe) then
- Log:trace "Skipping registering the source more than once"
- else
- local linter_cmd = services.find_command(linter._opts.command)
- if not linter_cmd then
- Log:warn("Not found: " .. linter._opts.command)
- errors[name] = {} -- Add data here when necessary
- else
- Log:debug("Using linter: " .. linter_cmd)
- table.insert(
- linters,
- linter.with {
- command = linter_cmd,
- extra_args = lnt_config.args,
- filetypes = lnt_config.filetypes,
- }
- )
- end
- end
- end
-
- return { supported = linters, unsupported = errors }
-end
-
-function M.setup(linter_configs)
- if vim.tbl_isempty(linter_configs) then
- return
- end
-
- local linters = M.list_configured(linter_configs)
- null_ls.register { sources = linters.supported }
-end
-
-return M
diff --git a/.config/nvim/lua/lsp/null-ls/services.lua b/.config/nvim/lua/lsp/null-ls/services.lua
deleted file mode 100644
index 6a52520..0000000
--- a/.config/nvim/lua/lsp/null-ls/services.lua
+++ /dev/null
@@ -1,61 +0,0 @@
-local M = {}
-
-local function find_root_dir()
- local util = require "lspconfig/util"
- local lsp_utils = require "lsp.utils"
-
- local ts_client = lsp_utils.is_client_active "typescript"
- if ts_client then
- return ts_client.config.root_dir
- end
- local dirname = vim.fn.expand "%:p:h"
- return util.root_pattern "package.json"(dirname)
-end
-
-local function from_node_modules(command)
- local root_dir = find_root_dir()
-
- if not root_dir then
- return nil
- end
-
- return root_dir .. "/node_modules/.bin/" .. command
-end
-
-local local_providers = {
- prettier = { find = from_node_modules },
- prettierd = { find = from_node_modules },
- prettier_d_slim = { find = from_node_modules },
- eslint_d = { find = from_node_modules },
- eslint = { find = from_node_modules },
- stylelint = { find = from_node_modules },
-}
-
-function M.find_command(command)
- if local_providers[command] then
- local local_command = local_providers[command].find(command)
- if local_command and vim.fn.executable(local_command) == 1 then
- return local_command
- end
- end
-
- if vim.fn.executable(command) == 1 then
- return command
- end
- return nil
-end
-
-function M.list_registered_providers_names(filetype)
- local s = require "null-ls.sources"
- local available_sources = s.get_available(filetype)
- local registered = {}
- for _, source in ipairs(available_sources) do
- for method in pairs(source.methods) do
- registered[method] = registered[method] or {}
- table.insert(registered[method], source.name)
- end
- end
- return registered
-end
-
-return M