summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/null-ls/linters.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-11 22:03:16 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-11 22:03:16 +0200
commitdf66b461596d351367f90d41a0fabffb873de4be (patch)
tree711b15790bb97ba0bfa57e1e863fe9a521d55bec /.config/nvim/lua/lsp/null-ls/linters.lua
parent611b15e94dadc7351d5ff67f268791d5269ea112 (diff)
Merge updates from lunarvim
Diffstat (limited to '.config/nvim/lua/lsp/null-ls/linters.lua')
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
index e9e92e9..3f834ba 100644
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ b/.config/nvim/lua/lsp/null-ls/linters.lua
@@ -13,9 +13,13 @@ end
function M.list_available(filetype)
local linters = {}
+ local tbl = require "utils.table"
for _, provider in pairs(null_ls.builtins.diagnostics) do
- -- TODO: Add support for wildcard filetypes
- if vim.tbl_contains(provider.filetypes or {}, filetype) then
+ if
+ tbl.contains(provider.filetypes or {}, function(ft)
+ return ft == "*" or ft == filetype
+ end)
+ then
table.insert(linters, provider.name)
end
end
@@ -27,7 +31,8 @@ function M.list_configured(linter_configs)
local linters, errors = {}, {}
for _, lnt_config in pairs(linter_configs) do
- local linter = null_ls.builtins.diagnostics[lnt_config.exe]
+ local linter_name = lnt_config.exe:gsub("-", "_")
+ local linter = null_ls.builtins.diagnostics[linter_name]
if not linter then
Log:error("Not a valid linter: " .. lnt_config.exe)
@@ -42,6 +47,7 @@ function M.list_configured(linter_configs)
linters[lnt_config.exe] = linter.with {
command = linter_cmd,
extra_args = lnt_config.args,
+ filetypes = lnt_config.filetypes,
}
end
end
@@ -50,14 +56,13 @@ function M.list_configured(linter_configs)
return { supported = linters, unsupported = errors }
end
-function M.setup(linter_configs, filetype)
+function M.setup(linter_configs)
if vim.tbl_isempty(linter_configs) then
return
end
- local linters_by_ft = {}
- linters_by_ft[filetype] = M.list_configured(linter_configs)
- null_ls.register { sources = linters_by_ft[filetype].supported }
+ local linters = M.list_configured(linter_configs)
+ null_ls.register { sources = linters.supported }
end
return M